diff --git a/qa/rpc-tests/getblocktemplate.py b/qa/rpc-tests/getblocktemplate.py index 3eb70a509..ac2240b67 100755 --- a/qa/rpc-tests/getblocktemplate.py +++ b/qa/rpc-tests/getblocktemplate.py @@ -10,6 +10,7 @@ from test_framework.util import ( assert_equal, CANOPY_BRANCH_ID, NU5_BRANCH_ID, + get_coinbase_address, hex_str_to_bytes, nuparams, nustr, @@ -18,7 +19,6 @@ from test_framework.util import ( ) from test_framework.mininode import ( CTransaction, - uint256_from_str, ) from test_framework.blocktools import ( create_block @@ -49,7 +49,13 @@ class GetBlockTemplateTest(BitcoinTestFramework): node = self.node # sprout to transparent (v4) recipients = [{"address": self.transparent_addr, "amount": Decimal('0.1')}] - myopid = node.z_sendmany(self.sprout_addr, recipients) + myopid = node.z_sendmany(self.sprout_addr, recipients, 1) + wait_and_assert_operationid_status(node, myopid) + + def add_nu5_v5_tx_to_mempool(self): + node = self.node + recipients = [{"address": self.unified_addr, "amount": Decimal('9.99999')}] + myopid = node.z_sendmany(get_coinbase_address(node), recipients, 1, Decimal('0.00001'), 'AllowRevealedSenders') wait_and_assert_operationid_status(node, myopid) def add_transparent_tx_to_mempool(self): @@ -97,6 +103,7 @@ class GetBlockTemplateTest(BitcoinTestFramework): tx = CTransaction() tx.deserialize(f) tx.calc_sha256() + assert_equal(tx.hash, gbt_tx['hash']) assert_equal(tx.auth_digest_hex, node.getrawtransaction(tx.hash, 1)['authdigest']) block.vtx.append(tx) block.hashMerkleRoot = int(gbt['defaultroots']['merkleroot'], 16) @@ -104,7 +111,8 @@ class GetBlockTemplateTest(BitcoinTestFramework): assert_equal(len(block.vtx), len(gbt['transactions']) + 1, "number of transactions") assert_equal(block.hashPrevBlock, int(gbt['previousblockhash'], 16), "prevhash") if nu5_active: - assert_equal(uint256_from_str(block.calc_auth_data_root()), int(gbt['defaultroots']['authdataroot'], 16)) + block.hashAuthDataRoot = int(gbt['defaultroots']['authdataroot'], 16) + assert_equal(block.hashAuthDataRoot, block.calc_auth_data_root(), "authdataroot") else: assert 'authdataroot' not in gbt['defaultroots'] block.solve() @@ -131,6 +139,8 @@ class GetBlockTemplateTest(BitcoinTestFramework): wait_and_assert_operationid_status(node, myopid) self.transparent_addr = node.getnewaddress() + account = node.z_getnewaccount()['account'] + self.unified_addr = node.z_getaddressforaccount(account)['address'] node.generate(15) # at height 120, NU5 is not active @@ -176,13 +186,29 @@ class GetBlockTemplateTest(BitcoinTestFramework): self.add_transparent_tx_to_mempool() self.gbt_submitblock(True) - # Adding both v4 and v5 to cover legacy auth digest. + # Adding both v4 and v5 to cover legacy auth digest (without full auth digest subtree). + print("- both v4 and v5 transactions (plus coinbase)") + self.add_nu5_v4_tx_to_mempool() + self.add_transparent_tx_to_mempool() + self.gbt_submitblock(True) + + # Adding both v4 and v5 to cover legacy auth digest (with full auth digest subtree). print("- both v4 and v5 transactions (plus coinbase)") self.add_nu5_v4_tx_to_mempool() self.add_transparent_tx_to_mempool() self.add_transparent_tx_to_mempool() self.gbt_submitblock(True) + print("- block with 6 Orchard transactions (plus coinbase)") + for i in range(0, 6): + print(str(node.z_getbalance(self.transparent_addr))) + self.add_nu5_v5_tx_to_mempool() + self.gbt_submitblock(True) + + print("- block with 7 Orchard transactions (plus coinbase)") + for i in range(0, 7): + self.add_nu5_v5_tx_to_mempool() + self.gbt_submitblock(True) if __name__ == '__main__': GetBlockTemplateTest().main() diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index 53a2512ca..107075aca 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -28,6 +28,7 @@ def create_block(hashprev, coinbase, nTime=None, nBits=None, hashFinalSaplingRoo block.nBits = nBits block.vtx.append(coinbase) block.hashMerkleRoot = block.calc_merkle_root() + block.hashAuthDataRoot = block.calc_auth_data_root() block.calc_sha256() return block diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 5b3ff3b63..abbccf16a 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -174,21 +174,25 @@ def deser_vector(f, c): return r -def ser_vector(l): +def ser_vector(elems): r = b"" - if len(l) < 253: - r = struct.pack("B", len(l)) - elif len(l) < 0x10000: - r = struct.pack(" 0: - flags = f.read(1) + flags = struct.unpack("B", f.read(1))[0] self.enableSpends = (flags & ORCHARD_FLAGS_ENABLE_SPENDS) != 0 self.enableOutputs = (flags & ORCHARD_FLAGS_ENABLE_OUTPUTS) != 0 self.valueBalance = struct.unpack(" 0: - flags = 0 ^ ( - ORCHARD_FLAGS_ENABLE_SPENDS if self.enableSpends else 0 - ) ^ ( - ORCHARD_FLAGS_ENABLE_OUTPUTS if self.enableOutputs else 0 - ) - r += struct.pack("B", flags) + r += struct.pack("B", self.flags()) r += struct.pack(" 0: - digest.update(orchardBundle.proofs) + digest.update(bytes(orchardBundle.proofs)) for desc in orchardBundle.actions: digest.update(desc.spendAuthSig.serialize()) digest.update(orchardBundle.bindingSig.serialize())