Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-fullblocktest.py
Show All 16 Lines | |||||
from test_framework.blocktools import * | from test_framework.blocktools import * | ||||
import time | import time | ||||
from test_framework.key import CECKey | from test_framework.key import CECKey | ||||
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 All 21 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 166 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
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()) | ||||
# Let's build some blocks and test them. | # Let's build some blocks and test them. | ||||
for i in range(16): | for i in range(15): | ||||
n = i + 1 | n = i + 1 | ||||
block(n, spend=out[i], block_size=n * ONE_MEGABYTE) | block(n, spend=out[i], block_size=n * ONE_MEGABYTE // 2) | ||||
yield accepted() | |||||
# Fork block | |||||
bfork = block(5555, out[15], block_size=8 * ONE_MEGABYTE) | |||||
bfork.nTime = MONOLITH_START_TIME | |||||
update_block(5555, []) | |||||
yield accepted() | |||||
# Get to one block of the May 15, 2018 HF activation | |||||
for i in range(4): | |||||
block(5100 + i) | |||||
test.blocks_and_transactions.append([self.tip, True]) | |||||
yield test | |||||
# Before we acivate the May 15, 2018 HF, 8MB is the limit. | |||||
block(4444, spend=out[16], block_size=8 * ONE_MEGABYTE + 1) | |||||
yield rejected(RejectResult(16, b'bad-blk-length')) | |||||
# Rewind bad block. | |||||
tip(5103) | |||||
# Actiavte the May 15, 2018 HF | |||||
block(5104) | |||||
yield accepted() | yield accepted() | ||||
# block of maximal size | # block of maximal size | ||||
block(17, spend=out[16], block_size=self.excessive_block_size) | block(17, spend=out[16], block_size=self.excessive_block_size) | ||||
yield accepted() | yield accepted() | ||||
# Reject oversized blocks with bad-blk-length error | # Reject oversized blocks with bad-blk-length error | ||||
block(18, spend=out[17], block_size=self.excessive_block_size + 1) | block(18, spend=out[17], block_size=self.excessive_block_size + 1) | ||||
yield rejected(RejectResult(16, b'bad-blk-length')) | yield rejected(RejectResult(16, b'bad-blk-length')) | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |