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

AddCommittedToken was edited to avoid amount duplicate on Lockup #476

Merged
merged 10 commits into from
May 16, 2024
1 change: 0 additions & 1 deletion x/commitment/types/commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (c *Commitments) AddCommittedTokens(denom string, amount math.Int, unlockTi
li++
continue
} else if lockup.UnlockTimestamp == unlockTime {
c.CommittedTokens[i].Lockups[li].Amount = lockup.Amount.Add(amount)
fenriz07 marked this conversation as resolved.
Show resolved Hide resolved
return
} else {
break
Expand Down
9 changes: 9 additions & 0 deletions x/commitment/types/commitments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ func TestCommitments_AddCommittedTokens(t *testing.T) {
require.Equal(t, commitments.CommittedTokens[0].Lockups[0].Amount.String(), "100")
require.Equal(t, commitments.CommittedTokens[0].Lockups[0].UnlockTimestamp, uint64(100))
require.Len(t, commitments.CommittedTokens[1].Lockups, 1)

commitments.AddCommittedTokens("lp/3", sdk.NewInt(1000), 100)
commitments.AddCommittedTokens("lp/3", sdk.NewInt(2000), 120)
commitments.AddCommittedTokens("lp/3", sdk.NewInt(3000), 130)

require.Equal(t, commitments.CommittedTokens[2].Lockups[0].Amount.String(), "1000")
require.Equal(t, commitments.CommittedTokens[2].Lockups[1].Amount.String(), "2000")
require.Equal(t, commitments.CommittedTokens[2].Lockups[2].Amount.String(), "3000")

}

func TestCommitments_WithdrawCommitedTokens(t *testing.T) {
Expand Down
Loading