@@ -1377,8 +1377,8 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1377
1377
<- progress
1378
1378
}
1379
1379
// 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 )
1382
1382
}
1383
1383
// Synchronise half the blocks and check initial progress
1384
1384
tester .newPeer ("peer-half" , protocol , hashes [targetBlocks / 2 :], headers , blocks , receipts )
@@ -1392,8 +1392,8 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1392
1392
}
1393
1393
}()
1394
1394
<- 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 )
1397
1397
}
1398
1398
progress <- struct {}{}
1399
1399
pending .Wait ()
@@ -1409,15 +1409,15 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1409
1409
}
1410
1410
}()
1411
1411
<- 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 )
1414
1414
}
1415
1415
progress <- struct {}{}
1416
1416
pending .Wait ()
1417
1417
1418
1418
// 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 )
1421
1421
}
1422
1422
}
1423
1423
@@ -1450,8 +1450,8 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1450
1450
<- progress
1451
1451
}
1452
1452
// 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 )
1455
1455
}
1456
1456
// Synchronise with one of the forks and check progress
1457
1457
tester .newPeer ("fork A" , protocol , hashesA , headersA , blocksA , receiptsA )
@@ -1465,8 +1465,8 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1465
1465
}
1466
1466
}()
1467
1467
<- 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 )
1470
1470
}
1471
1471
progress <- struct {}{}
1472
1472
pending .Wait ()
@@ -1485,15 +1485,15 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1485
1485
}
1486
1486
}()
1487
1487
<- 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 )
1490
1490
}
1491
1491
progress <- struct {}{}
1492
1492
pending .Wait ()
1493
1493
1494
1494
// 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 )
1497
1497
}
1498
1498
}
1499
1499
@@ -1526,8 +1526,8 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1526
1526
<- progress
1527
1527
}
1528
1528
// 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 )
1531
1531
}
1532
1532
// Attempt a full sync with a faulty peer
1533
1533
tester .newPeer ("faulty" , protocol , hashes , headers , blocks , receipts )
@@ -1546,8 +1546,8 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1546
1546
}
1547
1547
}()
1548
1548
<- 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 )
1551
1551
}
1552
1552
progress <- struct {}{}
1553
1553
pending .Wait ()
@@ -1563,15 +1563,15 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1563
1563
}
1564
1564
}()
1565
1565
<- 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 )
1568
1568
}
1569
1569
progress <- struct {}{}
1570
1570
pending .Wait ()
1571
1571
1572
1572
// 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 )
1575
1575
}
1576
1576
}
1577
1577
@@ -1603,8 +1603,8 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1603
1603
<- progress
1604
1604
}
1605
1605
// 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 )
1608
1608
}
1609
1609
// Create and sync with an attacker that promises a higher chain than available
1610
1610
tester .newPeer ("attack" , protocol , hashes , headers , blocks , receipts )
@@ -1624,8 +1624,8 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1624
1624
}
1625
1625
}()
1626
1626
<- 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 )
1629
1629
}
1630
1630
progress <- struct {}{}
1631
1631
pending .Wait ()
@@ -1641,15 +1641,15 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
1641
1641
}
1642
1642
}()
1643
1643
<- 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 )
1646
1646
}
1647
1647
progress <- struct {}{}
1648
1648
pending .Wait ()
1649
1649
1650
1650
// 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 )
1653
1653
}
1654
1654
}
1655
1655
0 commit comments