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
4 changes: 4 additions & 0 deletions pkg/solana/ccip/codec/extradatacodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (d ExtraDataDecoder) DecodeExtraArgsToMap(extraArgs ccipocr3.Bytes) (map[st

// DecodeDestExecDataToMap is a helper function for converting dest exec data bytes into map[string]any
func (d ExtraDataDecoder) DecodeDestExecDataToMap(destExecData ccipocr3.Bytes) (map[string]any, error) {
if len(destExecData) < 4 {
return nil, fmt.Errorf("dest exec data too short: %d, should be at least 4 bytes", len(destExecData))
}

return map[string]any{
svmDestExecDataKey: binary.BigEndian.Uint32(destExecData),
}, nil
Expand Down
7 changes: 7 additions & 0 deletions pkg/solana/ccip/codec/extradatacodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ func Test_decodeExtraArgs(t *testing.T) {
require.Equal(t, destGasAmount, decoded)
})

t.Run("decode dest exec data errors on short input", func(t *testing.T) {
for _, encoded := range [][]byte{nil, {}, {0x1}, {0x1, 0x2, 0x3}} {
_, err := extraDataDecoder.DecodeDestExecDataToMap(encoded)
require.Error(t, err)
}
})

t.Run("decode extra args into map svm", func(t *testing.T) {
destGasAmount := uint32(10000)
bitmap := uint64(0)
Expand Down
Loading