diff --git a/x/dex/types/message_deposit.go b/x/dex/types/message_deposit.go index 841b0328e..aa097c823 100644 --- a/x/dex/types/message_deposit.go +++ b/x/dex/types/message_deposit.go @@ -71,7 +71,8 @@ func (msg *MsgDeposit) ValidateBasic() error { numDeposits := len(msg.AmountsA) if numDeposits != len(msg.Fees) || numDeposits != len(msg.TickIndexesAToB) || - numDeposits != len(msg.AmountsB) { + numDeposits != len(msg.AmountsB) || + numDeposits != len(msg.Options) { return ErrUnbalancedTxArray } if numDeposits == 0 { diff --git a/x/dex/types/message_deposit_test.go b/x/dex/types/message_deposit_test.go index 33c8baf35..179e30c8d 100644 --- a/x/dex/types/message_deposit_test.go +++ b/x/dex/types/message_deposit_test.go @@ -24,6 +24,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { TickIndexesAToB: []int64{0}, AmountsA: []math.Int{math.OneInt()}, AmountsB: []math.Int{math.OneInt()}, + Options: []*DepositOptions{{false}}, }, err: ErrInvalidAddress, }, @@ -36,6 +37,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { TickIndexesAToB: []int64{0}, AmountsA: []math.Int{math.OneInt()}, AmountsB: []math.Int{math.OneInt()}, + Options: []*DepositOptions{{false}}, }, err: ErrInvalidAddress, }, @@ -48,6 +50,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { TickIndexesAToB: []int64{}, AmountsA: []math.Int{}, AmountsB: []math.Int{}, + Options: []*DepositOptions{{false}}, }, err: ErrUnbalancedTxArray, }, @@ -99,6 +102,19 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { }, err: ErrZeroDeposit, }, + { + name: "invalid duplicate deposit", + msg: MsgDeposit{ + Creator: sample.AccAddress(), + Receiver: sample.AccAddress(), + Fees: []uint64{1, 2, 1}, + TickIndexesAToB: []int64{0, 0, 0}, + AmountsA: []math.Int{math.OneInt(), math.OneInt(), math.OneInt()}, + AmountsB: []math.Int{math.OneInt(), math.OneInt(), math.OneInt()}, + Options: []*DepositOptions{{false}, {false}, {false}}, + }, + err: ErrDuplicatePoolDeposit, + }, { name: "invalid no deposit", msg: MsgDeposit{ @@ -108,6 +124,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { TickIndexesAToB: []int64{0}, AmountsA: []math.Int{math.ZeroInt()}, AmountsB: []math.Int{math.ZeroInt()}, + Options: []*DepositOptions{{false}}, }, err: ErrZeroDeposit, }, @@ -120,6 +137,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) { TickIndexesAToB: []int64{0}, AmountsA: []math.Int{math.OneInt()}, AmountsB: []math.Int{math.OneInt()}, + Options: []*DepositOptions{{false}}, }, }, }