Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCIP-2219 USDC Support - Stubbing interfaces and new flow #117

Merged
merged 13 commits into from
Sep 16, 2024
Prev Previous commit
Next Next commit
Config improvements
  • Loading branch information
mateusz-sekara committed Sep 16, 2024
commit 8e7970683109e4899b61bd1b5431cd3fb117386f
124 changes: 124 additions & 0 deletions execute/exectypes/observation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package exectypes

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

func Test_MessageTokensData(t *testing.T) {
tests := []struct {
name string
msgTokenData MessageTokensData
ready bool
error error
}{
{
name: "empty MessageTokenData is always ready - message doesnt carry tokens",
msgTokenData: MessageTokensData{},
ready: true,
error: nil,
},
{
name: "MessageTokenData is ready - all tokens are ready",
msgTokenData: MessageTokensData{
TokenData: []TokenData{
{
Ready: true,
Data: []byte{123},
},
{
Ready: true,
Data: []byte{234},
},
},
},
ready: true,
error: nil,
},
{
name: "MessageTokenData is not ready - one token is not ready",
msgTokenData: MessageTokensData{
TokenData: []TokenData{
{
Ready: true,
Data: []byte{123},
},
{
Ready: false,
Data: nil,
Error: fmt.Errorf("some error"),
},
},
},
ready: false,
error: fmt.Errorf("some error"),
},
{
name: "MessageTokenData is not ready - all tokens are not ready, first error is returned",
msgTokenData: MessageTokensData{
TokenData: []TokenData{
{
Ready: false,
Data: nil,
Error: fmt.Errorf("error1"),
},
{
Ready: false,
Data: nil,
Error: fmt.Errorf("error2"),
},
},
},
ready: false,
error: fmt.Errorf("error1"),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.ready, tt.msgTokenData.IsReady())
assert.Equal(t, tt.error, tt.msgTokenData.Error())
})
}
}

func Test_MessageTokensData_ToByteSlice(t *testing.T) {
tests := []struct {
name string
msgTokenData MessageTokensData
expected [][]byte
}{
{
name: "empty MessageTokenData is always ready - message doesnt carry tokens",
msgTokenData: MessageTokensData{},
expected: [][]byte{},
},
{
name: "MessageTokenData is ready - all tokens are ready",
msgTokenData: MessageTokensData{
TokenData: []TokenData{
{
Ready: true,
Data: []byte{123},
},
{
Ready: true,
Data: []byte{234},
},
},
},
expected: [][]byte{
{123},
{234},
},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.expected, tt.msgTokenData.ToByteSlice())
})
}
}
Loading