update vest-calc tests with a short 20sec period

master
michael 2022-09-14 23:59:41 +00:00
parent 72757b3c18
commit f3ddfca045
1 changed files with 17 additions and 1 deletions

View File

@ -60,7 +60,7 @@ func TestLinearVesting(t *testing.T) {
// Total: 1000 tokens // Total: 1000 tokens
// Time: end // Time: end
// Claimed: 1000 // Claimed: 1000
// Expected: 1000 // Expected: 0
if res, err := CalcAmountVestableLinear( if res, err := CalcAmountVestableLinear(
big.NewInt(1000), big.NewInt(1000),
big.NewInt(0), big.NewInt(0),
@ -105,8 +105,24 @@ func TestLinearVesting(t *testing.T) {
expectEq(res, 416) expectEq(res, 416)
} }
// Total: 1000 tokens
// Time: 20 sec in of a 3700sec lease
// Claimed: 1000
// Expected: 0
if res, err := CalcAmountVestableLinear(
big.NewInt(1000),
big.NewInt(1000),
time.Now(),
time.Unix(time.Now().Unix()-20, 0),
time.Unix(time.Now().Unix()+3680, 0),
); err != nil {
panic(err)
} else {
expectEq(res, 5)
}
} }
// Compare a bigint output to its expected int value
func expectEq(a *big.Int, b int) { func expectEq(a *big.Int, b int) {
a2 := int(a.Uint64()) a2 := int(a.Uint64())
if a2 != b { if a2 != b {