diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index a9242fba5bc8..ba3d2c98c5e4 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -1500,9 +1500,9 @@ func TestFakedSyncProgress66NoRemoteCheckpoint(t *testing.T) { tester := newTester() validate := func(count int) (bool, error) { - // only return the `ErrNoRemoteCheckoint` error for the first call + // only return the `ErrNoRemoteCheckpoint` error for the first call if count == 0 { - return false, whitelist.ErrNoRemoteCheckoint + return false, whitelist.ErrNoRemoteCheckpoint } return true, nil @@ -1518,7 +1518,7 @@ func TestFakedSyncProgress66NoRemoteCheckpoint(t *testing.T) { // Synchronise with the peer and make sure all blocks were retrieved // Should fail in first attempt if err := tester.sync("light", nil, mode); err != nil { - assert.Equal(t, whitelist.ErrNoRemoteCheckoint, err, "failed synchronisation") + assert.Equal(t, whitelist.ErrNoRemoteCheckpoint, err, "failed synchronisation") } // Try syncing again, should succeed diff --git a/eth/downloader/whitelist/service.go b/eth/downloader/whitelist/service.go index a2edcfb797da..5d3fe477d3d7 100644 --- a/eth/downloader/whitelist/service.go +++ b/eth/downloader/whitelist/service.go @@ -31,7 +31,7 @@ func NewService(maxCapacity uint) *Service { var ( ErrCheckpointMismatch = errors.New("checkpoint mismatch") ErrLongFutureChain = errors.New("received future chain of unacceptable length") - ErrNoRemoteCheckoint = errors.New("remote peer doesn't have a checkoint") + ErrNoRemoteCheckpoint = errors.New("remote peer doesn't have a checkpoint") ) // IsValidPeer checks if the chain we're about to receive from a peer is valid or not @@ -55,11 +55,11 @@ func (w *Service) IsValidPeer(remoteHeader *types.Header, fetchHeadersByNumber f // todo: we can extract this as an interface and mock as well or just test IsValidChain in isolation from downloader passing fake fetchHeadersByNumber functions headers, hashes, err := fetchHeadersByNumber(lastCheckpointBlockNum, 1, 0, false) if err != nil { - return false, fmt.Errorf("%w: last checkpoint %d, err %v", ErrNoRemoteCheckoint, lastCheckpointBlockNum, err) + return false, fmt.Errorf("%w: last checkpoint %d, err %v", ErrNoRemoteCheckpoint, lastCheckpointBlockNum, err) } if len(headers) == 0 { - return false, fmt.Errorf("%w: last checkpoint %d", ErrNoRemoteCheckoint, lastCheckpointBlockNum) + return false, fmt.Errorf("%w: last checkpoint %d", ErrNoRemoteCheckpoint, lastCheckpointBlockNum) } reqBlockNum := headers[0].Number.Uint64() diff --git a/eth/downloader/whitelist/service_test.go b/eth/downloader/whitelist/service_test.go index a91148c76114..cf0b076cfd38 100644 --- a/eth/downloader/whitelist/service_test.go +++ b/eth/downloader/whitelist/service_test.go @@ -64,14 +64,14 @@ func TestIsValidPeer(t *testing.T) { } // case2: false fetchHeadersByNumber function provided, should consider the chain as invalid - // and throw `ErrNoRemoteCheckoint` error + // and throw `ErrNoRemoteCheckpoint` error res, err = s.IsValidPeer(nil, falseFetchHeadersByNumber) if err == nil { t.Fatal("expected error, got nil") } - if !errors.Is(err, ErrNoRemoteCheckoint) { - t.Fatalf("expected error ErrNoRemoteCheckoint, got %v", err) + if !errors.Is(err, ErrNoRemoteCheckpoint) { + t.Fatalf("expected error ErrNoRemoteCheckpoint, got %v", err) } require.Equal(t, res, false, "expected chain to be invalid")