Changeset View
Changeset View
Standalone View
Standalone View
qa/rpc-tests/abc-p2p-fullblocktest-simple.py
| Show All 26 Lines | |||||
| class FullBlockTest(ComparisonTestFramework): | class FullBlockTest(ComparisonTestFramework): | ||||
| # Can either run this test as 1 node with expected answers, or two and compare them. | # Can either run this test as 1 node with expected answers, or two and compare them. | ||||
| # Change the "outcome" variable from each TestInstance object to only do the comparison. | # Change the "outcome" variable from each TestInstance object to only do the comparison. | ||||
| def __init__(self): | def __init__(self): | ||||
| super().__init__() | super().__init__() | ||||
| self.excessive_block_size = 2 * LEGACY_MAX_BLOCK_SIZE | self.excessive_block_size = 16 * ONE_MEGABYTE | ||||
| self.num_nodes = 1 | self.num_nodes = 1 | ||||
| self.block_heights = {} | self.block_heights = {} | ||||
| self.coinbase_key = CECKey() | self.coinbase_key = CECKey() | ||||
| self.coinbase_key.set_secretbytes(b"fatstacks") | self.coinbase_key.set_secretbytes(b"fatstacks") | ||||
| self.coinbase_pubkey = self.coinbase_key.get_pubkey() | self.coinbase_pubkey = self.coinbase_key.get_pubkey() | ||||
| self.tip = None | self.tip = None | ||||
| self.blocks = {} | self.blocks = {} | ||||
| ▲ Show 20 Lines • Show All 175 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): | |||||
| # 1MB block | n = i + 1 | ||||
| block(1, spend=out[0], block_size=LEGACY_MAX_BLOCK_SIZE) | block(n, spend=out[i], block_size=n*ONE_MEGABYTE) | ||||
| yield accepted() | yield accepted() | ||||
| # 2MB block | # block of maximal size | ||||
| assert(2 * LEGACY_MAX_BLOCK_SIZE <= self.excessive_block_size) | block(17, spend=out[16], block_size=self.excessive_block_size) | ||||
| block(2, spend=out[1], block_size=(2 * LEGACY_MAX_BLOCK_SIZE)) | |||||
| yield accepted() | yield accepted() | ||||
| # Reject oversized blocks with bad-blk-length error | # Reject oversized blocks with bad-blk-length error | ||||
| block(3, spend=out[2], 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')) | ||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| FullBlockTest().main() | FullBlockTest().main() | ||||