aboutsummaryrefslogtreecommitdiff
path: root/examples/client
diff options
context:
space:
mode:
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)
}