@@ -1377,8 +1377,8 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
13771377 <- progress
13781378 }
13791379 // Retrieve the sync progress and ensure they are zero (pristine sync)
1380- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != 0 {
1381- t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , 0 )
1380+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != 0 {
1381+ t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , 0 )
13821382 }
13831383 // Synchronise half the blocks and check initial progress
13841384 tester .newPeer ("peer-half" , protocol , hashes [targetBlocks / 2 :], headers , blocks , receipts )
@@ -1392,8 +1392,8 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
13921392 }
13931393 }()
13941394 <- starting
1395- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != uint64 (targetBlocks / 2 + 1 ) {
1396- t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , targetBlocks / 2 + 1 )
1395+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != uint64 (targetBlocks / 2 + 1 ) {
1396+ t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , targetBlocks / 2 + 1 )
13971397 }
13981398 progress <- struct {}{}
13991399 pending .Wait ()
@@ -1409,15 +1409,15 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14091409 }
14101410 }()
14111411 <- starting
1412- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != uint64 (targetBlocks / 2 + 1 ) || current != uint64 (targetBlocks / 2 + 1 ) || latest != uint64 (targetBlocks ) {
1413- t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , targetBlocks / 2 + 1 , targetBlocks / 2 + 1 , targetBlocks )
1412+ if progress := tester .downloader .Progress (); progress . StartingBlock != uint64 (targetBlocks / 2 + 1 ) || progress . CurrentBlock != uint64 (targetBlocks / 2 + 1 ) || progress . HighestBlock != uint64 (targetBlocks ) {
1413+ t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , targetBlocks / 2 + 1 , targetBlocks / 2 + 1 , targetBlocks )
14141414 }
14151415 progress <- struct {}{}
14161416 pending .Wait ()
14171417
14181418 // Check final progress after successful sync
1419- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != uint64 (targetBlocks / 2 + 1 ) || current != uint64 (targetBlocks ) || latest != uint64 (targetBlocks ) {
1420- t .Fatalf ("Final progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , targetBlocks / 2 + 1 , targetBlocks , targetBlocks )
1419+ if progress := tester .downloader .Progress (); progress . StartingBlock != uint64 (targetBlocks / 2 + 1 ) || progress . CurrentBlock != uint64 (targetBlocks ) || progress . HighestBlock != uint64 (targetBlocks ) {
1420+ t .Fatalf ("Final progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , targetBlocks / 2 + 1 , targetBlocks , targetBlocks )
14211421 }
14221422}
14231423
@@ -1450,8 +1450,8 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14501450 <- progress
14511451 }
14521452 // Retrieve the sync progress and ensure they are zero (pristine sync)
1453- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != 0 {
1454- t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , 0 )
1453+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != 0 {
1454+ t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , 0 )
14551455 }
14561456 // Synchronise with one of the forks and check progress
14571457 tester .newPeer ("fork A" , protocol , hashesA , headersA , blocksA , receiptsA )
@@ -1465,8 +1465,8 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14651465 }
14661466 }()
14671467 <- starting
1468- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != uint64 (len (hashesA )- 1 ) {
1469- t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , len (hashesA )- 1 )
1468+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != uint64 (len (hashesA )- 1 ) {
1469+ t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , len (hashesA )- 1 )
14701470 }
14711471 progress <- struct {}{}
14721472 pending .Wait ()
@@ -1485,15 +1485,15 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14851485 }
14861486 }()
14871487 <- starting
1488- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != uint64 (common ) || current != uint64 (len (hashesA )- 1 ) || latest != uint64 (len (hashesB )- 1 ) {
1489- t .Fatalf ("Forking progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , common , len (hashesA )- 1 , len (hashesB )- 1 )
1488+ if progress := tester .downloader .Progress (); progress . StartingBlock != uint64 (common ) || progress . CurrentBlock != uint64 (len (hashesA )- 1 ) || progress . HighestBlock != uint64 (len (hashesB )- 1 ) {
1489+ t .Fatalf ("Forking progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , common , len (hashesA )- 1 , len (hashesB )- 1 )
14901490 }
14911491 progress <- struct {}{}
14921492 pending .Wait ()
14931493
14941494 // Check final progress after successful sync
1495- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != uint64 (common ) || current != uint64 (len (hashesB )- 1 ) || latest != uint64 (len (hashesB )- 1 ) {
1496- t .Fatalf ("Final progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , common , len (hashesB )- 1 , len (hashesB )- 1 )
1495+ if progress := tester .downloader .Progress (); progress . StartingBlock != uint64 (common ) || progress . CurrentBlock != uint64 (len (hashesB )- 1 ) || progress . HighestBlock != uint64 (len (hashesB )- 1 ) {
1496+ t .Fatalf ("Final progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , common , len (hashesB )- 1 , len (hashesB )- 1 )
14971497 }
14981498}
14991499
@@ -1526,8 +1526,8 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
15261526 <- progress
15271527 }
15281528 // Retrieve the sync progress and ensure they are zero (pristine sync)
1529- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != 0 {
1530- t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , 0 )
1529+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != 0 {
1530+ t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , 0 )
15311531 }
15321532 // Attempt a full sync with a faulty peer
15331533 tester .newPeer ("faulty" , protocol , hashes , headers , blocks , receipts )
@@ -1546,8 +1546,8 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
15461546 }
15471547 }()
15481548 <- starting
1549- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != uint64 (targetBlocks ) {
1550- t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , targetBlocks )
1549+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != uint64 (targetBlocks ) {
1550+ t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , targetBlocks )
15511551 }
15521552 progress <- struct {}{}
15531553 pending .Wait ()
@@ -1563,15 +1563,15 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
15631563 }
15641564 }()
15651565 <- starting
1566- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current > uint64 (targetBlocks / 2 ) || latest != uint64 (targetBlocks ) {
1567- t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/0-%v/%v" , origin , current , latest , 0 , targetBlocks / 2 , targetBlocks )
1566+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock > uint64 (targetBlocks / 2 ) || progress . HighestBlock != uint64 (targetBlocks ) {
1567+ t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/0-%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , targetBlocks / 2 , targetBlocks )
15681568 }
15691569 progress <- struct {}{}
15701570 pending .Wait ()
15711571
15721572 // Check final progress after successful sync
1573- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin > uint64 (targetBlocks / 2 ) || current != uint64 (targetBlocks ) || latest != uint64 (targetBlocks ) {
1574- t .Fatalf ("Final progress mismatch: have %v/%v/%v, want 0-%v/%v/%v" , origin , current , latest , targetBlocks / 2 , targetBlocks , targetBlocks )
1573+ if progress := tester .downloader .Progress (); progress . StartingBlock > uint64 (targetBlocks / 2 ) || progress . CurrentBlock != uint64 (targetBlocks ) || progress . HighestBlock != uint64 (targetBlocks ) {
1574+ t .Fatalf ("Final progress mismatch: have %v/%v/%v, want 0-%v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , targetBlocks / 2 , targetBlocks , targetBlocks )
15751575 }
15761576}
15771577
@@ -1603,8 +1603,8 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
16031603 <- progress
16041604 }
16051605 // Retrieve the sync progress and ensure they are zero (pristine sync)
1606- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != 0 {
1607- t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , 0 )
1606+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != 0 {
1607+ t .Fatalf ("Pristine progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , 0 )
16081608 }
16091609 // Create and sync with an attacker that promises a higher chain than available
16101610 tester .newPeer ("attack" , protocol , hashes , headers , blocks , receipts )
@@ -1624,8 +1624,8 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
16241624 }
16251625 }()
16261626 <- starting
1627- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current != 0 || latest != uint64 (targetBlocks + 3 ) {
1628- t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , origin , current , latest , 0 , 0 , targetBlocks + 3 )
1627+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock != 0 || progress . HighestBlock != uint64 (targetBlocks + 3 ) {
1628+ t .Fatalf ("Initial progress mismatch: have %v/%v/%v, want %v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , 0 , targetBlocks + 3 )
16291629 }
16301630 progress <- struct {}{}
16311631 pending .Wait ()
@@ -1641,15 +1641,15 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
16411641 }
16421642 }()
16431643 <- starting
1644- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin != 0 || current > uint64 (targetBlocks ) || latest != uint64 (targetBlocks ) {
1645- t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/0-%v/%v" , origin , current , latest , 0 , targetBlocks , targetBlocks )
1644+ if progress := tester .downloader .Progress (); progress . StartingBlock != 0 || progress . CurrentBlock > uint64 (targetBlocks ) || progress . HighestBlock != uint64 (targetBlocks ) {
1645+ t .Fatalf ("Completing progress mismatch: have %v/%v/%v, want %v/0-%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , 0 , targetBlocks , targetBlocks )
16461646 }
16471647 progress <- struct {}{}
16481648 pending .Wait ()
16491649
16501650 // Check final progress after successful sync
1651- if origin , current , latest , _ , _ := tester .downloader .Progress (); origin > uint64 (targetBlocks ) || current != uint64 (targetBlocks ) || latest != uint64 (targetBlocks ) {
1652- t .Fatalf ("Final progress mismatch: have %v/%v/%v, want 0-%v/%v/%v" , origin , current , latest , targetBlocks , targetBlocks , targetBlocks )
1651+ if progress := tester .downloader .Progress (); progress . StartingBlock > uint64 (targetBlocks ) || progress . CurrentBlock != uint64 (targetBlocks ) || progress . HighestBlock != uint64 (targetBlocks ) {
1652+ t .Fatalf ("Final progress mismatch: have %v/%v/%v, want 0-%v/%v/%v" , progress . StartingBlock , progress . CurrentBlock , progress . HighestBlock , targetBlocks , targetBlocks , targetBlocks )
16531653 }
16541654}
16551655
0 commit comments