Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions encoding/ccf/ccf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2583,7 +2583,10 @@ func TestDecodeWord128Invalid(t *testing.T) {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
})
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: failed to decode Word128: cbor: cannot decode CBOR tag type to big.Int", err.Error())
assert.ErrorContains(t,
err,
"failed to decode Word128: cbor: cannot decode CBOR tag type to big.Int",
)
}
}

Expand Down Expand Up @@ -2683,7 +2686,10 @@ func TestDecodeWord256Invalid(t *testing.T) {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
})
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: failed to decode Word256: cbor: cannot decode CBOR tag type to big.Int", err.Error())
assert.ErrorContains(t,
err,
"failed to decode Word256: cbor: cannot decode CBOR tag type to big.Int",
)
}
}

Expand Down Expand Up @@ -10922,7 +10928,10 @@ func TestEncodeType(t *testing.T) {

_, err := ccf.Decode(nil, encodedData)
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: unexpected empty intersection type", err.Error())
assert.ErrorContains(t,
err,
"unexpected empty intersection type",
)

})

Expand Down Expand Up @@ -10953,7 +10962,10 @@ func TestEncodeType(t *testing.T) {

_, err := ccf.Decode(nil, encodedData)
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: unexpected empty intersection type", err.Error())
assert.ErrorContains(t,
err,
"unexpected empty intersection type",
)
})

t.Run("with static intersection type", func(t *testing.T) {
Expand Down Expand Up @@ -12817,7 +12829,10 @@ func TestDecodeInvalidType(t *testing.T) {
for _, dm := range decModes {
_, err := dm.Decode(nil, encodedData)
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: invalid type ID for built-in: ``", err.Error())
assert.ErrorContains(t,
err,
"invalid type ID for built-in: ``",
)
}
})

Expand Down Expand Up @@ -12875,7 +12890,10 @@ func TestDecodeInvalidType(t *testing.T) {
for _, dm := range decModes {
_, err := dm.Decode(nil, encodedData)
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: invalid type ID `I`: invalid identifier location type ID: missing location", err.Error())
assert.ErrorContains(t,
err,
"invalid type ID `I`: invalid identifier location type ID: missing location",
)
}
})

Expand Down Expand Up @@ -12933,7 +12951,10 @@ func TestDecodeInvalidType(t *testing.T) {
for _, dm := range decModes {
_, err := dm.Decode(nil, encodedData)
require.Error(t, err)
assert.Equal(t, "ccf: failed to decode: invalid type ID for built-in: `N.PublicKey`", err.Error())
assert.ErrorContains(t,
err,
"invalid type ID for built-in: `N.PublicKey`",
)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions encoding/ccf/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
default:
err := decodeCBORTagWithKnownNumber(d.dec, CBORTagTypeAndValue)
if err != nil {
return nil, fmt.Errorf("unexpected encoded value of Cadence type %s (%T): %s", t.ID(), t, err.Error())
return nil, fmt.Errorf("unexpected encoded value of Cadence type %s (%T): %w", t.ID(), t, err)
}

// Decode ccf-type-and-value-message.
Expand Down Expand Up @@ -1538,7 +1538,7 @@ func (d *Decoder) decodeCapability(typ *cadence.CapabilityType, types *cadenceTy
if nextType == cbor.TagType {
err := decodeCBORTagWithKnownNumber(d.dec, CBORTagTypeAndValue)
if err != nil {
return nil, fmt.Errorf("unexpected encoded value of Cadence type %s (%T): %s", typ.ID(), typ, err.Error())
return nil, fmt.Errorf("unexpected encoded value of Cadence type %s (%T): %w", typ.ID(), typ, err)
}

// Decode ccf-type-and-value-message.
Expand Down
Loading
Loading