|
|
|
@ -74,7 +74,10 @@ func TestProcessMessageValidatorAnnounce(test *testing.T) { |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("newhost failure: %v", err) |
|
|
|
|
} |
|
|
|
|
consensusLeader := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
consensusLeader, err := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") |
|
|
|
|
consensusLeader.block = blockBytes |
|
|
|
|
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053") |
|
|
|
@ -92,7 +95,10 @@ func TestProcessMessageValidatorAnnounce(test *testing.T) { |
|
|
|
|
test.Errorf("Failed to unmarshal message payload") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
consensusValidator1 := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
consensusValidator1, err := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
consensusValidator1.ChainReader = MockChainReader{} |
|
|
|
|
|
|
|
|
|
copy(consensusValidator1.blockHash[:], hashBytes[:]) |
|
|
|
@ -129,7 +135,10 @@ func TestProcessMessageValidatorPrepared(test *testing.T) { |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("newhost failure: %v", err) |
|
|
|
|
} |
|
|
|
|
consensusLeader := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
consensusLeader, err := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") |
|
|
|
|
consensusLeader.block = blockBytes |
|
|
|
|
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053") |
|
|
|
@ -141,7 +150,10 @@ func TestProcessMessageValidatorPrepared(test *testing.T) { |
|
|
|
|
|
|
|
|
|
preparedMsg, _ := consensusLeader.constructPreparedMessage() |
|
|
|
|
|
|
|
|
|
consensusValidator1 := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
consensusValidator1, err := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
consensusValidator1.ChainReader = MockChainReader{} |
|
|
|
|
|
|
|
|
|
// Get actual consensus messages.
|
|
|
|
@ -199,7 +211,10 @@ func TestProcessMessageValidatorCommitted(test *testing.T) { |
|
|
|
|
test.Fatalf("newhost failure: %v", err) |
|
|
|
|
} |
|
|
|
|
message := &msg_pb.Message{} |
|
|
|
|
consensusLeader := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
consensusLeader, err := New(host, 0, []p2p.Peer{validator1, validator2, validator3}, leader, leaderPriKey) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") |
|
|
|
|
consensusLeader.block = blockBytes |
|
|
|
|
hashBytes, err := hex.DecodeString("bdd66a8211ffcbf0ad431b506c854b49264951fd9f690928e9cf44910c381053") |
|
|
|
@ -230,7 +245,10 @@ func TestProcessMessageValidatorCommitted(test *testing.T) { |
|
|
|
|
test.Errorf("Failed to get consensus message") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
consensusValidator1 := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
consensusValidator1, err := New(m, 0, []p2p.Peer{validator1, validator2, validator3}, leader, bls_cosi.RandPrivateKey()) |
|
|
|
|
if err != nil { |
|
|
|
|
test.Fatalf("Cannot craeate consensus: %v", err) |
|
|
|
|
} |
|
|
|
|
consensusValidator1.ChainReader = MockChainReader{} |
|
|
|
|
consensusValidator1.OnConsensusDone = func(newBlock *types.Block) {} |
|
|
|
|
|
|
|
|
|