Skip to content

Commit

Permalink
merge bitcoin#22738: fix failure in feature_nulldummy.py on single-co…
Browse files Browse the repository at this point in the history
…re machines
  • Loading branch information
kwvg committed Jul 23, 2024
1 parent ad96ef2 commit 847d866
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
from test_framework.messages import CTransaction
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)

NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"

Expand All @@ -44,7 +47,12 @@ def set_test_params(self):
# Need two nodes so GBT (getblocktemplate) doesn't complain that it's not connected.
self.num_nodes = 2
self.setup_clean_chain = True
self.extra_args = [['-whitelist=127.0.0.1', '-dip3params=105:105', '-bip147height=105']] * 2
self.extra_args = [[
'-whitelist=127.0.0.1',
'-dip3params=105:105',
'-bip147height=105',
'-par=1', # Use only one script thread to get the exact reject reason for testing
]] * 2

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down Expand Up @@ -74,30 +82,30 @@ def run_test(self):
txid1 = self.nodes[0].sendrawtransaction(test1txs[0].serialize().hex(), 0)
test1txs.append(create_transaction(self.nodes[0], txid1, self.ms_address, amount=48))
txid2 = self.nodes[0].sendrawtransaction(test1txs[1].serialize().hex(), 0)
self.block_submit(self.nodes[0], test1txs, True)
self.block_submit(self.nodes[0], test1txs, accept=True)

self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
test2tx = create_transaction(self.nodes[0], txid2, self.ms_address, amount=47)
trueDummy(test2tx)
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test2tx.serialize().hex(), 0)

self.log.info(f"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{COINBASE_MATURITY + 4}]")
self.block_submit(self.nodes[0], [test2tx], True)
self.block_submit(self.nodes[0], [test2tx], accept=True)

self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, amount=46)
test6txs=[CTransaction(test4tx)]
trueDummy(test4tx)
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test4tx.serialize().hex(), 0)
self.block_submit(self.nodes[0], [test4tx])
self.block_submit(self.nodes[0], [test4tx], accept=False)

self.log.info(f"Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [{COINBASE_MATURITY + 5}]")
for i in test6txs:
self.nodes[0].sendrawtransaction(i.serialize().hex(), 0)
self.block_submit(self.nodes[0], test6txs, True)
self.block_submit(self.nodes[0], test6txs, accept=True)


def block_submit(self, node, txs, accept = False):
def block_submit(self, node, txs, *, accept=False):
dip4_activated = self.lastblockheight + 1 >= COINBASE_MATURITY + 5
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
assert_equal(tmpl['previousblockhash'], self.lastblockhash)
Expand All @@ -109,8 +117,8 @@ def block_submit(self, node, txs, accept = False):
block.hashMerkleRoot = block.calc_merkle_root()
block.rehash()
block.solve()
assert_equal(None if accept else 'block-validation-failed', node.submitblock(block.serialize().hex()))
if (accept):
assert_equal(None if accept else NULLDUMMY_ERROR, node.submitblock(block.serialize().hex()))
if accept:
assert_equal(node.getbestblockhash(), block.hash)
self.lastblockhash = block.hash
self.lastblocktime += 1
Expand Down

0 comments on commit 847d866

Please sign in to comment.