aboutsummaryrefslogtreecommitdiff
path: root/examples/client
diff options
context:
space:
mode:
authoraaronbuchwald <[email protected]>2020-11-25 11:37:05 -0500
committerGitHub <[email protected]>2020-11-25 11:37:05 -0500
commit1ed9c772e948720b02d38a233c9f63a7a95ee761 (patch)
tree7c29d399ecef48eb347de62ff58ba9d6eaade1ae /examples/client
parent2ea6c2aeacd37f347c5794d6b300a6d1815c251b (diff)
parent60e7fbe4c3278aa42fe7fb6517482fe1d7f4573f (diff)
Merge pull request #63 from ava-labs/update-rpc-testv0.3.15-rc.2
Update rpc test to use new formatting
Diffstat (limited to 'examples/client')
-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)
}