forked from osmosis-labs/fee-abstraction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_memo_test.go
48 lines (37 loc) · 1.48 KB
/
build_memo_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package types_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/types"
)
// TODO: need to refactor this test, use driven table
func TestParseMsgToMemo(t *testing.T) {
twapRouter := types.TwapRouter{
SlippagePercentage: "20",
WindowSeconds: 10,
}
swap := types.Swap{
OutPutDenom: "khanhyeuchau",
Slippage: types.Twap{Twap: twapRouter},
Receiver: "123456",
}
msgSwap := types.OsmosisSwapMsg{
OsmosisSwap: swap,
}
mockAddress := "cosmos123456789"
// TODO: need to check assert msg
_, err := types.ParseMsgToMemo(msgSwap, mockAddress)
require.NoError(t, err)
}
// TODO: need to refactor this test, use driven table
func TestParseCrossChainSwapMsgToMemo(t *testing.T) {
outPutDenom := "uosmo"
contractAddress := "osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg"
mockReceiver := "feeabs1efd63aw40lxf3n4mhf7dzhjkr453axurwrhrrw"
chainName := "feeabs"
execeptedMemoStr := `{"wasm":{"contract":"osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg","msg":{"osmosis_swap":{"output_denom":"uosmo","slippage":{"twap":{"slippage_percentage":"20","window_seconds":10}},"receiver":"feeabs/feeabs1efd63aw40lxf3n4mhf7dzhjkr453axurwrhrrw","on_failed_delivery":"do_nothing"}}}}`
// TODO: need to check assert msg
memoStr, err := types.BuildCrossChainSwapMemo(outPutDenom, contractAddress, mockReceiver, chainName)
require.NoError(t, err)
require.Equal(t, execeptedMemoStr, memoStr)
}