Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_fingerprint.py
Show All 12 Lines | |||||
from test_framework.blocktools import (create_block, create_coinbase) | from test_framework.blocktools import (create_block, create_coinbase) | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
CInv, | CInv, | ||||
msg_block, | msg_block, | ||||
msg_getdata, | msg_getdata, | ||||
msg_getheaders, | msg_getheaders, | ||||
msg_headers, | msg_headers, | ||||
) | ) | ||||
from test_framework.mininode import P2PInterface, network_thread_start | from test_framework.mininode import P2PInterface | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, wait_until | from test_framework.util import assert_equal, wait_until | ||||
class P2PFingerprintTest(BitcoinTestFramework): | class P2PFingerprintTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
Show All 39 Lines | def last_header_equals(self, expected_hash, node): | ||||
headers_msg.headers[0].rehash() == expected_hash) | headers_msg.headers[0].rehash() == expected_hash) | ||||
# Checks that stale blocks timestamped more than a month ago are not served | # Checks that stale blocks timestamped more than a month ago are not served | ||||
# by the node while recent stale blocks and old active chain blocks are. | # by the node while recent stale blocks and old active chain blocks are. | ||||
# This does not currently test that stale blocks timestamped within the | # This does not currently test that stale blocks timestamped within the | ||||
# last month but that have over a month's worth of work are also withheld. | # last month but that have over a month's worth of work are also withheld. | ||||
def run_test(self): | def run_test(self): | ||||
node0 = self.nodes[0].add_p2p_connection(P2PInterface()) | node0 = self.nodes[0].add_p2p_connection(P2PInterface()) | ||||
network_thread_start() | |||||
node0.wait_for_verack() | node0.wait_for_verack() | ||||
# Set node time to 60 days ago | # Set node time to 60 days ago | ||||
self.nodes[0].setmocktime(int(time.time()) - 60 * 24 * 60 * 60) | self.nodes[0].setmocktime(int(time.time()) - 60 * 24 * 60 * 60) | ||||
# Generating a chain of 10 blocks | # Generating a chain of 10 blocks | ||||
block_hashes = self.nodes[0].generate(nblocks=10) | block_hashes = self.nodes[0].generate(nblocks=10) | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |