fixed checkoint misspell to checkpoint (#854)

This commit is contained in:
Pratik Patil 2023-05-09 12:37:25 +05:30 committed by GitHub
parent 1e181a9b2e
commit b6de7aaf17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -1500,9 +1500,9 @@ func TestFakedSyncProgress66NoRemoteCheckpoint(t *testing.T) {
tester := newTester() tester := newTester()
validate := func(count int) (bool, error) { 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 { if count == 0 {
return false, whitelist.ErrNoRemoteCheckoint return false, whitelist.ErrNoRemoteCheckpoint
} }
return true, nil return true, nil
@ -1518,7 +1518,7 @@ func TestFakedSyncProgress66NoRemoteCheckpoint(t *testing.T) {
// Synchronise with the peer and make sure all blocks were retrieved // Synchronise with the peer and make sure all blocks were retrieved
// Should fail in first attempt // Should fail in first attempt
if err := tester.sync("light", nil, mode); err != nil { 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 // Try syncing again, should succeed

View file

@ -31,7 +31,7 @@ func NewService(maxCapacity uint) *Service {
var ( var (
ErrCheckpointMismatch = errors.New("checkpoint mismatch") ErrCheckpointMismatch = errors.New("checkpoint mismatch")
ErrLongFutureChain = errors.New("received future chain of unacceptable length") 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 // 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 // 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) headers, hashes, err := fetchHeadersByNumber(lastCheckpointBlockNum, 1, 0, false)
if err != nil { 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 { 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() reqBlockNum := headers[0].Number.Uint64()

View file

@ -64,14 +64,14 @@ func TestIsValidPeer(t *testing.T) {
} }
// case2: false fetchHeadersByNumber function provided, should consider the chain as invalid // 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) res, err = s.IsValidPeer(nil, falseFetchHeadersByNumber)
if err == nil { if err == nil {
t.Fatal("expected error, got nil") t.Fatal("expected error, got nil")
} }
if !errors.Is(err, ErrNoRemoteCheckoint) { if !errors.Is(err, ErrNoRemoteCheckpoint) {
t.Fatalf("expected error ErrNoRemoteCheckoint, got %v", err) t.Fatalf("expected error ErrNoRemoteCheckpoint, got %v", err)
} }
require.Equal(t, res, false, "expected chain to be invalid") require.Equal(t, res, false, "expected chain to be invalid")