Changeset View
Changeset View
Standalone View
Standalone View
test/functional/maxuploadtarget.py
Show All 13 Lines | |||||
''' | ''' | ||||
from collections import defaultdict | from collections import defaultdict | ||||
import time | import time | ||||
from test_framework.mininode import * | from test_framework.mininode import * | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import * | from test_framework.util import * | ||||
from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE | from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE | ||||
from test_framework.blocktools import mine_big_block | |||||
class TestNode(NodeConnCB): | class TestNode(NodeConnCB): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.block_receive_map = defaultdict(int) | self.block_receive_map = defaultdict(int) | ||||
Show All 40 Lines | def run_test(self): | ||||
# Start up network handling in another thread | # Start up network handling in another thread | ||||
NetworkThread().start() | NetworkThread().start() | ||||
[x.wait_for_verack() for x in test_nodes] | [x.wait_for_verack() for x in test_nodes] | ||||
# Test logic begins here | # Test logic begins here | ||||
# Now mine a big block | # Now mine a big block | ||||
mine_large_block(self.nodes[0], self.utxo_cache) | mine_big_block(self.nodes[0], self.utxo_cache) | ||||
# Store the hash; we'll request this later | # Store the hash; we'll request this later | ||||
big_old_block = self.nodes[0].getbestblockhash() | big_old_block = self.nodes[0].getbestblockhash() | ||||
old_block_size = self.nodes[0].getblock(big_old_block, True)['size'] | old_block_size = self.nodes[0].getblock(big_old_block, True)['size'] | ||||
big_old_block = int(big_old_block, 16) | big_old_block = int(big_old_block, 16) | ||||
# Advance to two days ago | # Advance to two days ago | ||||
self.nodes[0].setmocktime(int(time.time()) - 2 * 60 * 60 * 24) | self.nodes[0].setmocktime(int(time.time()) - 2 * 60 * 60 * 24) | ||||
# Mine one more block, so that the prior block looks old | # Mine one more block, so that the prior block looks old | ||||
mine_large_block(self.nodes[0], self.utxo_cache) | mine_big_block(self.nodes[0], self.utxo_cache) | ||||
# We'll be requesting this new block too | # We'll be requesting this new block too | ||||
big_new_block = self.nodes[0].getbestblockhash() | big_new_block = self.nodes[0].getbestblockhash() | ||||
big_new_block = int(big_new_block, 16) | big_new_block = int(big_new_block, 16) | ||||
# test_nodes[0] will test what happens if we just keep requesting the | # test_nodes[0] will test what happens if we just keep requesting the | ||||
# the same big old block too many times (expect: disconnect) | # the same big old block too many times (expect: disconnect) | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |