[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.
This commit is contained in:
1 parent
bd60a9a8ed
commit
784f757994
17 files changed
+73
-73
No files matched your search
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user