From 60e7fbe4c3278aa42fe7fb6517482fe1d7f4573f Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Wed, 25 Nov 2020 11:36:28 -0500 Subject: Update rpc test to use new formatting --- examples/client/main.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'examples/client') diff --git a/examples/client/main.go b/examples/client/main.go index 5f61e6a..8da7db0 100644 --- a/examples/client/main.go +++ b/examples/client/main.go @@ -22,8 +22,22 @@ var ( prefixedPrivateKey = fmt.Sprintf("PrivateKey-%s", key) ipAddr = "127.0.0.1" port = 9650 + pk crypto.PrivateKey + secpKey *crypto.PrivateKeySECP256K1R + ethAddr common.Address ) +func init() { + pkBytes, err := formatting.Decode(formatting.CB58, key) + if err != nil { + panic(err) + } + factory := crypto.FactorySECP256K1R{} + pk, err = factory.ToPrivateKey(pkBytes) + secpKey = pk.(*crypto.PrivateKeySECP256K1R) + ethAddr = evm.GetEthAddress(secpKey) +} + type ethWSAPITestExecutor struct { uri string requestTimeout time.Duration @@ -39,13 +53,6 @@ func (e *ethWSAPITestExecutor) ExecuteTest() error { ctx := context.Background() - cb58 := formatting.CB58{} - factory := crypto.FactorySECP256K1R{} - _ = cb58.FromString(key) - pk, _ := factory.ToPrivateKey(cb58.Bytes) - secpKey := pk.(*crypto.PrivateKeySECP256K1R) - ethAddr := evm.GetEthAddress(secpKey) - if err := testSubscription(ctx, client); err != nil { return fmt.Errorf("Subscription Test failed: %w", err) } @@ -72,13 +79,6 @@ func (e *ethRPCAPITestExecutor) ExecuteTest() error { ctx := context.Background() - cb58 := formatting.CB58{} - factory := crypto.FactorySECP256K1R{} - _ = cb58.FromString(key) - pk, _ := factory.ToPrivateKey(cb58.Bytes) - secpKey := pk.(*crypto.PrivateKeySECP256K1R) - ethAddr := evm.GetEthAddress(secpKey) - if err := testHeaderAndBlockCalls(ctx, client, ethAddr); err != nil { return fmt.Errorf("HeaderAndBlockCalls Test failed: %w", err) } -- cgit v1.2.3-70-g09d2