@@ -104,12 +104,43 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
104
104
105
105
assert_equal (self .get_bip9_status (bipName )['status' ], 'started' )
106
106
assert_equal (self .get_bip9_status (bipName )['since' ], 144 )
107
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 0 )
108
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 0 )
107
109
tmpl = self .nodes [0 ].getblocktemplate ({})
108
110
assert (bipName not in tmpl ['rules' ])
109
111
assert_equal (tmpl ['vbavailable' ][bipName ], bitno )
110
112
assert_equal (tmpl ['vbrequired' ], 0 )
111
113
assert (tmpl ['version' ] & activated_version )
112
114
115
+ # Test 1-A
116
+ # check stats after max number of "signalling not" blocks such that LOCKED_IN still possible this period
117
+ test_blocks = self .generate_blocks (36 , 4 , test_blocks ) # 0x00000004 (signalling not)
118
+ test_blocks = self .generate_blocks (10 , activated_version ) # 0x20000001 (signalling ready)
119
+ yield TestInstance (test_blocks , sync_every_block = False )
120
+
121
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 46 )
122
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 10 )
123
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['possible' ], True )
124
+
125
+ # Test 1-B
126
+ # check stats after one additional "signalling not" block -- LOCKED_IN no longer possible this period
127
+ test_blocks = self .generate_blocks (1 , 4 , test_blocks ) # 0x00000004 (signalling not)
128
+ yield TestInstance (test_blocks , sync_every_block = False )
129
+
130
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 47 )
131
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 10 )
132
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['possible' ], False )
133
+
134
+ # Test 1-C
135
+ # finish period with "ready" blocks, but soft fork will still fail to advance to LOCKED_IN
136
+ test_blocks = self .generate_blocks (97 , activated_version ) # 0x20000001 (signalling ready)
137
+ yield TestInstance (test_blocks , sync_every_block = False )
138
+
139
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 0 )
140
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 0 )
141
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['possible' ], True )
142
+ assert_equal (self .get_bip9_status (bipName )['status' ], 'started' )
143
+
113
144
# Test 2
114
145
# Fail to achieve LOCKED_IN 100 out of 144 signal bit 1
115
146
# using a variety of bits to simulate multiple parallel softforks
@@ -121,6 +152,8 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
121
152
122
153
assert_equal (self .get_bip9_status (bipName )['status' ], 'started' )
123
154
assert_equal (self .get_bip9_status (bipName )['since' ], 144 )
155
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 0 )
156
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 0 )
124
157
tmpl = self .nodes [0 ].getblocktemplate ({})
125
158
assert (bipName not in tmpl ['rules' ])
126
159
assert_equal (tmpl ['vbavailable' ][bipName ], bitno )
@@ -130,14 +163,24 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
130
163
# Test 3
131
164
# 108 out of 144 signal bit 1 to achieve LOCKED_IN
132
165
# using a variety of bits to simulate multiple parallel softforks
133
- test_blocks = self .generate_blocks (58 , activated_version ) # 0x20000001 (signalling ready)
166
+ test_blocks = self .generate_blocks (57 , activated_version ) # 0x20000001 (signalling ready)
134
167
test_blocks = self .generate_blocks (26 , 4 , test_blocks ) # 0x00000004 (signalling not)
135
168
test_blocks = self .generate_blocks (50 , activated_version , test_blocks ) # 0x20000101 (signalling ready)
136
169
test_blocks = self .generate_blocks (10 , 4 , test_blocks ) # 0x20010000 (signalling not)
137
170
yield TestInstance (test_blocks , sync_every_block = False )
138
171
172
+ # check counting stats and "possible" flag before last block of this period achieves LOCKED_IN...
173
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['elapsed' ], 143 )
174
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['count' ], 107 )
175
+ assert_equal (self .get_bip9_status (bipName )['statistics' ]['possible' ], True )
176
+ assert_equal (self .get_bip9_status (bipName )['status' ], 'started' )
177
+
178
+ # ...continue with Test 3
179
+ test_blocks = self .generate_blocks (1 , activated_version ) # 0x20000001 (signalling ready)
180
+ yield TestInstance (test_blocks , sync_every_block = False )
181
+
139
182
assert_equal (self .get_bip9_status (bipName )['status' ], 'locked_in' )
140
- assert_equal (self .get_bip9_status (bipName )['since' ], 432 )
183
+ assert_equal (self .get_bip9_status (bipName )['since' ], 576 )
141
184
tmpl = self .nodes [0 ].getblocktemplate ({})
142
185
assert (bipName not in tmpl ['rules' ])
143
186
@@ -147,7 +190,7 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
147
190
yield TestInstance (test_blocks , sync_every_block = False )
148
191
149
192
assert_equal (self .get_bip9_status (bipName )['status' ], 'locked_in' )
150
- assert_equal (self .get_bip9_status (bipName )['since' ], 432 )
193
+ assert_equal (self .get_bip9_status (bipName )['since' ], 576 )
151
194
tmpl = self .nodes [0 ].getblocktemplate ({})
152
195
assert (bipName not in tmpl ['rules' ])
153
196
@@ -173,7 +216,7 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
173
216
yield TestInstance ([[block , True ]])
174
217
175
218
assert_equal (self .get_bip9_status (bipName )['status' ], 'active' )
176
- assert_equal (self .get_bip9_status (bipName )['since' ], 576 )
219
+ assert_equal (self .get_bip9_status (bipName )['since' ], 720 )
177
220
tmpl = self .nodes [0 ].getblocktemplate ({})
178
221
assert (bipName in tmpl ['rules' ])
179
222
assert (bipName not in tmpl ['vbavailable' ])
0 commit comments