From 906c4385dc3889e23e314318e29432e95cce69cc Mon Sep 17 00:00:00 2001 From: Francisco de Borja Aranda Castillejo Date: Tue, 20 Aug 2024 11:12:15 +0200 Subject: [PATCH] apply code review fixes --- app/app.go | 2 + changelog.md | 5 +- cmd/zetae2e/local/precompiles.go | 14 +++--- codecov.yml | 86 ++++++++++++++++---------------- e2e/config/config.go | 1 + e2e/e2etests/e2etests.go | 2 +- 6 files changed, 58 insertions(+), 52 deletions(-) diff --git a/app/app.go b/app/app.go index 71188d3eb7..32d85214eb 100644 --- a/app/app.go +++ b/app/app.go @@ -1056,6 +1056,8 @@ func (app *App) BlockedAddrs() map[string]bool { blockList[addr.String()] = v } + // 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 { if enabled { blockList[addr.String()] = enabled diff --git a/changelog.md b/changelog.md index 7ef55517f7..fcd82cffe7 100644 --- a/changelog.md +++ b/changelog.md @@ -18,6 +18,10 @@ * [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module +### Tests + +* [2703](https://github.com/zeta-chain/node/pull/2703) - add e2e tests for stateful precompiled contracts + ## v19.0.0 ### Breaking Changes @@ -115,7 +119,6 @@ * [2415](https://github.com/zeta-chain/node/pull/2415) - add e2e test for upgrade and test admin functionalities * [2440](https://github.com/zeta-chain/node/pull/2440) - Add e2e test for TSS migration * [2473](https://github.com/zeta-chain/node/pull/2473) - add e2e tests for most used admin transactions -* [2703](https://github.com/zeta-chain/node/pull/2703) - add e2e tests for stateful precompiled contracts ### Fixes diff --git a/cmd/zetae2e/local/precompiles.go b/cmd/zetae2e/local/precompiles.go index c76d587c3c..bf1fe25257 100644 --- a/cmd/zetae2e/local/precompiles.go +++ b/cmd/zetae2e/local/precompiles.go @@ -19,10 +19,9 @@ func statefulPrecompilesTestRoutine( testNames ...string, ) func() error { return func() (err error) { - account := conf.AdditionalAccounts.UserERC20 + account := conf.AdditionalAccounts.UserPrecompile - // initialize runner for erc20 test - erc20Runner, err := initTestRunner( + precompileRunner, err := initTestRunner( "precompiles", conf, deployerRunner, @@ -33,11 +32,10 @@ func statefulPrecompilesTestRoutine( return err } - erc20Runner.Logger.Print("🏃 starting stateful precompiled contracts tests") + precompileRunner.Logger.Print("🏃 starting stateful precompiled contracts tests") startTime := time.Now() - // run erc20 test - testsToRun, err := erc20Runner.GetE2ETestsToRunByName( + testsToRun, err := precompileRunner.GetE2ETestsToRunByName( e2etests.AllE2ETests, testNames..., ) @@ -45,11 +43,11 @@ func statefulPrecompilesTestRoutine( return fmt.Errorf("precompiled contracts tests failed: %v", err) } - if err := erc20Runner.RunE2ETests(testsToRun); err != nil { + if err := precompileRunner.RunE2ETests(testsToRun); err != nil { return fmt.Errorf("precompiled contracts tests failed: %v", err) } - erc20Runner.Logger.Print("🍾 precompiled contracts tests completed in %s", time.Since(startTime).String()) + precompileRunner.Logger.Print("🍾 precompiled contracts tests completed in %s", time.Since(startTime).String()) return err } diff --git a/codecov.yml b/codecov.yml index 45df0a7f87..fb59f7ad2a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -22,57 +22,59 @@ coverage: - pkg comment: - layout: "reach, diff, files" + layout: 'reach, diff, files' behavior: default require_changes: true flags: zetacore: paths: - - "x/" + - 'x/' zetaclient: paths: - - "zetaclient/" + - 'zetaclient/' pkg: paths: - - "pkg/" + - 'pkg/' ignore: - - "x/**/client/**/*" - - "x/**/keeper/keeper.go" - - "x/**/keeper/msg_server.go" - - "x/**/keeper/grpc_query_params.go" - - "x/**/types/codec.go" - - "x/**/types/errors.go" - - "x/**/types/keys.go" - - "x/**/types/key_*.go" - - "x/**/types/types.go" - - "x/**/types/expected_keepers.go" - - "x/**/module.go" - - "x/**/events.go" - - "x/**/migrator.go" - - "x/**/module_simulation.go" - - "x/**/simulation/**/*" - - "**/*.proto" - - "**/*.md" - - "**/*.yml" - - "**/*.yaml" - - "**/*.pb.go" - - "**/*.pb.gw.go" - - "**/*_legacy.go" - - "**/*.json" - - "zetaclient/testdata/**/*" - - "zetaclient/testutils/**/*" - - ".github" - - "app" - - "cmd" - - "contrib" - - "docs" - - "e2e" - - "proto" - - "rpc" - - "scripts" - - "server" - - "testutil" - - "tool" - - "typescript/**/*" \ No newline at end of file + - 'x/**/client/**/*' + - 'x/**/keeper/keeper.go' + - 'x/**/keeper/msg_server.go' + - 'x/**/keeper/grpc_query_params.go' + - 'x/**/types/codec.go' + - 'x/**/types/errors.go' + - 'x/**/types/keys.go' + - 'x/**/types/key_*.go' + - 'x/**/types/types.go' + - 'x/**/types/expected_keepers.go' + - 'x/**/module.go' + - 'x/**/events.go' + - 'x/**/migrator.go' + - 'x/**/module_simulation.go' + - 'x/**/simulation/**/*' + - '**/*.proto' + - '**/*.md' + - '**/*.yml' + - '**/*.yaml' + - '**/*.pb.go' + - '**/*.pb.gw.go' + - '**/*_legacy.go' + - '**/*.json' + - 'zetaclient/testdata/**/*' + - 'zetaclient/testutils/**/*' + - '.github' + - 'app' + - 'cmd' + - 'contrib' + - 'docs' + - 'e2e' + - 'proto' + - 'rpc' + - 'scripts' + - 'server' + - 'testutil' + - 'tool' + - 'typescript/**/*' + - 'precompiles/**/bindings.go' + - 'precompiles/prototype/IPrototype.*' diff --git a/e2e/config/config.go b/e2e/config/config.go index 8e8006c042..ca1a372a02 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -68,6 +68,7 @@ type AdditionalAccounts struct { UserMisc Account `yaml:"user_misc"` UserAdmin Account `yaml:"user_admin"` UserMigration Account `yaml:"user_migration"` + UserPrecompile Account `yaml:"user_precompile"` } type PolicyAccounts struct { diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 6e14d13aa7..6a975bcc79 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -120,7 +120,7 @@ const ( /* Stateful precompiled contracts tests */ - TestZetaPrecompilesPrototypeName = "precompiles_contract_prototype" + TestZetaPrecompilesPrototypeName = "precompile_contracts_prototype" ) // AllE2ETests is an ordered list of all e2e tests