Skip to content

Commit

Permalink
test(vesting): add vesting_account test for cliff spendable coins
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed May 16, 2024
1 parent a2a8807 commit 54ac0b8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions x/vesting/types/vesting_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,36 @@ func TestGetVestingCoinsCliffVestingAcc(t *testing.T) {
require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, vestingCoins)
}

func TestSpendableCoinsCliffVestingAcc(t *testing.T) {
now := tmtime.Now()
cliffTime := now.Add(12 * time.Hour)
endTime := now.Add(24 * time.Hour)

bacc, origCoins := initBaseAccount()
cva, err := types.NewCliffVestingAccount(bacc, origCoins, now.Unix(), cliffTime.Unix(), endTime.Unix())
require.NoError(t, err)

// require all coins are locked at the beginning of the vesting schedule
lockedCoins := cva.LockedCoins(now)
require.Equal(t, origCoins, lockedCoins)

// require all coins are locked before the cliff time but after the beginning
lockedCoins = cva.LockedCoins(now.Add(6 * time.Hour))
require.Equal(t, origCoins, lockedCoins)

// require no coins are locked at the end of the vesting schedule
lockedCoins = cva.LockedCoins(endTime)
require.Equal(t, sdk.NewCoins(), lockedCoins)

// require 50% of coins are locked at the cliff time
lockedCoins = cva.LockedCoins(cliffTime.Add(1 * time.Second))
require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins)

// require 25% of coins are locked
lockedCoins = cva.LockedCoins(now.Add(18 * time.Hour))
require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 250), sdk.NewInt64Coin(stakeDenom, 25)}, lockedCoins)
}

func TestTrackDelegationCliffVestingAcc(t *testing.T) {
now := tmtime.Now()
cliffTime := now.Add(12 * time.Hour)
Expand Down

0 comments on commit 54ac0b8

Please sign in to comment.