From 91b4219d2557d2d7e34c2d17f3daa8079ed8eddf Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 4 Jan 2019 18:14:22 +0000 Subject: [PATCH 1/3] use a common type for block hash Signed-off-by: Leo Chen --- api/proto/node/node.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/proto/node/node.go b/api/proto/node/node.go index d855edecd..a9abbfcc0 100644 --- a/api/proto/node/node.go +++ b/api/proto/node/node.go @@ -5,6 +5,7 @@ import ( "encoding/gob" "log" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/core/types" @@ -34,7 +35,7 @@ const ( // BlockchainSyncMessage is a struct for blockchain sync message. type BlockchainSyncMessage struct { BlockHeight int - BlockHashes [][32]byte + BlockHashes []common.Hash } // BlockchainSyncMessageType represents BlockchainSyncMessageType type. From 867f106c50188290e260d05ed28b47f11e9d026e Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 4 Jan 2019 18:14:58 +0000 Subject: [PATCH 2/3] simplify the pingpong_test.go Signed-off-by: Leo Chen --- api/proto/node/pingpong_test.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/api/proto/node/pingpong_test.go b/api/proto/node/pingpong_test.go index 017756308..14064f623 100644 --- a/api/proto/node/pingpong_test.go +++ b/api/proto/node/pingpong_test.go @@ -2,6 +2,7 @@ package node import ( "fmt" + "reflect" "strings" "testing" @@ -57,8 +58,6 @@ func TestString(test *testing.T) { r1 := fmt.Sprintf("%v", *ping1) if strings.Compare(r1, e1) != 0 { test.Errorf("expect: %v, got: %v", e1, r1) - } else { - fmt.Println(r1) } ping1.Node.Role = ClientRole @@ -66,8 +65,6 @@ func TestString(test *testing.T) { r3 := fmt.Sprintf("%v", *ping1) if strings.Compare(r3, e3) != 0 { test.Errorf("expect: %v, got: %v", e3, r3) - } else { - fmt.Println(r3) } pong1 := NewPongMessage(p2, pubKeys) @@ -75,22 +72,12 @@ func TestString(test *testing.T) { if !strings.HasPrefix(r2, e2) { test.Errorf("expect: %v, got: %v", e2, r2) - } else { - fmt.Println(r2) } } func TestSerialize(test *testing.T) { ping1 := NewPingMessage(p1) buf1 = ping1.ConstructPingMessage() - fmt.Printf("buf ping: %v\n", buf1) - - pong1 := NewPongMessage(p2, pubKeys) - buf2 = pong1.ConstructPongMessage() - fmt.Printf("buf pong: %v\n", buf2) -} - -func TestDeserialize(test *testing.T) { msg1, err := proto.GetMessagePayload(buf1) if err != nil { test.Error("GetMessagePayload Failed!") @@ -99,13 +86,20 @@ func TestDeserialize(test *testing.T) { if err != nil { test.Error("Ping failed!") } - fmt.Println(ping) + if !reflect.DeepEqual(ping, ping1) { + test.Error("Serialize/Deserialze Ping Message Failed") + } + + pong1 := NewPongMessage(p2, pubKeys) + buf2 = pong1.ConstructPongMessage() msg2, err := proto.GetMessagePayload(buf2) pong, err := GetPongMessage(msg2) if err != nil { test.Error("Pong failed!") } - fmt.Println(pong) + if !reflect.DeepEqual(pong, pong1) { + test.Error("Serialize/Deserialze Pong Message Failed") + } } From 83df76cdca642f6a0b2b0c1224910ecf72651e2a Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 4 Jan 2019 18:19:31 +0000 Subject: [PATCH 3/3] move script to test/ directory Signed-off-by: Leo Chen --- test_before_submit.sh => test/test_before_submit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test_before_submit.sh => test/test_before_submit.sh (89%) diff --git a/test_before_submit.sh b/test/test_before_submit.sh similarity index 89% rename from test_before_submit.sh rename to test/test_before_submit.sh index 394957157..465e294c4 100755 --- a/test_before_submit.sh +++ b/test/test_before_submit.sh @@ -1,6 +1,6 @@ #!/bin/bash -DIRROOT=$(dirname $0) +DIRROOT=$(dirname $0)/.. OS=$(uname -s) go test ./...