test: Check hashBlockCommitments before, at, and after NU5 activation

This commit is contained in:
Jack Grigg 2021-06-17 17:33:04 +01:00
parent da8fcedd4d
commit 9930a27992
1 changed files with 17 additions and 13 deletions

View File

@ -38,23 +38,27 @@ class AuthDataRootTest(BitcoinTestFramework):
self.nodes[0].generate(2) self.nodes[0].generate(2)
self.sync_all() self.sync_all()
# Before NU5 activation, the hashBlockCommitments field of the block # For blocks prior to NU5 activation, the hashBlockCommitments field of
# header contains the root of the ZIP 221 history tree. # the block header contains the root of the ZIP 221 history tree.
block_before = self.nodes[0].getblock('202') for i in range(3):
assert_equal(block_before['blockcommitments'], block_before['chainhistoryroot']) block_before = self.nodes[0].getblock('%d' % (202 + i))
assert_equal(block_before['blockcommitments'], block_before['chainhistoryroot'])
# Generate blocks until we are on NU5 rules. self.nodes[0].generate(1)
self.nodes[0].generate(3) self.sync_all()
self.sync_all()
# From NU5 activation, the hashBlockCommitments field of the block # From NU5 activation, the hashBlockCommitments field of the block
# header contains a hash of various block commitments (per ZIP 244). # header contains a hash of various block commitments (per ZIP 244).
block_after = self.nodes[0].getblock('205') for i in range(2):
block_commitments = bytes_to_hex_str(derive_block_commitments_hash( block_after = self.nodes[0].getblock('%d' % (205 + i))
hex_str_to_bytes(block_after['chainhistoryroot'])[::-1], block_commitments = bytes_to_hex_str(derive_block_commitments_hash(
hex_str_to_bytes(block_after['authdataroot'])[::-1], hex_str_to_bytes(block_after['chainhistoryroot'])[::-1],
)[::-1]) hex_str_to_bytes(block_after['authdataroot'])[::-1],
assert_equal(block_after['blockcommitments'], block_commitments) )[::-1])
assert_equal(block_after['blockcommitments'], block_commitments)
self.nodes[0].generate(1)
self.sync_all()
if __name__ == '__main__': if __name__ == '__main__':