fixed error strings (#708)

This commit is contained in:
terence tsao
2018-10-31 23:05:55 +01:00
committed by Raul Jordan
parent 95625629f7
commit 80d6c60769
11 changed files with 30 additions and 30 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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")
}
}