Skip to content
35 changes: 28 additions & 7 deletions encoding/ccf/ccf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2582,7 +2582,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 @@ -2682,7 +2685,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 @@ -10921,7 +10927,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 @@ -10952,7 +10961,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 @@ -12816,7 +12828,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 @@ -12874,7 +12889,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 @@ -12932,7 +12950,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