Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_feefilter.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2016 The Bitcoin Core developers | # Copyright (c) 2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test processing of feefilter messages.""" | """Test processing of feefilter messages.""" | ||||
from decimal import Decimal | from decimal import Decimal | ||||
import time | import time | ||||
from test_framework.messages import msg_feefilter | from test_framework.messages import msg_feefilter | ||||
from test_framework.mininode import ( | from test_framework.mininode import ( | ||||
mininode_lock, | mininode_lock, | ||||
network_thread_start, | |||||
P2PInterface, | P2PInterface, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import sync_blocks, sync_mempools | from test_framework.util import sync_blocks, sync_mempools | ||||
def hashToHex(hash): | def hashToHex(hash): | ||||
return format(hash, '064x') | return format(hash, '064x') | ||||
Show All 31 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 | ||||
self.nodes[0].add_p2p_connection(TestP2PConn()) | self.nodes[0].add_p2p_connection(TestP2PConn()) | ||||
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)) | ||||
self.nodes[0].p2p.clear_invs() | self.nodes[0].p2p.clear_invs() | ||||
Show All 38 Lines |