From 81882be6527d6933ee4e86af7e898730f1532923 Mon Sep 17 00:00:00 2001 From: uynarud Date: Tue, 17 Oct 2017 15:26:13 +0800 Subject: [PATCH] rpc: better testing client log. --- config.pb.txt | 20 ++++++++++---------- config1.pb.txt | 20 ++++++++++---------- rpc/testing/client/main.go | 27 ++++++++++++++++----------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/config.pb.txt b/config.pb.txt index edfde8f95..f6daf5c7c 100644 --- a/config.pb.txt +++ b/config.pb.txt @@ -5,26 +5,26 @@ # p2p { - # seed: "UNCOMMENT_AND_SET_SEED_NODE_ADDRESS" - port: 51413 + # seed: "UNCOMMENT_AND_SET_SEED_NODE_ADDRESS" + port: 51413 } rpc { - port: 51510 + port: 51510 } pow { - coinbase: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf" + coinbase: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf" } account { - # keystore.SECP256K1 = 1 - signature: 1 + # keystore.SECP256K1 = 1 + signature: 1 - # keystore.SCRYPT = 1 << 4 - encrypt: 16 + # keystore.SCRYPT = 1 << 4 + encrypt: 16 - key_dir: "testKey" + key_dir: "testKey" - test_passphrase: "passphrase" + test_passphrase: "passphrase" } diff --git a/config1.pb.txt b/config1.pb.txt index 4e07ff9e2..33a477e1e 100644 --- a/config1.pb.txt +++ b/config1.pb.txt @@ -1,26 +1,26 @@ # Sample non-seed testing node config. p2p { - port: 10001 - seed: "/ip4/192.168.1.18/tcp/51413/ipfs/QmVMamgHNoR8GBUbq4r9BTFzod5F2BvhSgaGLVxPpXcWNm" + port: 10001 + seed: "/ip4/192.168.1.18/tcp/51413/ipfs/QmVMamgHNoR8GBUbq4r9BTFzod5F2BvhSgaGLVxPpXcWNm" } rpc { - port: 51510 + port: 51510 } pow { - coinbase: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf" + coinbase: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf" } account { - # keystore.SECP256K1 = 1 - signature: 1 + # keystore.SECP256K1 = 1 + signature: 1 - # keystore.SCRYPT = 1 << 4 - encrypt: 16 + # keystore.SCRYPT = 1 << 4 + encrypt: 16 - key_dir: "testKey" + key_dir: "testKey" - test_passphrase: "passphrase" + test_passphrase: "passphrase" } diff --git a/rpc/testing/client/main.go b/rpc/testing/client/main.go index f79221ad1..c7d76ca7e 100644 --- a/rpc/testing/client/main.go +++ b/rpc/testing/client/main.go @@ -30,7 +30,12 @@ import ( ) // TODO: add command line flag. -const config = "../../../config.pb.txt" +const ( + config = "../../../config.pb.txt" + from = "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf" + to = "22ac3a9a2b1c31b7a9084e46eae16e761f83f02324092b09" + value = 2 +) // RPC testing client. func main() { @@ -47,35 +52,35 @@ func main() { var nonce uint64 { - r, err := ac.GetAccountState(context.Background(), &rpcpb.GetAccountStateRequest{Address: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf"}) + r, err := ac.GetAccountState(context.Background(), &rpcpb.GetAccountStateRequest{Address: from}) if err != nil { - log.Println("GetAccountState failed: ", err) + log.Println("GetAccountState", from, "failed", err) } else { val, _ := util.NewUint128FromFixedSizeByteSlice(r.GetBalance()) nonce = r.Nonce - log.Println("GetAccountState respnonse: ", r.Nonce, val) + log.Println("GetAccountState", from, "nonce", r.Nonce, "value", val) } } { - v := util.NewUint128FromInt(1) + v := util.NewUint128FromInt(value) fsb, _ := v.ToFixedSizeByteSlice() - r, err := ac.SendTransaction(context.Background(), &rpcpb.SendTransactionRequest{From: "8a209cec02cbeab7e2f74ad969d2dfe8dd24416aa65589bf", To: "22ac3a9a2b1c31b7a9084e46eae16e761f83f02324092b09", Value: fsb, Nonce: nonce + 1}) + r, err := ac.SendTransaction(context.Background(), &rpcpb.SendTransactionRequest{From: from, To: to, Value: fsb, Nonce: nonce + 1}) if err != nil { - log.Println("SendTransaction failed: ", err) + log.Println("SendTransaction failed:", err) } else { - log.Println("SendTransaction response: ", r) + log.Println("SendTransaction", from, "->", to, "value", value, r) } } { - r, err := ac.GetAccountState(context.Background(), &rpcpb.GetAccountStateRequest{Address: "22ac3a9a2b1c31b7a9084e46eae16e761f83f02324092b09"}) + r, err := ac.GetAccountState(context.Background(), &rpcpb.GetAccountStateRequest{Address: to}) if err != nil { - log.Println("GetAccountState failed: ", err) + log.Println("GetAccountState", to, "failed", err) } else { val, _ := util.NewUint128FromFixedSizeByteSlice(r.GetBalance()) nonce = r.Nonce - log.Println("GetAccountState respnonse: ", r.Nonce, val) + log.Println("GetAccountState", to, "nonce", r.Nonce, "value", val) } }