Skip to content

Commit e662d28

Browse files
author
MarcoFalke
committed
Merge #9206: Make test constant consistent with consensus.h
09dc406 Make test constant consistent with consensus.h (BtcDrak)
2 parents fa1f944 + 09dc406 commit e662d28

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

qa/rpc-tests/p2p-fullblocktest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,32 +351,32 @@ def update_block(block_number, new_transactions):
351351
block(22, spend=out[5])
352352
yield rejected()
353353

354-
# Create a block on either side of MAX_BLOCK_SIZE and make sure its accepted/rejected
354+
# Create a block on either side of MAX_BLOCK_BASE_SIZE and make sure its accepted/rejected
355355
# genesis -> b1 (0) -> b2 (1) -> b5 (2) -> b6 (3)
356356
# \-> b12 (3) -> b13 (4) -> b15 (5) -> b23 (6)
357357
# \-> b24 (6) -> b25 (7)
358358
# \-> b3 (1) -> b4 (2)
359359
tip(15)
360360
b23 = block(23, spend=out[6])
361361
tx = CTransaction()
362-
script_length = MAX_BLOCK_SIZE - len(b23.serialize()) - 69
362+
script_length = MAX_BLOCK_BASE_SIZE - len(b23.serialize()) - 69
363363
script_output = CScript([b'\x00' * script_length])
364364
tx.vout.append(CTxOut(0, script_output))
365365
tx.vin.append(CTxIn(COutPoint(b23.vtx[1].sha256, 0)))
366366
b23 = update_block(23, [tx])
367367
# Make sure the math above worked out to produce a max-sized block
368-
assert_equal(len(b23.serialize()), MAX_BLOCK_SIZE)
368+
assert_equal(len(b23.serialize()), MAX_BLOCK_BASE_SIZE)
369369
yield accepted()
370370
save_spendable_output()
371371

372372
# Make the next block one byte bigger and check that it fails
373373
tip(15)
374374
b24 = block(24, spend=out[6])
375-
script_length = MAX_BLOCK_SIZE - len(b24.serialize()) - 69
375+
script_length = MAX_BLOCK_BASE_SIZE - len(b24.serialize()) - 69
376376
script_output = CScript([b'\x00' * (script_length+1)])
377377
tx.vout = [CTxOut(0, script_output)]
378378
b24 = update_block(24, [tx])
379-
assert_equal(len(b24.serialize()), MAX_BLOCK_SIZE+1)
379+
assert_equal(len(b24.serialize()), MAX_BLOCK_BASE_SIZE+1)
380380
yield rejected(RejectResult(16, b'bad-blk-length'))
381381

382382
block(25, spend=out[7])
@@ -523,12 +523,12 @@ def update_block(block_number, new_transactions):
523523
tx_new = None
524524
tx_last = tx
525525
total_size=len(b39.serialize())
526-
while(total_size < MAX_BLOCK_SIZE):
526+
while(total_size < MAX_BLOCK_BASE_SIZE):
527527
tx_new = create_tx(tx_last, 1, 1, p2sh_script)
528528
tx_new.vout.append(CTxOut(tx_last.vout[1].nValue - 1, CScript([OP_TRUE])))
529529
tx_new.rehash()
530530
total_size += len(tx_new.serialize())
531-
if total_size >= MAX_BLOCK_SIZE:
531+
if total_size >= MAX_BLOCK_BASE_SIZE:
532532
break
533533
b39.vtx.append(tx_new) # add tx to block
534534
tx_last = tx_new
@@ -877,7 +877,7 @@ def update_block(block_number, new_transactions):
877877

878878

879879
# This checks that a block with a bloated VARINT between the block_header and the array of tx such that
880-
# the block is > MAX_BLOCK_SIZE with the bloated varint, but <= MAX_BLOCK_SIZE without the bloated varint,
880+
# the block is > MAX_BLOCK_BASE_SIZE with the bloated varint, but <= MAX_BLOCK_BASE_SIZE without the bloated varint,
881881
# does not cause a subsequent, identical block with canonical encoding to be rejected. The test does not
882882
# care whether the bloated block is accepted or rejected; it only cares that the second block is accepted.
883883
#
@@ -901,12 +901,12 @@ def update_block(block_number, new_transactions):
901901
tx = CTransaction()
902902

903903
# use canonical serialization to calculate size
904-
script_length = MAX_BLOCK_SIZE - len(b64a.normal_serialize()) - 69
904+
script_length = MAX_BLOCK_BASE_SIZE - len(b64a.normal_serialize()) - 69
905905
script_output = CScript([b'\x00' * script_length])
906906
tx.vout.append(CTxOut(0, script_output))
907907
tx.vin.append(CTxIn(COutPoint(b64a.vtx[1].sha256, 0)))
908908
b64a = update_block("64a", [tx])
909-
assert_equal(len(b64a.serialize()), MAX_BLOCK_SIZE + 8)
909+
assert_equal(len(b64a.serialize()), MAX_BLOCK_BASE_SIZE + 8)
910910
yield TestInstance([[self.tip, None]])
911911

912912
# comptool workaround: to make sure b64 is delivered, manually erase b64a from blockstore
@@ -916,7 +916,7 @@ def update_block(block_number, new_transactions):
916916
b64 = CBlock(b64a)
917917
b64.vtx = copy.deepcopy(b64a.vtx)
918918
assert_equal(b64.hash, b64a.hash)
919-
assert_equal(len(b64.serialize()), MAX_BLOCK_SIZE)
919+
assert_equal(len(b64.serialize()), MAX_BLOCK_BASE_SIZE)
920920
self.blocks[64] = b64
921921
update_block(64, [])
922922
yield accepted()
@@ -1250,12 +1250,12 @@ def update_block(block_number, new_transactions):
12501250
for i in range(89, LARGE_REORG_SIZE + 89):
12511251
b = block(i, spend)
12521252
tx = CTransaction()
1253-
script_length = MAX_BLOCK_SIZE - len(b.serialize()) - 69
1253+
script_length = MAX_BLOCK_BASE_SIZE - len(b.serialize()) - 69
12541254
script_output = CScript([b'\x00' * script_length])
12551255
tx.vout.append(CTxOut(0, script_output))
12561256
tx.vin.append(CTxIn(COutPoint(b.vtx[1].sha256, 0)))
12571257
b = update_block(i, [tx])
1258-
assert_equal(len(b.serialize()), MAX_BLOCK_SIZE)
1258+
assert_equal(len(b.serialize()), MAX_BLOCK_BASE_SIZE)
12591259
test1.blocks_and_transactions.append([self.tip, True])
12601260
save_spendable_output()
12611261
spend = get_spendable_output()

qa/rpc-tests/p2p-segwit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def test_block_malleability(self):
498498
block.solve()
499499

500500
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.append(b'a'*5000000)
501-
assert(get_virtual_size(block) > MAX_BLOCK_SIZE)
501+
assert(get_virtual_size(block) > MAX_BLOCK_BASE_SIZE)
502502

503503
# We can't send over the p2p network, because this is too big to relay
504504
# TODO: repeat this test with a block that can be relayed
@@ -507,7 +507,7 @@ def test_block_malleability(self):
507507
assert(self.nodes[0].getbestblockhash() != block.hash)
508508

509509
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.pop()
510-
assert(get_virtual_size(block) < MAX_BLOCK_SIZE)
510+
assert(get_virtual_size(block) < MAX_BLOCK_BASE_SIZE)
511511
self.nodes[0].submitblock(bytes_to_hex_str(block.serialize(True)))
512512

513513
assert(self.nodes[0].getbestblockhash() == block.hash)
@@ -572,10 +572,10 @@ def test_witness_block_size(self):
572572
self.update_witness_block_with_transactions(block, [parent_tx, child_tx])
573573

574574
vsize = get_virtual_size(block)
575-
additional_bytes = (MAX_BLOCK_SIZE - vsize)*4
575+
additional_bytes = (MAX_BLOCK_BASE_SIZE - vsize)*4
576576
i = 0
577577
while additional_bytes > 0:
578-
# Add some more bytes to each input until we hit MAX_BLOCK_SIZE+1
578+
# Add some more bytes to each input until we hit MAX_BLOCK_BASE_SIZE+1
579579
extra_bytes = min(additional_bytes+1, 55)
580580
block.vtx[-1].wit.vtxinwit[int(i/(2*NUM_DROPS))].scriptWitness.stack[i%(2*NUM_DROPS)] = b'a'*(195+extra_bytes)
581581
additional_bytes -= extra_bytes
@@ -585,7 +585,7 @@ def test_witness_block_size(self):
585585
add_witness_commitment(block)
586586
block.solve()
587587
vsize = get_virtual_size(block)
588-
assert_equal(vsize, MAX_BLOCK_SIZE + 1)
588+
assert_equal(vsize, MAX_BLOCK_BASE_SIZE + 1)
589589
# Make sure that our test case would exceed the old max-network-message
590590
# limit
591591
assert(len(block.serialize(True)) > 2*1024*1024)
@@ -598,7 +598,7 @@ def test_witness_block_size(self):
598598
block.vtx[0].vout.pop()
599599
add_witness_commitment(block)
600600
block.solve()
601-
assert(get_virtual_size(block) == MAX_BLOCK_SIZE)
601+
assert(get_virtual_size(block) == MAX_BLOCK_BASE_SIZE)
602602

603603
self.test_node.test_witness_block(block, accepted=True)
604604

@@ -1433,7 +1433,7 @@ def test_signature_version_1(self):
14331433
block.vtx.append(tx)
14341434

14351435
# Test the block periodically, if we're close to maxblocksize
1436-
if (get_virtual_size(block) > MAX_BLOCK_SIZE - 1000):
1436+
if (get_virtual_size(block) > MAX_BLOCK_BASE_SIZE - 1000):
14371437
self.update_witness_block_with_transactions(block, [])
14381438
self.test_node.test_witness_block(block, accepted=True)
14391439
block = self.build_next_block()

qa/rpc-tests/prioritise_transaction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import *
12-
from test_framework.mininode import COIN, MAX_BLOCK_SIZE
12+
from test_framework.mininode import COIN, MAX_BLOCK_BASE_SIZE
1313

1414
class PrioritiseTransactionTest(BitcoinTestFramework):
1515

@@ -42,15 +42,15 @@ def run_test(self):
4242
txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[start_range:end_range], (i+1)*base_fee)
4343

4444
# Make sure that the size of each group of transactions exceeds
45-
# MAX_BLOCK_SIZE -- otherwise the test needs to be revised to create
45+
# MAX_BLOCK_BASE_SIZE -- otherwise the test needs to be revised to create
4646
# more transactions.
4747
mempool = self.nodes[0].getrawmempool(True)
4848
sizes = [0, 0, 0]
4949
for i in range(3):
5050
for j in txids[i]:
5151
assert(j in mempool)
5252
sizes[i] += mempool[j]['size']
53-
assert(sizes[i] > MAX_BLOCK_SIZE) # Fail => raise utxo_count
53+
assert(sizes[i] > MAX_BLOCK_BASE_SIZE) # Fail => raise utxo_count
5454

5555
# add a fee delta to something in the cheapest bucket and make sure it gets mined
5656
# also check that a different entry in the cheapest bucket is NOT mined (lower

qa/rpc-tests/test_framework/mininode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
4545

4646
MAX_INV_SZ = 50000
47-
MAX_BLOCK_SIZE = 1000000
47+
MAX_BLOCK_BASE_SIZE = 1000000
4848

4949
COIN = 100000000 # 1 btc in satoshis
5050

0 commit comments

Comments
 (0)