aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-05-23 19:07:29 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-05-23 19:12:29 +0200
commit46771514fa86b9a5a0e0af34c1abfa1da22212f7 (patch)
treeb51c2bba5880fa9c9d0a578d948d249847a41967 /test
parent433c57aa6f304153f1b8740e0aa11b297f7fd143 (diff)
parent557c9a68fb72aeb535f2efe3cc82d3f5e66c6ad3 (diff)
downloadbitcoin-46771514fa86b9a5a0e0af34c1abfa1da22212f7.tar.xz
Merge #9571: RPC: getblockchaininfo returns BIP signaling statistics
557c9a6 RPC: getblockchaininfo: BIP9 stats (Matthew Zipkin) Tree-SHA512: ecf0bf47f04f92becc77acc649fdfa270e768939acce42df39d30069398d40d9a30539862f7c307e08239f78d5c58c470ca5f6e717d2ab8e24db9be0dd7bec0c
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/bip9-softforks.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/test/functional/bip9-softforks.py b/test/functional/bip9-softforks.py
index 1b2dff63d2..fff47fcca9 100755
--- a/test/functional/bip9-softforks.py
+++ b/test/functional/bip9-softforks.py
@@ -99,12 +99,43 @@ class BIP9SoftForksTest(ComparisonTestFramework):
assert_equal(self.get_bip9_status(bipName)['status'], 'started')
assert_equal(self.get_bip9_status(bipName)['since'], 144)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 0)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 0)
tmpl = self.nodes[0].getblocktemplate({})
assert(bipName not in tmpl['rules'])
assert_equal(tmpl['vbavailable'][bipName], bitno)
assert_equal(tmpl['vbrequired'], 0)
assert(tmpl['version'] & activated_version)
+ # Test 1-A
+ # check stats after max number of "signalling not" blocks such that LOCKED_IN still possible this period
+ test_blocks = self.generate_blocks(36, 4, test_blocks) # 0x00000004 (signalling not)
+ test_blocks = self.generate_blocks(10, activated_version) # 0x20000001 (signalling ready)
+ yield TestInstance(test_blocks, sync_every_block=False)
+
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 46)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 10)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['possible'], True)
+
+ # Test 1-B
+ # check stats after one additional "signalling not" block -- LOCKED_IN no longer possible this period
+ test_blocks = self.generate_blocks(1, 4, test_blocks) # 0x00000004 (signalling not)
+ yield TestInstance(test_blocks, sync_every_block=False)
+
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 47)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 10)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['possible'], False)
+
+ # Test 1-C
+ # finish period with "ready" blocks, but soft fork will still fail to advance to LOCKED_IN
+ test_blocks = self.generate_blocks(97, activated_version) # 0x20000001 (signalling ready)
+ yield TestInstance(test_blocks, sync_every_block=False)
+
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 0)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 0)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['possible'], True)
+ assert_equal(self.get_bip9_status(bipName)['status'], 'started')
+
# Test 2
# Fail to achieve LOCKED_IN 100 out of 144 signal bit 1
# using a variety of bits to simulate multiple parallel softforks
@@ -116,6 +147,8 @@ class BIP9SoftForksTest(ComparisonTestFramework):
assert_equal(self.get_bip9_status(bipName)['status'], 'started')
assert_equal(self.get_bip9_status(bipName)['since'], 144)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 0)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 0)
tmpl = self.nodes[0].getblocktemplate({})
assert(bipName not in tmpl['rules'])
assert_equal(tmpl['vbavailable'][bipName], bitno)
@@ -125,14 +158,24 @@ class BIP9SoftForksTest(ComparisonTestFramework):
# Test 3
# 108 out of 144 signal bit 1 to achieve LOCKED_IN
# using a variety of bits to simulate multiple parallel softforks
- test_blocks = self.generate_blocks(58, activated_version) # 0x20000001 (signalling ready)
+ test_blocks = self.generate_blocks(57, activated_version) # 0x20000001 (signalling ready)
test_blocks = self.generate_blocks(26, 4, test_blocks) # 0x00000004 (signalling not)
test_blocks = self.generate_blocks(50, activated_version, test_blocks) # 0x20000101 (signalling ready)
test_blocks = self.generate_blocks(10, 4, test_blocks) # 0x20010000 (signalling not)
yield TestInstance(test_blocks, sync_every_block=False)
+ # check counting stats and "possible" flag before last block of this period achieves LOCKED_IN...
+ assert_equal(self.get_bip9_status(bipName)['statistics']['elapsed'], 143)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['count'], 107)
+ assert_equal(self.get_bip9_status(bipName)['statistics']['possible'], True)
+ assert_equal(self.get_bip9_status(bipName)['status'], 'started')
+
+ # ...continue with Test 3
+ test_blocks = self.generate_blocks(1, activated_version) # 0x20000001 (signalling ready)
+ yield TestInstance(test_blocks, sync_every_block=False)
+
assert_equal(self.get_bip9_status(bipName)['status'], 'locked_in')
- assert_equal(self.get_bip9_status(bipName)['since'], 432)
+ assert_equal(self.get_bip9_status(bipName)['since'], 576)
tmpl = self.nodes[0].getblocktemplate({})
assert(bipName not in tmpl['rules'])
@@ -142,7 +185,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
yield TestInstance(test_blocks, sync_every_block=False)
assert_equal(self.get_bip9_status(bipName)['status'], 'locked_in')
- assert_equal(self.get_bip9_status(bipName)['since'], 432)
+ assert_equal(self.get_bip9_status(bipName)['since'], 576)
tmpl = self.nodes[0].getblocktemplate({})
assert(bipName not in tmpl['rules'])
@@ -168,7 +211,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
yield TestInstance([[block, True]])
assert_equal(self.get_bip9_status(bipName)['status'], 'active')
- assert_equal(self.get_bip9_status(bipName)['since'], 576)
+ assert_equal(self.get_bip9_status(bipName)['since'], 720)
tmpl = self.nodes[0].getblocktemplate({})
assert(bipName in tmpl['rules'])
assert(bipName not in tmpl['vbavailable'])