Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-compactblocks.py
Show All 15 Lines | |||||
from test_framework.comptool import TestManager, TestInstance, RejectResult | from test_framework.comptool import TestManager, TestInstance, RejectResult | ||||
from test_framework.blocktools import * | from test_framework.blocktools import * | ||||
import time | import time | ||||
from test_framework.script import * | from test_framework.script import * | ||||
from test_framework.cdefs import (ONE_MEGABYTE, LEGACY_MAX_BLOCK_SIZE, | from test_framework.cdefs import (ONE_MEGABYTE, LEGACY_MAX_BLOCK_SIZE, | ||||
MAX_BLOCK_SIGOPS_PER_MB, MAX_TX_SIGOPS_COUNT) | MAX_BLOCK_SIGOPS_PER_MB, MAX_TX_SIGOPS_COUNT) | ||||
from collections import deque | from collections import deque | ||||
# far into the future | |||||
MONOLITH_START_TIME = 2000000000 | |||||
class PreviousSpendableOutput(): | class PreviousSpendableOutput(): | ||||
def __init__(self, tx=CTransaction(), n=-1): | def __init__(self, tx=CTransaction(), n=-1): | ||||
self.tx = tx | self.tx = tx | ||||
self.n = n # the output we're spending | self.n = n # the output we're spending | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | class FullBlockTest(ComparisonTestFramework): | ||||
def run_test(self): | def run_test(self): | ||||
self.test = TestManager(self, self.options.tmpdir) | self.test = TestManager(self, self.options.tmpdir) | ||||
self.test.add_all_connections(self.nodes) | self.test.add_all_connections(self.nodes) | ||||
# Start up network handling in another thread | # Start up network handling in another thread | ||||
NetworkThread().start() | NetworkThread().start() | ||||
# Set the blocksize to 2MB as initial condition | # Set the blocksize to 2MB as initial condition | ||||
self.nodes[0].setexcessiveblock(self.excessive_block_size) | self.nodes[0].setexcessiveblock(self.excessive_block_size) | ||||
self.nodes[0].setmocktime(MONOLITH_START_TIME) | |||||
self.test.run() | self.test.run() | ||||
def add_transactions_to_block(self, block, tx_list): | def add_transactions_to_block(self, block, tx_list): | ||||
[tx.rehash() for tx in tx_list] | [tx.rehash() for tx in tx_list] | ||||
block.vtx.extend(tx_list) | block.vtx.extend(tx_list) | ||||
# this is a little handier to use than the version in blocktools.py | # this is a little handier to use than the version in blocktools.py | ||||
def create_tx(self, spend_tx, n, value, script=CScript([OP_TRUE])): | def create_tx(self, spend_tx, n, value, script=CScript([OP_TRUE])): | ||||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
yield accepted() | yield accepted() | ||||
# Now we need that block to mature so we can spend the coinbase. | # Now we need that block to mature so we can spend the coinbase. | ||||
test = TestInstance(sync_every_block=False) | test = TestInstance(sync_every_block=False) | ||||
for i in range(99): | for i in range(99): | ||||
block(5000 + i) | block(5000 + i) | ||||
test.blocks_and_transactions.append([self.tip, True]) | test.blocks_and_transactions.append([self.tip, True]) | ||||
save_spendable_output() | save_spendable_output() | ||||
# Fork block | |||||
bfork = block(5555) | |||||
bfork.nTime = MONOLITH_START_TIME | |||||
update_block(5555, []) | |||||
test.blocks_and_transactions.append([self.tip, True]) | |||||
# Get to one block of the May 15, 2018 HF activation | |||||
for i in range(5): | |||||
block(5100 + i) | |||||
test.blocks_and_transactions.append([self.tip, True]) | |||||
# Send it all to the node at once. | |||||
yield test | yield test | ||||
# collect spendable outputs now to avoid cluttering the code later on | # collect spendable outputs now to avoid cluttering the code later on | ||||
out = [] | out = [] | ||||
for i in range(100): | for i in range(100): | ||||
out.append(get_spendable_output()) | out.append(get_spendable_output()) | ||||
# Check that compact block also work for big blocks | # Check that compact block also work for big blocks | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |