From 80d6c6076990409460a9b0d1464b4dc7b3c685d9 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 31 Oct 2018 23:05:55 +0100 Subject: [PATCH] fixed error strings (#708) --- beacon-chain/blockchain/service_test.go | 2 +- beacon-chain/casper/validator.go | 4 ++-- beacon-chain/db/block.go | 6 +++--- beacon-chain/powchain/service_test.go | 2 +- beacon-chain/rpc/service.go | 2 +- beacon-chain/sync/service.go | 2 +- beacon-chain/types/active_state.go | 2 +- beacon-chain/types/block.go | 12 ++++++------ validator/beacon/service.go | 2 +- validator/types/shard.go | 10 +++++----- validator/types/shard_test.go | 16 ++++++++-------- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index 30e1665a52..af6ab2d703 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -265,7 +265,7 @@ func TestProcessBlocksWithCorrectAttestations(t *testing.T) { Slot: 0, }) if saveErr := chainService.beaconDB.SaveBlock(block0); saveErr != nil { - t.Fatalf("Cannot save block: %v", saveErr) + t.Fatalf("Could not save block: %v", saveErr) } block0Hash, err := block0.Hash() if err != nil { diff --git a/beacon-chain/casper/validator.go b/beacon-chain/casper/validator.go index 1adae91b90..0431c7ce66 100644 --- a/beacon-chain/casper/validator.go +++ b/beacon-chain/casper/validator.go @@ -77,7 +77,7 @@ func GetShardAndCommitteesForSlot(shardCommittees []*pb.ShardAndCommitteeArray, func AreAttesterBitfieldsValid(attestation *pb.AggregatedAttestation, attesterIndices []uint32) bool { // Validate attester bit field has the correct length. if bitutil.BitLength(len(attesterIndices)) != len(attestation.AttesterBitfield) { - log.Debugf("attestation has incorrect bitfield length. Found %v, expected %v", + log.Debugf("Attestation has incorrect bitfield length. Found %v, expected %v", len(attestation.AttesterBitfield), bitutil.BitLength(len(attesterIndices))) return false } @@ -97,7 +97,7 @@ func AreAttesterBitfieldsValid(attestation *pb.AggregatedAttestation, attesterIn } if isBitSet { - log.Error("attestation has non-zero trailing bits") + log.Error("Attestation has non-zero trailing bits") return false } } diff --git a/beacon-chain/db/block.go b/beacon-chain/db/block.go index ed14ec5ed4..9737f01d3c 100644 --- a/beacon-chain/db/block.go +++ b/beacon-chain/db/block.go @@ -198,15 +198,15 @@ func (db *BeaconDB) GetBlockBySlot(slot uint64) (*types.Block, error) { func (db *BeaconDB) GetGenesisTime() (time.Time, error) { genesis, err := db.GetBlockBySlot(0) if err != nil { - return time.Time{}, fmt.Errorf("Could not get genesis block: %v", err) + return time.Time{}, fmt.Errorf("could not get genesis block: %v", err) } if genesis == nil { - return time.Time{}, fmt.Errorf("Genesis block not found: %v", err) + return time.Time{}, fmt.Errorf("genesis block not found: %v", err) } genesisTime, err := genesis.Timestamp() if err != nil { - return time.Time{}, fmt.Errorf("Could not get genesis timestamp: %v", err) + return time.Time{}, fmt.Errorf("could not get genesis timestamp: %v", err) } return genesisTime, nil diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index b55875775c..6255211a31 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -71,7 +71,7 @@ func TestStart(t *testing.T) { web3Service.Start() msg := hook.LastEntry().Message - want := "Cannot connect to PoW chain RPC client" + want := "Could not connect to PoW chain RPC client" if strings.Contains(want, msg) { t.Errorf("incorrect log, expected %s, got %s", want, msg) } diff --git a/beacon-chain/rpc/service.go b/beacon-chain/rpc/service.go index e87ae960d0..2797516bba 100644 --- a/beacon-chain/rpc/service.go +++ b/beacon-chain/rpc/service.go @@ -119,7 +119,7 @@ func (s *Service) Start() { if s.withCert != "" && s.withKey != "" { creds, err := credentials.NewServerTLSFromFile(s.withCert, s.withKey) if err != nil { - log.Errorf("could not load TLS keys: %s", err) + log.Errorf("Could not load TLS keys: %s", err) } s.grpcServer = grpc.NewServer(grpc.Creds(creds)) } else { diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index 1072057add..c792c477af 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -284,7 +284,7 @@ func (ss *Service) receiveAttestation(msg p2p.Message) { attestation, err := ss.db.GetAttestation(h) if err != nil { - log.Errorf("Can not check for attestation in DB: %v", err) + log.Errorf("Could not check for attestation in DB: %v", err) return } if attestation != nil { diff --git a/beacon-chain/types/active_state.go b/beacon-chain/types/active_state.go index 14d0b3f650..7d5c205749 100644 --- a/beacon-chain/types/active_state.go +++ b/beacon-chain/types/active_state.go @@ -324,7 +324,7 @@ func (a *ActiveState) CalculateNewActiveState( cState.LastStateRecalculationSlot(), parentSlot) if err != nil { - return nil, fmt.Errorf("Can not get proposer index %v", err) + return nil, fmt.Errorf("could not get proposer index %v", err) } newRandao := setRandaoMix(block.RandaoReveal(), a.RandaoMix()) diff --git a/beacon-chain/types/block.go b/beacon-chain/types/block.go index d7dbdcb0e3..3a749604f0 100644 --- a/beacon-chain/types/block.go +++ b/beacon-chain/types/block.go @@ -167,7 +167,7 @@ func (b *Block) IsValid( } if b.SlotNumber() == 0 { - log.Error("Cannot process a genesis block") + log.Error("Could not process a genesis block") return false } @@ -187,7 +187,7 @@ func (b *Block) IsValid( cState.LastStateRecalculationSlot(), b.SlotNumber()) if err != nil { - log.Errorf("Cannot get proposer index: %v", err) + log.Errorf("Could not get proposer index: %v", err) return false } @@ -205,7 +205,7 @@ func (b *Block) IsValid( func (b *Block) areAttestationsValid(db beaconDB, aState *ActiveState, cState *CrystallizedState, parentSlot uint64) bool { for index, attestation := range b.Attestations() { if !b.isAttestationValid(index, db, aState, cState, parentSlot) { - log.Errorf("attestation invalid: %v", attestation) + log.Errorf("Attestation invalid: %v", attestation) return false } } @@ -219,13 +219,13 @@ func (b *Block) doesParentProposerExist(cState *CrystallizedState, parentSlot ui cState.LastStateRecalculationSlot(), parentSlot) if err != nil { - log.Errorf("Cannot get proposer index: %v", err) + log.Errorf("Could not get proposer index: %v", err) return false } // verify proposer from last slot is in the first attestation object in AggregatedAttestation. if isBitSet, err := bitutil.CheckBit(b.Attestations()[0].AttesterBitfield, int(parentProposerIndex)); !isBitSet { - log.Errorf("Can not locate proposer in the first attestation of AttestionRecord %v", err) + log.Errorf("Could not locate proposer in the first attestation of AttestionRecord %v", err) return false } @@ -274,7 +274,7 @@ func (b *Block) isAttestationValid(attestationIndex int, db beaconDB, aState *Ac // Get all the block hashes up to cycle length. parentHashes, err := aState.getSignedParentHashes(b, attestation) if err != nil { - log.Errorf("unable to get signed parent hashes: %v", err) + log.Errorf("Unable to get signed parent hashes: %v", err) return false } diff --git a/validator/beacon/service.go b/validator/beacon/service.go index c0e419a532..2ea59ac8d5 100644 --- a/validator/beacon/service.go +++ b/validator/beacon/service.go @@ -122,7 +122,7 @@ func (s *Service) fetchCurrentAssignmentsAndGenesisTime(client pb.BeaconServiceC // since the genesis block. genesisTimestamp, err := ptypes.Timestamp(res.GetGenesisTimestamp()) if err != nil { - return fmt.Errorf("cannot compute genesis timestamp: %v", err) + return fmt.Errorf("could not compute genesis timestamp: %v", err) } s.genesisTimestamp = genesisTimestamp diff --git a/validator/types/shard.go b/validator/types/shard.go index 2566582ed2..7ed4040bf1 100644 --- a/validator/types/shard.go +++ b/validator/types/shard.go @@ -75,7 +75,7 @@ func (s *Shard) HeaderByHash(hash *common.Hash) (*CollationHeader, error) { func (s *Shard) CollationByHeaderHash(headerHash *common.Hash) (*Collation, error) { header, err := s.HeaderByHash(headerHash) if err != nil { - return nil, fmt.Errorf("cannot fetch header by hash: %v", err) + return nil, fmt.Errorf("could not fetch header by hash: %v", err) } if header == nil { @@ -84,12 +84,12 @@ func (s *Shard) CollationByHeaderHash(headerHash *common.Hash) (*Collation, erro body, err := s.BodyByChunkRoot(header.ChunkRoot()) if err != nil { - return nil, fmt.Errorf("cannot fetch body by chunk root: %v", err) + return nil, fmt.Errorf("could not fetch body by chunk root: %v", err) } txs, err := DeserializeBlobToTx(body) if err != nil { - return nil, fmt.Errorf("cannot deserialize body: %v", err) + return nil, fmt.Errorf("could not deserialize body: %v", err) } return NewCollation(header, body, *txs), nil } @@ -186,7 +186,7 @@ func (s *Shard) SaveHeader(header *CollationHeader) error { encoded, err := header.EncodeRLP() if err != nil { - return fmt.Errorf("cannot encode header: %v", err) + return fmt.Errorf("could not encode header: %v", err) } // uses the hash of the header as the key. @@ -240,7 +240,7 @@ func (s *Shard) SetCanonical(header *CollationHeader) error { key := canonicalCollationLookupKey(dbHeader.ShardID(), dbHeader.Period()) encoded, err := dbHeader.EncodeRLP() if err != nil { - return fmt.Errorf("cannot encode header: %v", err) + return fmt.Errorf("could not encode header: %v", err) } // sets the key to be the canonical collation lookup key and val as RLP encoded // collation header. diff --git a/validator/types/shard_test.go b/validator/types/shard_test.go index e256801c03..b2f875124e 100644 --- a/validator/types/shard_test.go +++ b/validator/types/shard_test.go @@ -85,7 +85,7 @@ func TestShard_HeaderByHash(t *testing.T) { errorShard := NewShard(big.NewInt(1), mockDB) if err := shard.SaveHeader(header); err != nil { - t.Fatalf("cannot save collation header: %v", err) + t.Fatalf("could not save collation header: %v", err) } hash := header.Hash() @@ -150,7 +150,7 @@ func TestShard_CollationByHeaderHash(t *testing.T) { // properly saves the collation. if err := shard.SaveCollation(collation); err != nil { - t.Fatalf("cannot save collation: %v", err) + t.Fatalf("could not save collation: %v", err) } dbCollation, err := shard.CollationByHeaderHash(&hash) @@ -215,7 +215,7 @@ func TestShard_CanonicalHeaderHash(t *testing.T) { // should not be able to set as canonical before saving the header and body first. if err := shard.SetCanonical(header); err == nil { - t.Errorf("cannot set as canonical before saving header and body first") + t.Errorf("could not set as canonical before saving header and body first") } if err := shard.SaveCollation(collation); err != nil { @@ -317,7 +317,7 @@ func TestShard_BodyByChunkRoot(t *testing.T) { shard := NewShard(shardID, shardDB) if err := shard.SaveBody(body); err != nil { - t.Fatalf("cannot save body: %v", err) + t.Fatalf("could not save body: %v", err) } chunks := Chunks(body) // wrapper allowing us to merklizing the chunks. @@ -325,7 +325,7 @@ func TestShard_BodyByChunkRoot(t *testing.T) { dbBody, err := shard.BodyByChunkRoot(&chunkRoot) if err != nil { - t.Errorf("cannot fetch body by chunk root: %v", err) + t.Errorf("could not fetch body by chunk root: %v", err) } // it should throw error if fetching non-existent chunk root. @@ -369,11 +369,11 @@ func TestShard_CheckAvailability(t *testing.T) { // should throw error if checking availability before header is even saved. if _, err := shard.CheckAvailability(header); err == nil { - t.Errorf("error should be thrown: cannot check availability before saving header first") + t.Errorf("error should be thrown: could not check availability before saving header first") } if err := shard.SaveBody(collation.body); err != nil { - t.Fatalf("cannot save body: %v", err) + t.Fatalf("could not save body: %v", err) } available, err := shard.CheckAvailability(header) @@ -439,7 +439,7 @@ func TestShard_SaveCollation(t *testing.T) { collation.CalculateChunkRoot() if err := shard.SaveCollation(collation); err == nil { - t.Errorf("cannot save collation in shard with wrong shardID") + t.Errorf("could not save collation in shard with wrong shardID") } }