Skip to content

Commit

Permalink
rpc: better testing client log.
Browse files Browse the repository at this point in the history
  • Loading branch information
uynarud committed Oct 17, 2017
1 parent f446045 commit 81882be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
20 changes: 10 additions & 10 deletions config.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
20 changes: 10 additions & 10 deletions config1.pb.txt
Original file line number Diff line number Diff line change
@@ -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"
}
27 changes: 16 additions & 11 deletions rpc/testing/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 81882be

Please sign in to comment.