Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_feefilter.py
Show All 26 Lines | def allInvsMatch(invsExpected, testnode): | ||||
for x in range(60): | for x in range(60): | ||||
with mininode_lock: | with mininode_lock: | ||||
if (sorted(invsExpected) == sorted(testnode.txinvs)): | if (sorted(invsExpected) == sorted(testnode.txinvs)): | ||||
return True | return True | ||||
time.sleep(1) | time.sleep(1) | ||||
return False | return False | ||||
class TestNode(P2PInterface): | class TestP2PConn(P2PInterface): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.txinvs = [] | self.txinvs = [] | ||||
def on_inv(self, message): | def on_inv(self, message): | ||||
for i in message.inv: | for i in message.inv: | ||||
if (i.type == 1): | if (i.type == 1): | ||||
self.txinvs.append(hashToHex(i.hash)) | self.txinvs.append(hashToHex(i.hash)) | ||||
Show All 10 Lines | class FeeFilterTest(BitcoinTestFramework): | ||||
def run_test(self): | def run_test(self): | ||||
node1 = self.nodes[1] | node1 = self.nodes[1] | ||||
node0 = self.nodes[0] | node0 = self.nodes[0] | ||||
# Get out of IBD | # Get out of IBD | ||||
node1.generate(1) | node1.generate(1) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# Setup the p2p connections and start up the network thread. | # Setup the p2p connections and start up the network thread. | ||||
self.nodes[0].add_p2p_connection(TestNode()) | self.nodes[0].add_p2p_connection(TestP2PConn()) | ||||
network_thread_start() | network_thread_start() | ||||
self.nodes[0].p2p.wait_for_verack() | self.nodes[0].p2p.wait_for_verack() | ||||
# Test that invs are received for all txs at feerate of 20 sat/byte | # Test that invs are received for all txs at feerate of 20 sat/byte | ||||
node1.settxfee(Decimal("0.00020000")) | node1.settxfee(Decimal("0.00020000")) | ||||
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) | txids = [node1.sendtoaddress(node1.getnewaddress(), 1) | ||||
for x in range(3)] | for x in range(3)] | ||||
assert(allInvsMatch(txids, self.nodes[0].p2p)) | assert(allInvsMatch(txids, self.nodes[0].p2p)) | ||||
Show All 39 Lines |