diff --git a/test/functional/abc-mempool-accept-txn.py b/test/functional/abc-mempool-accept-txn.py --- a/test/functional/abc-mempool-accept-txn.py +++ b/test/functional/abc-mempool-accept-txn.py @@ -16,7 +16,6 @@ create_transaction, ) from test_framework.cdefs import MAX_STANDARD_TX_SIGOPS -from test_framework.comptool import TestInstance, TestManager from test_framework.key import CECKey from test_framework.messages import ( COutPoint, @@ -25,7 +24,10 @@ CTxOut, ToHex, ) -from test_framework.mininode import network_thread_start +from test_framework.mininode import ( + network_thread_start, + P2PDataStore, +) from test_framework.script import ( CScript, hash160, @@ -39,7 +41,7 @@ SIGHASH_FORKID, SignatureHashForkId, ) -from test_framework.test_framework import ComparisonTestFramework +from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error # Error for too many sigops in one TX @@ -50,14 +52,11 @@ def __init__(self, tx=CTransaction(), n=-1): self.tx = tx - self.n = n # the output we're spending - + # The output we're spending + self.n = n -class FullBlockTest(ComparisonTestFramework): - # Can either run this test as 1 node with expected answers, or two and compare them. - # Change the "outcome" variable from each TestInstance object to only do - # the comparison. +class FullBlockTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 @@ -79,12 +78,6 @@ parser.add_argument( "--runbarelyexpensive", dest="runbarelyexpensive", default=True) - def run_test(self): - self.test = TestManager(self, self.options.tmpdir) - self.test.add_all_connections(self.nodes) - network_thread_start() - self.test.run() - def add_transactions_to_block(self, block, tx_list): [tx.rehash() for tx in tx_list] block.vtx.extend(tx_list) @@ -148,7 +141,12 @@ self.blocks[number] = block return block - def get_tests(self): + def run_test(self): + node = self.nodes[0] + node.add_p2p_connection(P2PDataStore()) + network_thread_start() + node.p2p.wait_for_verack() + self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 spendable_outputs = [] @@ -161,17 +159,6 @@ def get_spendable_output(): return PreviousSpendableOutput(spendable_outputs.pop(0).vtx[0], 0) - # returns a test case that asserts that the current tip was accepted - def accepted(): - return TestInstance([[self.tip, True]]) - - # returns a test case that asserts that the current tip was rejected - def rejected(reject=None): - if reject is None: - return TestInstance([[self.tip, False]]) - else: - return TestInstance([[self.tip, reject]]) - # move the tip back to a previous block def tip(number): self.tip = self.blocks[number] @@ -195,21 +182,18 @@ # shorthand for functions block = self.next_block - # shorthand for variables - node = self.nodes[0] - # Create a new block block(0) save_spendable_output() - yield accepted() + node.p2p.send_blocks_and_test([self.tip], node) # Now we need that block to mature so we can spend the coinbase. - test = TestInstance(sync_every_block=False) + maturity_blocks = [] for i in range(99): block(5000 + i) - test.blocks_and_transactions.append([self.tip, True]) + maturity_blocks.append(self.tip) save_spendable_output() - yield test + node.p2p.send_blocks_and_test(maturity_blocks, node) # Collect spendable outputs now to avoid cluttering the code later on out = [] @@ -247,7 +231,7 @@ # Add the transaction to the block block(1) update_block(1, [p2sh_tx]) - yield accepted() + node.p2p.send_blocks_and_test([self.tip], node) # Sigops p2sh limit for the mempool test p2sh_sigops_limit_mempool = MAX_STANDARD_TX_SIGOPS - \ @@ -276,7 +260,7 @@ # Mine the transaction block(2, spend=out[1]) update_block(2, [max_p2sh_sigops_txn]) - yield accepted() + node.p2p.send_blocks_and_test([self.tip], node) # The transaction has been mined, it's not in the mempool anymore assert_equal(set(node.getrawmempool()), set())