|
|
@ -1,6 +1,13 @@ |
|
|
|
package beaconchain |
|
|
|
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) { |
|
|
|
func TestNewNode(t *testing.T) { |
|
|
|
var ip, port string |
|
|
|
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") |
|
|
|
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") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|