@@ -117,7 +117,7 @@ def test_one_producer_allowed(self) -> None:
117
117
118
118
# manager is allowed to produce blocks, so it does
119
119
manager .allow_mining_without_peers ()
120
- self .simulator .run (120 )
120
+ self .simulator .run (90 )
121
121
assert manager .tx_storage .get_block_count () == 10
122
122
123
123
_assert_height_weight_signer_id (
@@ -155,9 +155,9 @@ def test_two_producers(self) -> None:
155
155
self .simulator .add_connection (connection )
156
156
157
157
# both managers are producing blocks
158
- self .simulator .run (125 )
159
- assert manager1 .tx_storage .get_block_count () == 16
160
- assert manager2 .tx_storage .get_block_count () == 17
158
+ self .simulator .run (100 )
159
+ assert manager1 .tx_storage .get_block_count () == 15
160
+ assert manager2 .tx_storage .get_block_count () == 16
161
161
assert manager1 .tx_storage .get_best_block_tips () == manager2 .tx_storage .get_best_block_tips ()
162
162
163
163
_assert_height_weight_signer_id (
@@ -195,13 +195,10 @@ def test_two_producers(self) -> None:
195
195
196
196
if height % 2 == 0 :
197
197
# if the height is even, it's manager1's turn.
198
- # manager2 will produce its block too, but it'll be voided and not propagated.
199
198
assert len (blocks_manager1 ) == 1
200
- assert len (blocks_manager2 ) == 2
201
199
_assert_block_in_turn (blocks_manager1 [0 ], signer1 )
202
200
else :
203
201
# if the height is odd, the opposite happens
204
- assert len (blocks_manager1 ) == 2
205
202
assert len (blocks_manager2 ) == 1
206
203
_assert_block_in_turn (blocks_manager2 [0 ], signer2 )
207
204
@@ -214,41 +211,45 @@ def test_producer_leave_and_comeback(self) -> None:
214
211
# out of turn
215
212
manager1 = self ._get_manager (signer1 )
216
213
manager1 .allow_mining_without_peers ()
217
- self .simulator .run (60 )
214
+ self .simulator .run (50 )
218
215
219
216
manager2 = self ._get_manager (signer2 )
220
217
connection = FakeConnection (manager1 , manager2 )
221
218
self .simulator .add_connection (connection )
222
219
self .simulator .run (80 )
223
220
224
221
manager2 .stop ()
225
- self .simulator .run (40 )
222
+ self .simulator .run (70 )
226
223
227
224
manager2 .start ()
228
225
self .simulator .run (30 )
229
226
230
- assert manager1 .tx_storage .get_block_count () == 23
231
- assert manager2 .tx_storage .get_block_count () == 23
227
+ assert manager1 .tx_storage .get_block_count () == 22
228
+ assert manager2 .tx_storage .get_block_count () == 22
232
229
assert manager1 .tx_storage .get_best_block_tips () == manager2 .tx_storage .get_best_block_tips ()
233
230
234
231
_assert_height_weight_signer_id (
235
232
manager1 .tx_storage .get_all_transactions (),
236
233
[
234
+ # Before manager2 joins, only manager1 produces blocks
237
235
(1 , poa .BLOCK_WEIGHT_OUT_OF_TURN , signer_id1 ),
238
236
(2 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
239
237
(3 , poa .BLOCK_WEIGHT_OUT_OF_TURN , signer_id1 ),
240
238
(4 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
241
239
(5 , poa .BLOCK_WEIGHT_OUT_OF_TURN , signer_id1 ),
242
240
(6 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
241
+ # When manager2 joins, both of them start taking turns
243
242
(7 , poa .BLOCK_WEIGHT_IN_TURN , signer_id2 ),
244
243
(8 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
245
244
(9 , poa .BLOCK_WEIGHT_IN_TURN , signer_id2 ),
246
245
(10 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
247
246
(11 , poa .BLOCK_WEIGHT_IN_TURN , signer_id2 ),
248
247
(12 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
248
+ # manager2 leaves so manager1 produces all the next blocks
249
249
(13 , poa .BLOCK_WEIGHT_OUT_OF_TURN , signer_id1 ),
250
250
(14 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
251
251
(15 , poa .BLOCK_WEIGHT_OUT_OF_TURN , signer_id1 ),
252
+ # manager2 comes back again, so both of them take turns again
252
253
(16 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
253
254
(17 , poa .BLOCK_WEIGHT_IN_TURN , signer_id2 ),
254
255
(18 , poa .BLOCK_WEIGHT_IN_TURN , signer_id1 ),
@@ -272,7 +273,7 @@ def test_existing_storage(self) -> None:
272
273
manager1 = artifacts1 .manager
273
274
manager1 .allow_mining_without_peers ()
274
275
275
- self .simulator .run (80 )
276
+ self .simulator .run (50 )
276
277
assert manager1 .tx_storage .get_block_count () == 6
277
278
278
279
_assert_height_weight_signer_id (
@@ -296,7 +297,7 @@ def test_existing_storage(self) -> None:
296
297
manager2 = artifacts .manager
297
298
manager2 .allow_mining_without_peers ()
298
299
299
- self .simulator .run (80 )
300
+ self .simulator .run (60 )
300
301
assert manager2 .tx_storage .get_block_count () == 12
301
302
302
303
_assert_height_weight_signer_id (
@@ -332,7 +333,7 @@ def test_new_signer_added(self) -> None:
332
333
manager_1a = artifacts_1a .manager
333
334
manager_1a .allow_mining_without_peers ()
334
335
335
- self .simulator .run (80 )
336
+ self .simulator .run (50 )
336
337
assert manager_1a .tx_storage .get_block_count () == 6
337
338
338
339
_assert_height_weight_signer_id (
@@ -358,7 +359,7 @@ def test_new_signer_added(self) -> None:
358
359
manager_1b = artifacts_1b .manager
359
360
manager_1b .allow_mining_without_peers ()
360
361
361
- self .simulator .run (80 )
362
+ self .simulator .run (90 )
362
363
assert manager_1b .tx_storage .get_block_count () == 11
363
364
364
365
# after we restart it, new blocks are alternating
@@ -383,7 +384,7 @@ def test_new_signer_added(self) -> None:
383
384
384
385
connection = FakeConnection (manager_1b , manager_2 )
385
386
self .simulator .add_connection (connection )
386
- self .simulator .run (40 )
387
+ self .simulator .run (60 )
387
388
388
389
# it should sync to the same blockchain
389
390
_assert_height_weight_signer_id (
@@ -463,7 +464,7 @@ def test_use_case(self) -> None:
463
464
464
465
manager = self ._get_manager (signer )
465
466
manager .allow_mining_without_peers ()
466
- self .simulator .run (130 )
467
+ self .simulator .run (100 )
467
468
assert manager .tx_storage .get_block_count () == 11
468
469
469
470
_assert_height_weight_signer_id (
0 commit comments