test: Replace self.nodes[0].p2p with conn

This commit is contained in:
MarcoFalke
2020-06-07 09:14:33 -04:00
parent faccdc8a31
commit ffff3fe50a

View File

@ -58,23 +58,23 @@ class FeeFilterTest(BitcoinTestFramework):
node1 = self.nodes[1]
node0 = self.nodes[0]
self.nodes[0].add_p2p_connection(TestP2PConn())
conn = self.nodes[0].add_p2p_connection(TestP2PConn())
# Test that invs are received by test connection for all txs at
# feerate of .2 sat/byte
node1.settxfee(Decimal("0.00000200"))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
assert allInvsMatch(txids, self.nodes[0].p2p)
self.nodes[0].p2p.clear_invs()
assert allInvsMatch(txids, conn)
conn.clear_invs()
# Set a filter of .15 sat/byte on test connection
self.nodes[0].p2p.send_and_ping(msg_feefilter(150))
conn.send_and_ping(msg_feefilter(150))
# Test that txs are still being received by test connection (paying .15 sat/byte)
node1.settxfee(Decimal("0.00000150"))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
assert allInvsMatch(txids, self.nodes[0].p2p)
self.nodes[0].p2p.clear_invs()
assert allInvsMatch(txids, conn)
conn.clear_invs()
# Change tx fee rate to .1 sat/byte and test they are no longer received
# by the test connection
@ -91,14 +91,14 @@ class FeeFilterTest(BitcoinTestFramework):
# as well.
node0.settxfee(Decimal("0.00020000"))
txids = [node0.sendtoaddress(node0.getnewaddress(), 1)]
assert allInvsMatch(txids, self.nodes[0].p2p)
self.nodes[0].p2p.clear_invs()
assert allInvsMatch(txids, conn)
conn.clear_invs()
# Remove fee filter and check that txs are received again
self.nodes[0].p2p.send_and_ping(msg_feefilter(0))
conn.send_and_ping(msg_feefilter(0))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
assert allInvsMatch(txids, self.nodes[0].p2p)
self.nodes[0].p2p.clear_invs()
assert allInvsMatch(txids, conn)
conn.clear_invs()
if __name__ == '__main__':