beaconchain rpc test

pull/203/head
ak 6 years ago
parent 0cbbc187e9
commit 9c902e808d
  1. 26
      internal/beaconchain/libs/beaconchain_test.go

@ -1,6 +1,13 @@
package beaconchain
import "testing"
import (
"reflect"
"strconv"
"testing"
proto "github.com/harmony-one/harmony/api/beaconchain"
beaconchain "github.com/harmony-one/harmony/internal/beaconchain/rpc"
)
func TestNewNode(t *testing.T) {
var ip, port string
@ -21,3 +28,20 @@ func TestNewNode(t *testing.T) {
t.Error("beacon chain number of shards not initialized to given number of desired shards")
}
}
func TestFetchLeaders(t *testing.T) {
var ip string
ip = "127.0.0.1"
beaconport := "8080"
numshards := 1
bc := New(numshards, ip, beaconport)
bc.SupportRPC()
port, _ := strconv.Atoi(beaconport)
bcClient := beaconchain.NewClient("127.0.0.1", strconv.Itoa(port+BeaconchainServicePortDiff))
response := bcClient.GetLeaders()
expresponse := &proto.FetchLeadersResponse{}
if !reflect.DeepEqual(response, expresponse) {
t.Error("was expexting a empty leaders array")
}
}

Loading…
Cancel
Save