From cf17671f304a748d5e51d92505eb33cb77981a17 Mon Sep 17 00:00:00 2001 From: Francisco de Borja Aranda Castillejo Date: Thu, 12 Sep 2024 14:10:33 +0200 Subject: [PATCH] fixes using time.Since --- app/app.go | 6 ++++++ e2e/e2etests/test_rate_limiter.go | 4 ++-- e2e/e2etests/test_stress_btc_deposit.go | 2 +- e2e/e2etests/test_stress_btc_withdraw.go | 2 +- e2e/e2etests/test_stress_eth_deposit.go | 2 +- e2e/e2etests/test_stress_eth_withdraw.go | 2 +- precompiles/types/errors_test.go | 4 ++-- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/app.go b/app/app.go index cc271fc35f..4eeaa16fa7 100644 --- a/app/app.go +++ b/app/app.go @@ -93,6 +93,7 @@ import ( "github.com/zeta-chain/node/docs/openapi" zetamempool "github.com/zeta-chain/node/pkg/mempool" "github.com/zeta-chain/node/precompiles" + bankprecompile "github.com/zeta-chain/node/precompiles/bank" srvflags "github.com/zeta-chain/node/server/flags" authoritymodule "github.com/zeta-chain/node/x/authority" authoritykeeper "github.com/zeta-chain/node/x/authority/keeper" @@ -1065,6 +1066,11 @@ func (app *App) BlockedAddrs() map[string]bool { // Each enabled precompiled stateful contract should be added as a BlockedAddrs. // That way it's marked as non payable by the bank keeper. for addr, enabled := range precompiles.EnabledStatefulContracts { + // bank precompile has to be able to receive funds. + if addr == bankprecompile.ContractAddress { + continue + } + if enabled { blockList[addr.String()] = enabled } diff --git a/e2e/e2etests/test_rate_limiter.go b/e2e/e2etests/test_rate_limiter.go index c2e10551aa..e74691e1bd 100644 --- a/e2e/e2etests/test_rate_limiter.go +++ b/e2e/e2etests/test_rate_limiter.go @@ -122,7 +122,7 @@ func createAndWaitWithdraws(r *runner.E2ERunner, withdrawType withdrawType, with return err } - duration := time.Now().Sub(startTime).Seconds() + duration := time.Since(startTime).Seconds() block, err := r.ZEVMClient.BlockNumber(r.Ctx) if err != nil { return fmt.Errorf("error getting block number: %w", err) @@ -155,7 +155,7 @@ func waitForWithdrawMined( } // record the time for completion - duration := time.Now().Sub(startTime).Seconds() + duration := time.Since(startTime).Seconds() block, err := r.ZEVMClient.BlockNumber(ctx) if err != nil { return err diff --git a/e2e/e2etests/test_stress_btc_deposit.go b/e2e/e2etests/test_stress_btc_deposit.go index 25b89088ac..53caea09df 100644 --- a/e2e/e2etests/test_stress_btc_deposit.go +++ b/e2e/e2etests/test_stress_btc_deposit.go @@ -53,7 +53,7 @@ func monitorBTCDeposit(r *runner.E2ERunner, hash *chainhash.Hash, index int, sta cctx.Index, ) } - timeToComplete := time.Now().Sub(startTime) + timeToComplete := time.Since(startTime) r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String()) return nil diff --git a/e2e/e2etests/test_stress_btc_withdraw.go b/e2e/e2etests/test_stress_btc_withdraw.go index 6e212c97e3..79cf1ae773 100644 --- a/e2e/e2etests/test_stress_btc_withdraw.go +++ b/e2e/e2etests/test_stress_btc_withdraw.go @@ -66,7 +66,7 @@ func monitorBTCWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index int cctx.Index, ) } - timeToComplete := time.Now().Sub(startTime) + timeToComplete := time.Since(startTime) r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String()) return nil diff --git a/e2e/e2etests/test_stress_eth_deposit.go b/e2e/e2etests/test_stress_eth_deposit.go index 19676c9cba..29abb76ba0 100644 --- a/e2e/e2etests/test_stress_eth_deposit.go +++ b/e2e/e2etests/test_stress_eth_deposit.go @@ -52,7 +52,7 @@ func monitorEtherDeposit(r *runner.E2ERunner, hash ethcommon.Hash, index int, st cctx.Index, ) } - timeToComplete := time.Now().Sub(startTime) + timeToComplete := time.Since(startTime) r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String()) return nil diff --git a/e2e/e2etests/test_stress_eth_withdraw.go b/e2e/e2etests/test_stress_eth_withdraw.go index 98fa8e8783..337a4d416d 100644 --- a/e2e/e2etests/test_stress_eth_withdraw.go +++ b/e2e/e2etests/test_stress_eth_withdraw.go @@ -70,7 +70,7 @@ func monitorEtherWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index i cctx.Index, ) } - timeToComplete := time.Now().Sub(startTime) + timeToComplete := time.Since(startTime) r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String()) return nil diff --git a/precompiles/types/errors_test.go b/precompiles/types/errors_test.go index bee953f1a2..4fa3bc72e2 100644 --- a/precompiles/types/errors_test.go +++ b/precompiles/types/errors_test.go @@ -4,7 +4,7 @@ import "testing" func Test_ErrInvalidAddr(t *testing.T) { e := ErrInvalidAddr{ - Got: "foo", + Got: "foo", Reason: "bar", } got := e.Error() @@ -82,4 +82,4 @@ func Test_ErrUnexpected(t *testing.T) { if got != expect { t.Errorf("Expected %v, got %v", expect, got) } -} \ No newline at end of file +}