TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
}
wantHex := strings.Join([]string{
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, "")
gotHex := testutil.Serialize(t, blockHeader)
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
wantHex: strings.Join([]string{
"01", // serialization flags
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, ""),
},
{
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
wantError: blockchain.ErrRange,
},
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
wantError: blockchain.ErrRange,
},
Height: 9223372036854775807, // MaxInt64(9223372036854775807)
PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
Timestamp: 1528945000,
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
wantHex: strings.Join([]string{
"01", // serialization flags
"40", // commitment extensible field length
"0000000000000000000000000000000000000000000000000000000000000000", // transactions merkle root
"0000000000000000000000000000000000000000000000000000000000000000", // tx status hash
+ "040102beef", //BlockWitness
+ }, ""),
+ },
+ {
+ blockHeader: &BlockHeader{
+ Version: 1,
+ Height: 9223372036854775807, // MaxInt64(9223372036854775807)
+ PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
+ Timestamp: 1528945000,
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}, []byte{0xab, 0xcd}, []byte{0xcd, 0x68}}},
+ },
+ wantHex: strings.Join([]string{
+ "01", // serialization flags
+ "01", // version
+ "ffffffffffffffff7f", // block height
+ "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
+ "e8b287d905", // timestamp
+ "40", // commitment extensible field length
+ "0000000000000000000000000000000000000000000000000000000000000000", // transactions merkle root
+ "0000000000000000000000000000000000000000000000000000000000000000", // tx status hash
+ "0a0302beef02abcd02cd68", //BlockWitness
+ }, ""),
+ },
+ {
+ blockHeader: &BlockHeader{
+ Version: 1,
+ Height: 9223372036854775807, // MaxInt64(9223372036854775807)
+ PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
+ Timestamp: 1528945000,
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}, nil, []byte{0xcd, 0x68}}},
+ },
+ wantHex: strings.Join([]string{
+ "01", // serialization flags
+ "01", // version
+ "ffffffffffffffff7f", // block height
+ "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
+ "e8b287d905", // timestamp
+ "40", // commitment extensible field length
+ "0000000000000000000000000000000000000000000000000000000000000000", // transactions merkle root
+ "0000000000000000000000000000000000000000000000000000000000000000", // tx status hash
+ "080302beef0002cd68", //BlockWitness
+ }, ""),
+ },
+ {
+ blockHeader: &BlockHeader{
+ Version: 1,
+ Height: 9223372036854775807, // MaxInt64(9223372036854775807)
+ PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
+ Timestamp: 1528945000,
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}, []byte{}, []byte{0xcd, 0x68}}},
+ },
+ wantHex: strings.Join([]string{
+ "01", // serialization flags
+ "01", // version
+ "ffffffffffffffff7f", // block height
+ "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
+ "e8b287d905", // timestamp
+ "40", // commitment extensible field length
+ "0000000000000000000000000000000000000000000000000000000000000000", // transactions merkle root
+ "0000000000000000000000000000000000000000000000000000000000000000", // tx status hash
+ "080302beef0002cd68", //BlockWitness
+ }, ""),
+ },
+ {
+ blockHeader: &BlockHeader{
+ Version: 1,
+ Height: 9223372036854775807, // MaxInt64(9223372036854775807)
+ PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
+ Timestamp: 1528945000,
+ BlockWitness: BlockWitness{Witness: [][]byte{}},
+ },
+ wantHex: strings.Join([]string{
+ "01", // serialization flags
+ "01", // version
+ "ffffffffffffffff7f", // block height
+ "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
+ "e8b287d905", // timestamp
+ "40", // commitment extensible field length
+ "0000000000000000000000000000000000000000000000000000000000000000", // transactions merkle root
+ "0000000000000000000000000000000000000000000000000000000000000000", // tx status hash
+ "0100", //BlockWitness
}, ""),
},
}
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, ""),
wantBlockHeader: &BlockHeader{
Version: 1,
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
},
{
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, ""),
wantBlockHeader: &BlockHeader{
Version: 1,
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
},
{
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, ""),
wantError: errors.New("binary: varint overflows a 64-bit integer"),
},
"40", // commitment extensible field length
"ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
"b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
+ "040102beef", //BlockWitness
}, ""),
wantBlockHeader: &BlockHeader{
Version: 1,
TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
},
+ BlockWitness: BlockWitness{Witness: [][]byte{[]byte{0xbe, 0xef}}},
},
},
}