Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-cmdline.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2017 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
""" | """ | ||||
Exercise the command line functions specific to ABC functionality. | Exercise the command line functions specific to ABC functionality. | ||||
Currently: | Currently: | ||||
-excessiveblocksize=<blocksize_in_bytes> | -excessiveblocksize=<blocksize_in_bytes> | ||||
""" | """ | ||||
import re | import re | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import assert_equal | ||||
assert_equal, | |||||
assert_start_raises_init_error | |||||
) | |||||
from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE, DEFAULT_MAX_BLOCK_SIZE | from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE, DEFAULT_MAX_BLOCK_SIZE | ||||
MAX_GENERATED_BLOCK_SIZE_ERROR = ( | MAX_GENERATED_BLOCK_SIZE_ERROR = ( | ||||
'Max generated block size (blockmaxsize) cannot exceed the excessive block size (excessiveblocksize)') | 'Max generated block size (blockmaxsize) cannot exceed the excessive block size (excessiveblocksize)') | ||||
class ABC_CmdLine_Test (BitcoinTestFramework): | class ABC_CmdLine_Test (BitcoinTestFramework): | ||||
Show All 25 Lines | def excessiveblocksize_test(self): | ||||
"-excessiveblocksize=%d" % (2 * LEGACY_MAX_BLOCK_SIZE)]) | "-excessiveblocksize=%d" % (2 * LEGACY_MAX_BLOCK_SIZE)]) | ||||
self.check_excessive(2 * LEGACY_MAX_BLOCK_SIZE) | self.check_excessive(2 * LEGACY_MAX_BLOCK_SIZE) | ||||
# Check for EB correctness in the subver string | # Check for EB correctness in the subver string | ||||
self.check_subversion("/Bitcoin ABC:.*\(EB2\.0; .*\)/") | self.check_subversion("/Bitcoin ABC:.*\(EB2\.0; .*\)/") | ||||
self.log.info(" Attempt to set below legacy limit of 1MB - try %d bytes" % | self.log.info(" Attempt to set below legacy limit of 1MB - try %d bytes" % | ||||
LEGACY_MAX_BLOCK_SIZE) | LEGACY_MAX_BLOCK_SIZE) | ||||
self.stop_node(0) | self.stop_node(0) | ||||
assert_start_raises_init_error(0, self.options.tmpdir, [ | self.assert_start_raises_init_error(0, self.options.tmpdir, [ | ||||
"-excessiveblocksize=%d" % LEGACY_MAX_BLOCK_SIZE], 'Error: Excessive block size must be > 1,000,000 bytes (1MB)') | "-excessiveblocksize=%d" % LEGACY_MAX_BLOCK_SIZE], 'Error: Excessive block size must be > 1,000,000 bytes (1MB)') | ||||
self.log.info(" Attempt to set below blockmaxsize (mining limit)") | self.log.info(" Attempt to set below blockmaxsize (mining limit)") | ||||
assert_start_raises_init_error(0, self.options.tmpdir, [ | self.assert_start_raises_init_error(0, self.options.tmpdir, [ | ||||
'-blockmaxsize=1500000', '-excessiveblocksize=1300000'], 'Error: ' + MAX_GENERATED_BLOCK_SIZE_ERROR) | '-blockmaxsize=1500000', '-excessiveblocksize=1300000'], 'Error: ' + MAX_GENERATED_BLOCK_SIZE_ERROR) | ||||
# Make sure we leave the test with a node running as this is what thee | # Make sure we leave the test with a node running as this is what thee | ||||
# framework expects. | # framework expects. | ||||
self.nodes[0] = self.start_node(0, self.options.tmpdir, []) | self.nodes[0] = self.start_node(0, self.options.tmpdir, []) | ||||
def run_test(self): | def run_test(self): | ||||
# Run tests on -excessiveblocksize option | # Run tests on -excessiveblocksize option | ||||
self.excessiveblocksize_test() | self.excessiveblocksize_test() | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ABC_CmdLine_Test().main() | ABC_CmdLine_Test().main() |