Browse Source

Tests: Edit bloated varint test and add option for 'barely expensive' tests

0.13
mrbandrews 9 years ago
parent
commit
ff2dcf274d
  1. 20
      qa/rpc-tests/p2p-fullblocktest.py

20
qa/rpc-tests/p2p-fullblocktest.py

@ -65,6 +65,10 @@ class FullBlockTest(ComparisonTestFramework):
self.tip = None self.tip = None
self.blocks = {} self.blocks = {}
def add_options(self, parser):
super().add_options(parser)
parser.add_option("--runbarelyexpensive", dest="runbarelyexpensive", default=True)
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)
@ -875,10 +879,13 @@ class FullBlockTest(ComparisonTestFramework):
yield rejected(RejectResult(16, b'bad-txns-nonfinal')) yield rejected(RejectResult(16, b'bad-txns-nonfinal'))
# This checks that a block with a bloated VARINT between the block_header and the array of tx is rejected # This checks that a block with a bloated VARINT between the block_header and the array of tx such that
# (previous behavior was that it was accepted.) It also checks that if you subsequently send that block # the block is > MAX_BLOCK_SIZE with the bloated varint, but <= MAX_BLOCK_SIZE without the bloated varint,
# with correct encoding, it should be accepted (i.e., the receiving node should not reject it on the # does not cause a subsequent, identical block with canonical encoding to be rejected. The test does not
# basis that it's the same as an already-rejected block, which would be a DoS vulnerability.) # care whether the bloated block is accepted or rejected; it only cares that the second block is accepted.
#
# What matters is that the receiving node should not reject the bloated block, and then reject the canonical
# block on the basis that it's the same as an already-rejected block (which would be a consensus failure.)
# #
# -> b39 (11) -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) # -> b39 (11) -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18)
# \ # \
@ -903,7 +910,7 @@ class FullBlockTest(ComparisonTestFramework):
tx.vin.append(CTxIn(COutPoint(b64a.vtx[1].sha256, 0))) tx.vin.append(CTxIn(COutPoint(b64a.vtx[1].sha256, 0)))
b64a = update_block("64a", [tx]) b64a = update_block("64a", [tx])
assert_equal(len(b64a.serialize()), MAX_BLOCK_SIZE + 8) assert_equal(len(b64a.serialize()), MAX_BLOCK_SIZE + 8)
yield rejected() yield TestInstance([[self.tip, None]])
# comptool workaround: to make sure b64 is delivered, manually erase b64a from blockstore # comptool workaround: to make sure b64 is delivered, manually erase b64a from blockstore
self.test.block_store.erase(b64a.sha256) self.test.block_store.erase(b64a.sha256)
@ -941,7 +948,6 @@ class FullBlockTest(ComparisonTestFramework):
update_block(66, [tx2, tx1]) update_block(66, [tx2, tx1])
yield rejected(RejectResult(16, b'bad-txns-inputs-missingorspent')) yield rejected(RejectResult(16, b'bad-txns-inputs-missingorspent'))
# Attempt to double-spend a transaction created in a block # Attempt to double-spend a transaction created in a block
# #
# -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19) # -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) -> b64 (18) -> b65 (19)
@ -1239,6 +1245,7 @@ class FullBlockTest(ComparisonTestFramework):
# Test re-org of a week's worth of blocks (1088 blocks) # Test re-org of a week's worth of blocks (1088 blocks)
# This test takes a minute or two and can be accomplished in memory # This test takes a minute or two and can be accomplished in memory
# #
if self.options.runbarelyexpensive:
tip(88) tip(88)
LARGE_REORG_SIZE = 1088 LARGE_REORG_SIZE = 1088
test1 = TestInstance(sync_every_block=False) test1 = TestInstance(sync_every_block=False)
@ -1281,5 +1288,6 @@ class FullBlockTest(ComparisonTestFramework):
chain1_tip += 2 chain1_tip += 2
if __name__ == '__main__': if __name__ == '__main__':
FullBlockTest().main() FullBlockTest().main()

Loading…
Cancel
Save