From fa782a308dbe7bc579c122f63c1c65666fc85e91 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 29 Aug 2018 12:42:46 -0400 Subject: [PATCH] qa: Use named args in some tests --- test/functional/mining_basic.py | 2 +- test/functional/p2p_invalid_block.py | 6 +++--- test/functional/p2p_segwit.py | 8 ++++---- test/functional/test_framework/mininode.py | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index 15b2d7f757..b675cd882f 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -188,7 +188,7 @@ class MiningTest(BitcoinTestFramework): # Should ask for the block from a p2p node, if they announce the header as well: node.add_p2p_connection(P2PDataStore()) node.p2p.wait_for_getheaders(timeout=5) # Drop the first getheaders - node.p2p.send_blocks_and_test(blocks=[block], rpc=node) + node.p2p.send_blocks_and_test(blocks=[block], node=node) # Must be active now: assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips() diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index e910bedd09..8036f65d81 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -42,7 +42,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework): # Save the coinbase for later block1 = block tip = block.sha256 - node.p2p.send_blocks_and_test([block1], node, True) + node.p2p.send_blocks_and_test([block1], node, success=True) self.log.info("Mature the block.") node.generate(100) @@ -79,7 +79,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework): assert_equal(orig_hash, block2.rehash()) assert(block2_orig.vtx != block2.vtx) - node.p2p.send_blocks_and_test([block2], node, False, False, 16, b'bad-txns-duplicate') + node.p2p.send_blocks_and_test([block2], node, success=False, request_block=False, reject_code=16, reject_reason=b'bad-txns-duplicate') self.log.info("Test very broken block.") @@ -92,7 +92,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework): block3.rehash() block3.solve() - node.p2p.send_blocks_and_test([block3], node, False, False, 16, b'bad-cb-amount') + node.p2p.send_blocks_and_test([block3], node, success=False, request_block=False, reject_code=16, reject_reason=b'bad-cb-amount') if __name__ == '__main__': InvalidBlockRequestTest().main() diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 82eacc84f4..45dc2928d3 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -119,7 +119,7 @@ def get_virtual_size(witness_block): vsize = int((3 * base_size + total_size + 3) / 4) return vsize -def test_transaction_acceptance(rpc, p2p, tx, with_witness, accepted, reason=None): +def test_transaction_acceptance(node, p2p, tx, with_witness, accepted, reason=None): """Send a transaction to the node and check that it's accepted to the mempool - Submit the transaction over the p2p interface @@ -129,13 +129,13 @@ def test_transaction_acceptance(rpc, p2p, tx, with_witness, accepted, reason=Non tx_message = msg_witness_tx(tx) p2p.send_message(tx_message) p2p.sync_with_ping() - assert_equal(tx.hash in rpc.getrawmempool(), accepted) + assert_equal(tx.hash in node.getrawmempool(), accepted) if (reason is not None and not accepted): # Check the rejection reason as well. with mininode_lock: assert_equal(p2p.last_message["reject"].reason, reason) -def test_witness_block(rpc, p2p, block, accepted, with_witness=True, reason=None): +def test_witness_block(node, p2p, block, accepted, with_witness=True, reason=None): """Send a block to the node and check that it's accepted - Submit the block over the p2p interface @@ -145,7 +145,7 @@ def test_witness_block(rpc, p2p, block, accepted, with_witness=True, reason=None else: p2p.send_message(msg_block(block)) p2p.sync_with_ping() - assert_equal(rpc.getbestblockhash() == block.hash, accepted) + assert_equal(node.getbestblockhash() == block.hash, accepted) if (reason is not None and not accepted): # Check the rejection reason as well. with mininode_lock: diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index d1ddbbe8ee..034e83aaae 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -482,7 +482,7 @@ class P2PDataStore(P2PInterface): self.reject_code_received = message.code self.reject_reason_received = message.reason - def send_blocks_and_test(self, blocks, rpc, success=True, request_block=True, reject_code=None, reject_reason=None, timeout=60): + def send_blocks_and_test(self, blocks, node, *, success=True, request_block=True, reject_code=None, reject_reason=None, timeout=60): """Send blocks to test node and test whether the tip advances. - add all blocks to our block_store @@ -508,16 +508,16 @@ class P2PDataStore(P2PInterface): wait_until(lambda: blocks[-1].sha256 in self.getdata_requests, timeout=timeout, lock=mininode_lock) if success: - wait_until(lambda: rpc.getbestblockhash() == blocks[-1].hash, timeout=timeout) + wait_until(lambda: node.getbestblockhash() == blocks[-1].hash, timeout=timeout) else: - assert rpc.getbestblockhash() != blocks[-1].hash + assert node.getbestblockhash() != blocks[-1].hash if reject_code is not None: wait_until(lambda: self.reject_code_received == reject_code, lock=mininode_lock) if reject_reason is not None: wait_until(lambda: self.reject_reason_received == reject_reason, lock=mininode_lock) - def send_txs_and_test(self, txs, rpc, success=True, expect_disconnect=False, reject_code=None, reject_reason=None): + def send_txs_and_test(self, txs, node, *, success=True, expect_disconnect=False, reject_code=None, reject_reason=None): """Send txs to test node and test whether they're accepted to the mempool. - add all txs to our tx_store @@ -541,7 +541,7 @@ class P2PDataStore(P2PInterface): else: self.sync_with_ping() - raw_mempool = rpc.getrawmempool() + raw_mempool = node.getrawmempool() if success: # Check that all txs are now in the mempool for tx in txs: