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