Skip to content

Commit

Permalink
feat: test cases for vault (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s authored Jan 11, 2023
1 parent 1635a7d commit 95f36d6
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion 007-vault/contract_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func Test(t *testing.T) {
test1 := std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5")
test2 := testutils.TestAddress("test2")
test3 := testutils.TestAddress("test3")
std.TestSetOrigCaller(test1)

// check token metadata.
Expand Down Expand Up @@ -52,5 +53,52 @@ func Test(t *testing.T) {
}
}

// TODO: test the vault.
// test1 deposits 300 with an unlock duration of 100 blocks default.
std.TestSetOrigCaller(test1)
Deposit(300, test3)

// check balance of test1.
{
got, _ := FooToken.BalanceOf(test1)
expected := 99998700
if got != expected {
t.Fatalf("expected %d, got %d.", expected, got)
}
}

// check balance of valut pkgs.
{
got, _ := FooToken.BalanceOf(std.GetOrigPkgAddr())
expected := 300
if got != expected {
t.Fatalf("expected %d, got %d.", expected, got)
}
}

// test1 calls unvalut for 50 tokens
// and wait 101 blocks
// then redeem it
Unvault(50)
std.TestSkipHeights(101)
Redeem(50)

// check balance of test1.
{
got, _ := FooToken.BalanceOf(test1)
expected := 99998750
if got != expected {
t.Fatalf("expected %d, got %d.", expected, got)
}
}

// check balance of valut pkgs.
{
got, _ := FooToken.BalanceOf(std.GetOrigPkgAddr())
expected := 250
if got != expected {
t.Fatalf("expected %d, got %d.", expected, got)
}
}

// TODO: additional test case(s) func Recover().
}

0 comments on commit 95f36d6

Please sign in to comment.