@@ -15,6 +15,7 @@ import (
15
15
"github.com/celo-org/celo-blockchain/common"
16
16
"github.com/celo-org/celo-blockchain/common/hexutil"
17
17
"github.com/celo-org/celo-blockchain/core/types"
18
+ "github.com/celo-org/celo-blockchain/eth/downloader"
18
19
"github.com/celo-org/celo-blockchain/eth/tracers"
19
20
"github.com/celo-org/celo-blockchain/log"
20
21
"github.com/celo-org/celo-blockchain/mycelo/env"
@@ -392,15 +393,19 @@ func runStopNetworkAtL2BlockTest(ctx context.Context, t *testing.T, network test
392
393
func TestStopNetworkAtl2BlockSimple (t * testing.T ) {
393
394
numValidators := 3
394
395
numFullNodes := 2
396
+ numFastNodes := 1
395
397
ac := test .AccountConfig (numValidators , 2 )
396
398
gingerbreadBlock := common .Big0
397
399
l2BlockOG := big .NewInt (3 )
398
400
gc , ec , err := test .BuildConfig (ac , gingerbreadBlock , l2BlockOG )
399
401
require .NoError (t , err )
400
402
network , _ , err := test .NewNetwork (ac , gc , ec )
401
403
require .NoError (t , err )
402
- network , shutdown , err : = test .AddNetworkFullNodes (network , ec , uint64 (numFullNodes ))
404
+ network , _ , err = test .AddNonValidatorNodes (network , ec , uint64 (numFullNodes ), downloader . FullSync )
403
405
require .NoError (t , err )
406
+ network , shutdown , err := test .AddNonValidatorNodes (network , ec , uint64 (numFastNodes ), downloader .FastSync )
407
+ require .NoError (t , err )
408
+
404
409
defer shutdown ()
405
410
406
411
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 40 )
@@ -412,15 +417,19 @@ func TestStopNetworkAtl2BlockSimple(t *testing.T) {
412
417
func TestStopNetworkAtL2Block (t * testing.T ) {
413
418
numValidators := 3
414
419
numFullNodes := 2
420
+ numFastNodes := 1
415
421
ac := test .AccountConfig (numValidators , 2 )
416
422
gingerbreadBlock := common .Big0
417
423
l2BlockOG := big .NewInt (3 )
418
424
gc , ec , err := test .BuildConfig (ac , gingerbreadBlock , l2BlockOG )
419
425
require .NoError (t , err )
420
426
network , _ , err := test .NewNetwork (ac , gc , ec )
421
427
require .NoError (t , err )
422
- network , shutdown , err : = test .AddNetworkFullNodes (network , ec , uint64 (numFullNodes ))
428
+ network , _ , err = test .AddNonValidatorNodes (network , ec , uint64 (numFullNodes ), downloader . FullSync )
423
429
require .NoError (t , err )
430
+ network , shutdown , err := test .AddNonValidatorNodes (network , ec , uint64 (numFastNodes ), downloader .FastSync )
431
+ require .NoError (t , err )
432
+
424
433
defer shutdown ()
425
434
426
435
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 400 )
@@ -431,7 +440,7 @@ func TestStopNetworkAtL2Block(t *testing.T) {
431
440
shutdown ()
432
441
433
442
// Restart nodes with --l2-migration-block set to the next block
434
- err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 1 , 1 , 1 })
443
+ err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 1 , 1 , 1 , 1 })
435
444
require .NoError (t , err )
436
445
437
446
l2BlockPlusOne := new (big.Int ).Add (l2BlockOG , big .NewInt (1 ))
@@ -441,7 +450,7 @@ func TestStopNetworkAtL2Block(t *testing.T) {
441
450
shutdown ()
442
451
443
452
// Restart nodes with --l2-migration-block set to the same block
444
- err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 1 , 1 , 1 })
453
+ err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 1 , 1 , 1 , 1 })
445
454
require .NoError (t , err )
446
455
447
456
runStopNetworkAtL2BlockTest (ctx , t , network , l2BlockPlusOne )
@@ -451,7 +460,7 @@ func TestStopNetworkAtL2Block(t *testing.T) {
451
460
// Restart nodes with different --l2-migration-block offsets
452
461
// If 2/3 validators (validators are the first 3 nodes in the network array)
453
462
// have the same migration block, the network should not be able to add any more blocks
454
- err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 2 , 2 , 2 })
463
+ err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 1 , 2 , 2 , 2 , 2 })
455
464
require .NoError (t , err )
456
465
457
466
runStopNetworkAtL2BlockTest (ctx , t , network , l2BlockPlusOne )
@@ -461,7 +470,7 @@ func TestStopNetworkAtL2Block(t *testing.T) {
461
470
// Restart nodes with different --l2-migration-block offsets
462
471
// If 2/3 validators (validators are the first 3 nodes in the network array)
463
472
// have a greater migration block, the rest of the network should be able to add more blocks
464
- err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 2 , 2 , 2 , 2 })
473
+ err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {1 , 2 , 2 , 2 , 2 , 2 })
465
474
require .NoError (t , err )
466
475
467
476
l2BlockPlusTwo := new (big.Int ).Add (l2BlockOG , big .NewInt (2 ))
@@ -472,8 +481,7 @@ func TestStopNetworkAtL2Block(t *testing.T) {
472
481
shutdown ()
473
482
474
483
// Restart nodes with --l2-migration-block set to a prev block
475
- err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {- 1 , - 1 , - 1 , - 1 , - 1 })
476
- // TODO(Alec) it would actually be nice to return errors here, require.Error(t, err, core.ErrL2Migration.Error())
484
+ err = network .RestartNetworkWithMigrationBlockOffsets (l2BlockOG , []int64 {- 1 , - 1 , - 1 , - 1 , - 1 , - 1 })
477
485
require .NoError (t , err )
478
486
479
487
// The network should be unchanged
0 commit comments