diff --git a/consensus/consensus_validator_test.go b/consensus/consensus_validator_test.go index 2c2817628..378603d7c 100644 --- a/consensus/consensus_validator_test.go +++ b/consensus/consensus_validator_test.go @@ -78,7 +78,7 @@ func TestProcessMessageValidatorAnnounce(test *testing.T) { if err != nil { test.Fatalf("Cannot craeate consensus: %v", err) } - blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") + blockBytes, err := testBlockBytes() if err != nil { test.Fatalf("Cannot decode blockByte: %v", err) } @@ -115,6 +115,98 @@ func TestProcessMessageValidatorAnnounce(test *testing.T) { time.Sleep(1 * time.Second) } +func testBlockBytes() ([]byte, error) { + return hex.DecodeString("" + + // BEGIN 677-byte Block + "f902a5" + + // BEGIN 672-byte header + "f902a0" + + // 32-byte ParentHash + "a0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // 20-byte Coinbase + "94" + + "0000000000000000000000000000000000000000" + + // 32-byte Root + "a0" + + "2b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2a" + + // 32-byte TxHash + "a0" + + "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + + // 32-byte ReceiptHash + "a0" + + "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + + // 256-byte Bloom + "b90100" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // 3-byte Difficulty + "83" + + "020000" + + // 0-byte Number + "80" + + "" + + // 5-byte GasLimit + "85" + + "02540be400" + + // 0-byte GasUsed + "80" + + "" + + // 0-byte Time + "80" + + "" + + // 0-byte Extra + "80" + + "" + + // 32-byte MixDigest + "a0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // 8-byte Nonce + "88" + + "0000000000000000" + + // 4-byte ShardID + "84" + + "00000001" + + // 48-byte PrepareSignature + "b0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "00000000000000000000000000000000" + + // 0-byte PrepareBitmap + "80" + + "" + + // 48-byte CommitSignature + "b0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "00000000000000000000000000000000" + + // 0-byte CommitBitmap + "80" + + "" + + // 32-byte RandPreimage + "a0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // 32-byte RandSeed + "a0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // 32-byte ShardStateHash + "a0" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // END header + // BEGIN 0-byte uncles + "c0" + + // END uncles + // BEGIN 0-byte transactions + "c0" + + // END transactions + // END Block + "") +} + func TestProcessMessageValidatorPrepared(test *testing.T) { ctrl := gomock.NewController(test) defer ctrl.Finish() @@ -145,7 +237,7 @@ func TestProcessMessageValidatorPrepared(test *testing.T) { if err != nil { test.Fatalf("Cannot craeate consensus: %v", err) } - blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") + blockBytes, err := testBlockBytes() if err != nil { test.Fatalf("Cannot decode blockByte: %v", err) } @@ -227,7 +319,7 @@ func TestProcessMessageValidatorCommitted(test *testing.T) { if err != nil { test.Fatalf("Cannot craeate consensus: %v", err) } - blockBytes, err := hex.DecodeString("f902a5f902a0a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a02b418211410ee3e75b32abd925bbeba215172afa509d65c1953d4b4e505a4a2aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be400808080a000000000000000000000000000000000000000000000000000000000000000008800000000000000008400000001b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c0c0") + blockBytes, err := testBlockBytes() if err != nil { test.Fatalf("Cannot decode blockByte: %v", err) }