Skip to content

Commit

Permalink
fixed checkoint misspell to checkpoint (ethereum#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikspatil024 authored May 9, 2023
1 parent 1e181a9 commit b6de7aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions eth/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions eth/downloader/whitelist/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions eth/downloader/whitelist/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b6de7aa

Please sign in to comment.