Unverified Commit 40431ef6 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub
Browse files

fix: MsgBeginUnlocking bug (#2746) (#2748)

* fix unlocking bug

* explicitly allow empty coins

* added fixes

* remove white space

(cherry picked from commit 0997049b

)

Co-authored-by: default avatarAdam Tucker <adam@osmosis.team>
parent d7ed36f5
Showing with 14 additions and 4 deletions
+14 -4
......@@ -111,12 +111,12 @@ func (m MsgBeginUnlocking) ValidateBasic() error {
return fmt.Errorf("invalid lockup ID, got %v", m.ID)
}
// only allow unlocks with a single denom
if m.Coins.Len() != 1 {
// only allow unlocks with a single denom or empty
if m.Coins.Len() > 1 {
return fmt.Errorf("can only unlock one denom per lock ID, got %v", m.Coins)
}
if !m.Coins.IsAllPositive() {
if !m.Coins.Empty() && !m.Coins.IsAllPositive() {
return fmt.Errorf("cannot unlock a zero or negative amount")
}
......
......@@ -167,12 +167,22 @@ func TestMsgBeginUnlocking(t *testing.T) {
},
},
{
name: "not positive coins amount",
name: "zero coins (same as nil)",
msg: types.MsgBeginUnlocking{
Owner: addr1,
ID: 1,
Coins: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(0))),
},
expectPass: true,
},
{
name: "nil coins (unlock by ID)",
msg: types.MsgBeginUnlocking{
Owner: addr1,
ID: 1,
Coins: sdk.NewCoins(),
},
expectPass: true,
},
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment