From 16cb1711b051dfc0b95b1d5e4233047a5b636970 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 3 Jan 2019 08:21:04 +0000 Subject: [PATCH] add test for api/client Signed-off-by: Leo Chen --- api/client/client_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 api/client/client_test.go diff --git a/api/client/client_test.go b/api/client/client_test.go new file mode 100644 index 000000000..5d290e852 --- /dev/null +++ b/api/client/client_test.go @@ -0,0 +1,24 @@ +package client + +import ( + "reflect" + "testing" + + "github.com/harmony-one/harmony/p2p" +) + +func TestClient(t *testing.T) { + leaders := map[uint32]p2p.Peer{ + 0: p2p.Peer{ + IP: "127.0.0.1", + Port: "90", + }, + } + client := NewClient(nil, &leaders) + + leadersGot := client.GetLeaders() + + if len(leadersGot) != 1 || !reflect.DeepEqual(leaders[0], leadersGot[0]) { + t.Errorf("expected: %v, got: %v\n", leaders[0], leadersGot[0]) + } +}