aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Buchwald <[email protected]>2020-11-25 11:36:28 -0500
committerAaron Buchwald <[email protected]>2020-11-25 11:36:28 -0500
commit60e7fbe4c3278aa42fe7fb6517482fe1d7f4573f (patch)
tree7c29d399ecef48eb347de62ff58ba9d6eaade1ae
parent2ea6c2aeacd37f347c5794d6b300a6d1815c251b (diff)
Update rpc test to use new formatting
-rw-r--r--examples/client/main.go28
1 files changed, 14 insertions, 14 deletions
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)
}