Skip to content

Commit

Permalink
ErrDecodeValue -> ErrDecodeStorageValue
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 18, 2022
1 parent aaec80f commit 39c7043
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions internal/trie/node/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

var (
// ErrDecodeValue is defined since no sentinel error is defined
// ErrDecodeStorageValue is defined since no sentinel error is defined
// in the scale package.
// TODO remove once the following issue is done:
// https://github.com/ChainSafe/gossamer/issues/2631 .
ErrDecodeValue = errors.New("cannot decode value")
ErrDecodeStorageValue = errors.New("cannot decode value")
ErrReadChildrenBitmap = errors.New("cannot read children bitmap")
// ErrDecodeChildHash is defined since no sentinel error is defined
// in the scale package.
Expand Down Expand Up @@ -85,7 +85,7 @@ func decodeBranch(reader io.Reader, variant byte, partialKeyLength uint16) (
if variant == branchWithValueVariant.bits {
err := sd.Decode(&node.StorageValue)
if err != nil {
return nil, fmt.Errorf("%w: %s", ErrDecodeValue, err)
return nil, fmt.Errorf("%w: %s", ErrDecodeStorageValue, err)
}
}

Expand Down Expand Up @@ -135,7 +135,7 @@ func decodeLeaf(reader io.Reader, partialKeyLength uint16) (node *Node, err erro
var value []byte
err = sd.Decode(&value)
if err != nil && !errors.Is(err, io.EOF) {
return nil, fmt.Errorf("%w: %s", ErrDecodeValue, err)
return nil, fmt.Errorf("%w: %s", ErrDecodeStorageValue, err)
}

if len(value) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions internal/trie/node/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func Test_decodeBranch(t *testing.T) {
),
variant: branchWithValueVariant.bits,
partialKeyLength: 1,
errWrapped: ErrDecodeValue,
errWrapped: ErrDecodeStorageValue,
errMessage: "cannot decode value: reading byte: EOF",
},
"success for branch with value": {
Expand Down Expand Up @@ -324,7 +324,7 @@ func Test_decodeLeaf(t *testing.T) {
}),
variant: leafVariant.bits,
partialKeyLength: 1,
errWrapped: ErrDecodeValue,
errWrapped: ErrDecodeStorageValue,
errMessage: "cannot decode value: unknown prefix for compact uint: 255",
},
"missing value data": {
Expand Down

0 comments on commit 39c7043

Please sign in to comment.