|
|
|
@ -117,3 +117,22 @@ func TestSignAndMarshalConsensusMessage(t *testing.T) { |
|
|
|
|
t.Error("No signature is signed on the consensus message.") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSetConsensusID(t *testing.T) { |
|
|
|
|
leader := p2p.Peer{IP: "127.0.0.1", Port: "9902"} |
|
|
|
|
priKey, _, _ := utils.GenKeyP2P("127.0.0.1", "9902") |
|
|
|
|
host, err := p2pimpl.NewHost(&leader, priKey) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("newhost failure: %v", err) |
|
|
|
|
} |
|
|
|
|
consensus, err := New(host, 0, leader, bls.RandPrivateKey()) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
height := uint32(1000) |
|
|
|
|
consensus.SetConsensusID(height) |
|
|
|
|
if consensus.consensusID != height { |
|
|
|
|
t.Errorf("Cannot set consensus ID. Got: %v, Expected: %v", consensus.consensusID, height) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|