Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-compactblocks.py
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | class FullBlockTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.block_heights = {} | self.block_heights = {} | ||||
self.tip = None | self.tip = None | ||||
self.blocks = {} | self.blocks = {} | ||||
self.excessive_block_size = 16 * ONE_MEGABYTE | self.excessive_block_size = 16 * ONE_MEGABYTE | ||||
# -norelaypriority is needed so that the invalidateblock at the end | |||||
# will insert free transactions back into the mempool. | |||||
self.extra_args = [['-norelaypriority', | self.extra_args = [['-norelaypriority', | ||||
'-whitelist=127.0.0.1', | '-whitelist=127.0.0.1', | ||||
'-limitancestorcount=999999', | '-limitancestorcount=999999', | ||||
'-limitancestorsize=999999', | '-limitancestorsize=999999', | ||||
'-limitdescendantcount=999999', | '-limitdescendantcount=999999', | ||||
'-limitdescendantsize=999999', | '-limitdescendantsize=999999', | ||||
'-maxmempool=99999', | '-maxmempool=99999', | ||||
"-excessiveblocksize={}".format(self.excessive_block_size)]] | "-excessiveblocksize={}".format(self.excessive_block_size)]] | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
wait_until(received_block, timeout=30) | wait_until(received_block, timeout=30) | ||||
# Was it our block ? | # Was it our block ? | ||||
cmpctblk_header = test_p2p.last_cmpctblock.header_and_shortids.header | cmpctblk_header = test_p2p.last_cmpctblock.header_and_shortids.header | ||||
cmpctblk_header.calc_sha256() | cmpctblk_header.calc_sha256() | ||||
assert cmpctblk_header.sha256 == b2.sha256 | assert cmpctblk_header.sha256 == b2.sha256 | ||||
# In order to avoid having to resend a ton of transactions, we invalidate | # In order to avoid having to resend a ton of transactions, we invalidate | ||||
# b2, which will send all its transactions in the mempool. | # b2, which will send all its transactions in the mempool. Note that this | ||||
# assumes reorgs will insert low-fee transactions back into the mempool. | |||||
node.invalidateblock(node.getbestblockhash()) | node.invalidateblock(node.getbestblockhash()) | ||||
# Let's send a compact block and see if the node accepts it. | # Let's send a compact block and see if the node accepts it. | ||||
# Let's modify b2 and use it so that we can reuse the mempool. | # Let's modify b2 and use it so that we can reuse the mempool. | ||||
tx = b2.vtx[0] | tx = b2.vtx[0] | ||||
tx.vout.append(CTxOut(0, CScript([random.randint(0, 256), OP_RETURN]))) | tx.vout.append(CTxOut(0, CScript([random.randint(0, 256), OP_RETURN]))) | ||||
tx.rehash() | tx.rehash() | ||||
b2.vtx[0] = tx | b2.vtx[0] = tx | ||||
Show All 14 Lines |