diff --git a/tests/rewards/node_test.go b/tests/rewards/node_test.go index b8f9885d..1ab1c2e4 100644 --- a/tests/rewards/node_test.go +++ b/tests/rewards/node_test.go @@ -46,7 +46,8 @@ func TestNodeRewards(t *testing.T) { } // Mine blocks until node claims are possible - if err := evm.MineBlocks(10); err != nil { t.Fatal(err) } + if err := evm.MineBlocks(5); err != nil { t.Fatal(err) } + if err := evm.IncreaseTime(5 * secondsPerBlock); err != nil { t.Fatal(err) } // Get & check updated node claim possible status if nodeClaimPossible, err := rewards.GetNodeClaimPossible(rp, nodeAccount.Address, nil); err != nil { @@ -88,6 +89,7 @@ func TestNodeRewards(t *testing.T) { // Mine blocks until rewards are available if err := evm.MineBlocks(10); err != nil { t.Fatal(err) } + if err := evm.IncreaseTime(10 * secondsPerBlock); err != nil { t.Fatal(err) } // Get & check updated node claim rewards amount if rewardsAmount, err := rewards.GetNodeClaimRewardsAmount(rp, nodeAccount.Address, nil); err != nil { diff --git a/tests/rewards/trusted_node_test.go b/tests/rewards/trusted_node_test.go index 2b0910b0..be087792 100644 --- a/tests/rewards/trusted_node_test.go +++ b/tests/rewards/trusted_node_test.go @@ -45,6 +45,7 @@ func TestTrustedNodeRewards(t *testing.T) { // Mine blocks until trusted node claims are possible if err := evm.MineBlocks(5); err != nil { t.Fatal(err) } + if err := evm.IncreaseTime(5 * secondsPerBlock); err != nil { t.Fatal(err) } // Get & check updated trusted node claim possible status if nodeClaimPossible, err := rewards.GetTrustedNodeClaimPossible(rp, trustedNodeAccount.Address, nil); err != nil { @@ -76,6 +77,7 @@ func TestTrustedNodeRewards(t *testing.T) { // Mine blocks until rewards are available if err := evm.MineBlocks(10); err != nil { t.Fatal(err) } + if err := evm.IncreaseTime(10 * secondsPerBlock); err != nil { t.Fatal(err) } // Get & check updated trusted node claim rewards amount if rewardsAmount, err := rewards.GetTrustedNodeClaimRewardsAmount(rp, trustedNodeAccount.Address, nil); err != nil { diff --git a/tests/testutils/evm/mining.go b/tests/testutils/evm/mining.go index 78a72c59..e205482e 100644 --- a/tests/testutils/evm/mining.go +++ b/tests/testutils/evm/mining.go @@ -1,12 +1,11 @@ package evm import ( - "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/rpc" - "github.com/rocket-pool/rocketpool-go/tests" + "github.com/rocket-pool/rocketpool-go/tests" ) - // Mine a number of blocks func MineBlocks(numBlocks int) error { @@ -24,3 +23,19 @@ func MineBlocks(numBlocks int) error { } + +// Fast forward to some number of seconds +func IncreaseTime(time uint64) error { + + // Initialize RPC client + client, err := rpc.Dial(tests.Eth1ProviderAddress) + if err != nil { return err } + + // Make RPC calls + if err := client.Call(nil, "evm_increaseTime", time); err != nil { return err } + + // Return + return nil + +} + diff --git a/tests/tokens/rpl_test.go b/tests/tokens/rpl_test.go index 9b2445ca..c397558d 100644 --- a/tests/tokens/rpl_test.go +++ b/tests/tokens/rpl_test.go @@ -129,6 +129,7 @@ func TestMintInflationRPL(t *testing.T) { // Mine blocks until rewards are available if err := evm.MineBlocks(10); err != nil { t.Fatal(err) } + if err := evm.IncreaseTime(10 * secondsPerBlock); err != nil { t.Fatal(err) } // Get initial total supply rplTotalSupply1, err := tokens.GetRPLTotalSupply(rp, nil)