-
Notifications
You must be signed in to change notification settings - Fork 2
/
abc-cmdline.py
executable file
·71 lines (56 loc) · 2.69 KB
/
abc-cmdline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
# Copyright (c) 2017 The Bitcoin developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Exercise the command line functions specific to ABC functionality.
Currently:
-excessiveblocksize=<blocksize_in_bytes>
"""
import re
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE, DEFAULT_MAX_BLOCK_SIZE
MAX_GENERATED_BLOCK_SIZE_ERROR = (
'Max generated block size (blockmaxsize) cannot exceed the excessive block size (excessiveblocksize)')
class ABC_CmdLine_Test (BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = False
def check_excessive(self, expected_value):
'Check that the excessiveBlockSize is as expected'
getsize = self.nodes[0].getexcessiveblock()
ebs = getsize['excessiveBlockSize']
assert_equal(ebs, expected_value)
def check_subversion(self, pattern_str):
'Check that the subversion is set as expected'
netinfo = self.nodes[0].getnetworkinfo()
subversion = netinfo['subversion']
pattern = re.compile(pattern_str)
assert(pattern.match(subversion))
def excessiveblocksize_test(self):
self.log.info("Testing -excessiveblocksize")
self.log.info(" Set to twice the default, i.e. %d bytes" %
(2 * LEGACY_MAX_BLOCK_SIZE))
self.stop_node(0)
self.start_node(0, ["--excessiveblocksize=%d" %
(2 * LEGACY_MAX_BLOCK_SIZE)])
self.check_excessive(2 * LEGACY_MAX_BLOCK_SIZE)
# Check for EB correctness in the subver string
self.check_subversion("/Copernicus:[\d\.]+\(.*\)/")
self.log.info(" Attempt to set below legacy limit of 1MB - try %d bytes" %
LEGACY_MAX_BLOCK_SIZE)
self.stop_node(0)
self.assert_start_raises_init_error(
0, ["--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.assert_start_raises_init_error(
0, ['--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
# framework expects.
self.start_node(0, [])
def run_test(self):
# Run tests on -excessiveblocksize option
self.excessiveblocksize_test()
if __name__ == '__main__':
ABC_CmdLine_Test().main()