-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tunnel-ibc' into tunnel-ibc-hook
- Loading branch information
Showing
10 changed files
with
423 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package tunnel_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" | ||
"github.com/bandprotocol/chain/v3/x/tunnel" | ||
"github.com/bandprotocol/chain/v3/x/tunnel/types" | ||
) | ||
|
||
func TestPacketDataUnmarshalerInterface(t *testing.T) { | ||
var ( | ||
data []byte | ||
expPacketData types.TunnelPricesPacketData | ||
) | ||
|
||
testCases := []struct { | ||
name string | ||
malleate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"invalid packet data", | ||
func() { | ||
data = []byte("invalid packet data") | ||
}, | ||
false, | ||
}, | ||
{ | ||
"all good", | ||
func() { | ||
expPacketData = types.TunnelPricesPacketData{ | ||
TunnelID: 1, | ||
Sequence: 1, | ||
Prices: []feedstypes.Price{ | ||
{Status: feedstypes.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "BTC", Price: 50000}, | ||
}, | ||
CreatedAt: 1633024800, | ||
} | ||
data = expPacketData.GetBytes() | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tc.malleate() | ||
|
||
packetData, err := tunnel.IBCModule{}.UnmarshalPacketData(data) | ||
|
||
if tc.expPass { | ||
require.NoError(t, err) | ||
require.Equal(t, expPacketData, packetData) | ||
} else { | ||
require.Error(t, err) | ||
require.Nil(t, packetData) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.