aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_blocksonly.py
diff options
context:
space:
mode:
authorgzhao408 <gzhao408@berkeley.edu>2020-09-03 18:05:26 -0700
committergzhao408 <gzhao408@berkeley.edu>2020-09-10 07:37:14 -0700
commit784f757994c1306bb6584b14c0c78617d6248432 (patch)
treea884db60889e652e08236f668585d24aca65a3a6 /test/functional/p2p_blocksonly.py
parentbd60a9a8edd4a3fe2f4f605b77cdae34969eaaf2 (diff)
downloadbitcoin-784f757994c1306bb6584b14c0c78617d6248432.tar.xz
[refactor] clarify tests by referencing p2p objects directly
Use object returned from add_p2p_connection to refer to p2ps. Add a test class attribute if it needs to be used across many methods. Don't use the p2p property.
Diffstat (limited to 'test/functional/p2p_blocksonly.py')
-rwxr-xr-xtest/functional/p2p_blocksonly.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py
index 65259f1869..2bc44f81f6 100755
--- a/test/functional/p2p_blocksonly.py
+++ b/test/functional/p2p_blocksonly.py
@@ -17,7 +17,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
self.extra_args = [["-blocksonly"]]
def run_test(self):
- self.nodes[0].add_p2p_connection(P2PInterface())
+ block_relay_peer = self.nodes[0].add_p2p_connection(P2PInterface())
self.log.info('Check that txs from p2p are rejected and result in disconnect')
prevtx = self.nodes[0].getblock(self.nodes[0].getblockhash(1), 2)['tx'][0]
@@ -41,20 +41,20 @@ class P2PBlocksOnly(BitcoinTestFramework):
)['hex']
assert_equal(self.nodes[0].getnetworkinfo()['localrelay'], False)
with self.nodes[0].assert_debug_log(['transaction sent in violation of protocol peer=0']):
- self.nodes[0].p2p.send_message(msg_tx(FromHex(CTransaction(), sigtx)))
- self.nodes[0].p2p.wait_for_disconnect()
+ block_relay_peer.send_message(msg_tx(FromHex(CTransaction(), sigtx)))
+ block_relay_peer.wait_for_disconnect()
assert_equal(self.nodes[0].getmempoolinfo()['size'], 0)
# Remove the disconnected peer and add a new one.
del self.nodes[0].p2ps[0]
- self.nodes[0].add_p2p_connection(P2PInterface())
+ tx_relay_peer = self.nodes[0].add_p2p_connection(P2PInterface())
self.log.info('Check that txs from rpc are not rejected and relayed to other peers')
assert_equal(self.nodes[0].getpeerinfo()[0]['relaytxes'], True)
txid = self.nodes[0].testmempoolaccept([sigtx])[0]['txid']
with self.nodes[0].assert_debug_log(['received getdata for: wtx {} peer=1'.format(txid)]):
self.nodes[0].sendrawtransaction(sigtx)
- self.nodes[0].p2p.wait_for_tx(txid)
+ tx_relay_peer.wait_for_tx(txid)
assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
self.log.info('Check that txs from forcerelay peers are not rejected and relayed to others')