Skip to content

Commit 71a889b

Browse files
lumtiskingpinXDskositows4charlie
authored
test: add admin and performance test and fix upgrade test (#1805)
* simplify docker compose * fix makefi;e * add new version * type * fix restart client * some fixes * add light upgrade test * fix gov sending * add admin function test command * performance test * fix lint * add pprof port * some fixes in tests * test: emissions unit test (#1767) * ci: run build workflow on develop push for code coverage generation (#1793) * refactor: zetaclient metrics (#1783) * Refactor zetaclient metrics * Fix blame counter init * Add changelog entry * Add unreleased to changelog * Remove blank line * feat: initiated feature of zetaclient-restricted-address (#1790) * initiated feature of zetaclient-banned-address * fix some issues in e2e tests * fix gosec issues * some unit tests, comments and refactor * unified log prints for restricted address detection * move restricted address to Unreleased section * improved compliance log prints * update compliance log print according to CharlieMc * chore(codecov.yml): fix ignore extension (#1814) * chore(codecov.yml): fix ignore extension * changelog * refactor: remove params from config and introduce app context (#1774) * refactor(`crosschain`): move ballot voting logic into `observer` (#1511) * move logic for ballot voting for inbound * fix mocks * goimports * changelog * fix unit tests * fix CI = * x/observer/keeper/vote_outbound.go x/crosschain/types/expected_keepers.go x/crosschain/keeper/msg_server_vote_outbound_tx.go * update mocks * refactor finalized check * make generate * initialize vote inbound tests * add sdk keepers in observer testutil * implement mock option for observer * inbound vote test * initialize outbound tests * goimports * vote outbound tests * update changelog * test with integration tests * add isNew in vote_inbound * add tests back * use tmp context for ballot logic * add new test for finalized ballot * add not finzalized test * remove unused comment * fix bitcoin credentials * change upgrade version * fix performance tests * handler * fix setup handler * add light flag and use it for upgrade tests * fix username * add performance test back * Update cmd/zetae2e/local/ethereum.go * stefan comments * changelog * fix --------- Co-authored-by: Tanmay <[email protected]> Co-authored-by: skosito <[email protected]> Co-authored-by: Charlie Chen <[email protected]>
1 parent 58c3d43 commit 71a889b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+440
-249
lines changed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ WORKDIR /go/delivery/zeta-node
1414
# Copy module files and download dependencies
1515
COPY go.mod .
1616
COPY go.sum .
17+
1718
RUN go mod download
1819

1920
# Copy the rest of the source code and build the application

Dockerfile-upgrade

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ WORKDIR /go/delivery/zeta-node
2020
RUN mkdir -p $GOPATH/bin/old
2121
RUN mkdir -p $GOPATH/bin/new
2222

23-
ARG OLD_VERSION=v13.0.0
24-
ENV NEW_VERSION=v14
23+
ARG OLD_VERSION=v14.0.0
24+
ENV NEW_VERSION=v15
2525

2626
# Build new release from the current source
2727
COPY go.mod /go/delivery/zeta-node/

LOCAL_TESTING.md

+17-9
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ $ make zetanode
1717

1818
This Makefile rule builds the zetanode image. **Rebuild if zetacored/zetaclientd code is updated**.
1919
```bash
20-
# in zeta-node/
2120
$ docker build -t zetanode .
2221
```
2322

2423
### Run e2e tests
2524

2625
Now we have built all the docker images, we can run the e2e test with make command:
2726
```bash
28-
# in zeta-node/
2927
make start-e2e-test
3028
```
3129

30+
#### Run admin functions e2e tests
31+
32+
We define e2e tests allowing to test admin functionalities (emergency network pause for example).
33+
Since these tests interact with the network functionalities, these can't be run concurrently with the regular e2e tests.
34+
Moreover, these tests test scoped functionalities of the protocol, and won't be tested in the same pipeline as the regular e2e tests.
35+
Therefore, we provide a separate command to run e2e admin functions tests:
36+
```bash
37+
make start-e2e-admin-test
38+
```
39+
3240
### Run upgrade tests
3341

3442
Upgrade tests run the E2E tests with an older version, upgrade the nodes to the new version, and run the E2E tests again.
@@ -46,18 +54,22 @@ NOTE: We only specify the major version for `NEW_VERSION` since we use major ver
4654

4755
The upgrade tests can be run with the following command:
4856
```bash
49-
# in zeta-node/
5057
make start-upgrade-test
5158
```
5259

60+
The test the upgrade script faster a light version of the upgrade test can be run with the following command:
61+
```bash
62+
make start-upgrade-test-light
63+
```
64+
This command will run the upgrade test with a lower height and will not populate the state.
65+
5366
### Run stress tests
5467

5568
Stress tests run the E2E tests with a larger number of nodes and clients to test the performance of the network.
5669
It also stresses the network by sending a large number of cross-chain transactions.
5770

5871
The stress tests can be run with the following command:
5972
```bash
60-
# in zeta-node/
6173
make start-stress-test
6274
```
6375

@@ -68,15 +80,14 @@ If everything works fine, it should finish without panic.
6880

6981
The logs can be observed with the following command:
7082
```bash
71-
# in zeta-node/contrib/localnet/orchestrator
83+
# in node/contrib/localnet/orchestrator
7284
$ docker logs -f orchestrator
7385
```
7486

7587
### Stop tests
7688

7789
To stop the tests,
7890
```bash
79-
# in zeta-node/
8091
make stop-test
8192
```
8293

@@ -86,7 +97,6 @@ Before starting the monitoring setup, make sure the Zetacore API is up at http:/
8697
You can also add any additional ETH addresses to monitor in `zeta-node/contrib/localnet/grafana/addresses.txt` file
8798

8899
```bash
89-
# in zeta-node/
90100
make start-monitoring
91101
```
92102

@@ -97,7 +107,6 @@ The Grafana default credentials are admin:admin. The dashboards are located at h
97107
### Stop monitoring setup
98108

99109
```bash
100-
# in zeta-node/
101110
make stop-monitoring
102111
```
103112

@@ -108,7 +117,6 @@ In addition to running automated tests, you can also interact with the localnet
108117
The localnet can be started without running tests with the following command:
109118

110119
```bash
111-
# in zeta-node/
112120
make start-localnet
113121
```
114122

Makefile

+18-3
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,35 @@ install-zetae2e: go.sum
192192
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetae2e
193193
.PHONY: install-zetae2e
194194

195-
start-e2e-test:
195+
start-e2e-test: zetanode
196196
@echo "--> Starting e2e test"
197197
cd contrib/localnet/ && $(DOCKER) compose up -d
198198

199+
start-e2e-admin-test: zetanode
200+
@echo "--> Starting e2e admin test"
201+
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-admin.yml up -d
202+
203+
start-e2e-performance-test: zetanode
204+
@echo "--> Starting e2e performance test"
205+
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-performance.yml up -d
206+
199207
start-stress-test: zetanode
208+
@echo "--> Starting stress test"
200209
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d
201210

202211
start-upgrade-test:
203212
@echo "--> Starting upgrade test"
204-
$(DOCKER) build --build-arg -t zetanode -f ./Dockerfile-upgrade .
213+
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
205214
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
206215
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d
207216

208-
start-localnet:
217+
start-upgrade-test-light:
218+
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
219+
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
220+
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
221+
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade-light.yml up -d
222+
223+
start-localnet: zetanode
209224
@echo "--> Starting localnet"
210225
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-setup-only.yml up -d
211226

app/setup_handlers.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import (
55
sdk "github.com/cosmos/cosmos-sdk/types"
66
"github.com/cosmos/cosmos-sdk/types/module"
77
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
8-
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
8+
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
9+
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
910
)
1011

11-
const releaseVersion = "v14"
12+
const releaseVersion = "v15"
1213

1314
func SetupHandlers(app *App) {
1415
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
@@ -17,7 +18,7 @@ func SetupHandlers(app *App) {
1718
for m, mb := range app.mm.Modules {
1819
vm[m] = mb.ConsensusVersion()
1920
}
20-
VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName)
21+
VersionMigrator{v: vm}.TriggerMigration(observertypes.ModuleName)
2122

2223
return app.mm.RunMigrations(ctx, app.configurator, vm)
2324
})
@@ -28,7 +29,7 @@ func SetupHandlers(app *App) {
2829
}
2930
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
3031
storeUpgrades := storetypes.StoreUpgrades{
31-
// Added: []string{},
32+
Added: []string{authoritytypes.ModuleName},
3233
}
3334
// Use upgrade store loader for the initial loading of all stores when app starts,
3435
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,

changelog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* [1840](https://github.com/zeta-chain/node/pull/1840) - fix code coverage test failures ignored in CI
3232
* [1851](https://github.com/zeta-chain/node/pull/1851) - rename usdt to erc20 in e2e tests
3333
* [1872](https://github.com/zeta-chain/node/pull/1872) - remove usage of RPC in unit test
34+
* [1805](https://github.com/zeta-chain/node/pull/1805) - add admin and performance test and fix upgrade test
3435

3536
### Fixes
3637

@@ -93,7 +94,6 @@
9394
* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks
9495
* [1746](https://github.com/zeta-chain/node/pull/1746) - rename smoke tests to e2e tests
9596
* [1753](https://github.com/zeta-chain/node/pull/1753) - fix gosec errors on usage of rand package
96-
9797
* [1762](https://github.com/zeta-chain/node/pull/1762) - improve coverage for fungibile module
9898
* [1782](https://github.com/zeta-chain/node/pull/1782) - improve coverage for fungibile module system contract
9999

cmd/zetae2e/config/clients.go

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func getBtcClient(rpcConf config.BitcoinRPC) (*rpcclient.Client, error) {
8080
HTTPPostMode: rpcConf.HTTPPostMode,
8181
DisableTLS: rpcConf.DisableTLS,
8282
Params: param,
83-
//Endpoint: "/wallet/user",
8483
}
8584
return rpcclient.New(connCfg, nil)
8685
}

cmd/zetae2e/config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
100100
conf.Contracts.ZEVM.BTCZRC20Addr = r.BTCZRC20Addr.Hex()
101101
conf.Contracts.ZEVM.UniswapFactoryAddr = r.UniswapV2FactoryAddr.Hex()
102102
conf.Contracts.ZEVM.UniswapRouterAddr = r.UniswapV2RouterAddr.Hex()
103+
conf.Contracts.ZEVM.ConnectorZEVMAddr = r.ConnectorZEVMAddr.Hex()
104+
conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex()
103105
conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex()
104106
conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex()
105107
conf.Contracts.ZEVM.TestDappAddr = r.TestDAppAddr.Hex()

cmd/zetae2e/config/local.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rpcs:
77
evm: "http://0.0.0.0:8545"
88
bitcoin:
99
host: "0.0.0.0:18443"
10-
user: "e2e"
10+
user: "smoketest"
1111
pass: "123"
1212
http_post_mode: true
1313
disable_tls: true

cmd/zetae2e/local/admin.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func adminTestRoutine(
1717
conf config.Config,
1818
deployerRunner *runner.E2ERunner,
1919
verbose bool,
20+
testNames ...string,
2021
) func() error {
2122
return func() (err error) {
2223
// return an error on panic
@@ -63,9 +64,7 @@ func adminTestRoutine(
6364
// run erc20 advanced test
6465
testsToRun, err := adminRunner.GetE2ETestsToRunByName(
6566
e2etests.AllE2ETests,
66-
e2etests.TestPauseZRC20Name,
67-
e2etests.TestUpdateBytecodeName,
68-
e2etests.TestDepositEtherLiquidityCapName,
67+
testNames...,
6968
)
7069
if err != nil {
7170
return fmt.Errorf("admin tests failed: %v", err)

cmd/zetae2e/local/bitcoin.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func bitcoinTestRoutine(
1717
deployerRunner *runner.E2ERunner,
1818
verbose bool,
1919
initBitcoinNetwork bool,
20+
testHeader bool,
21+
testNames ...string,
2022
) func() error {
2123
return func() (err error) {
2224
// return an error on panic
@@ -59,18 +61,14 @@ func bitcoinTestRoutine(
5961
bitcoinRunner.WaitForMinedCCTX(txERC20Deposit)
6062

6163
bitcoinRunner.SetupBitcoinAccount(initBitcoinNetwork)
62-
bitcoinRunner.DepositBTC(true)
64+
bitcoinRunner.DepositBTC(testHeader)
6365

6466
// run bitcoin test
6567
// Note: due to the extensive block generation in Bitcoin localnet, block header test is run first
6668
// to make it faster to catch up with the latest block header
6769
testsToRun, err := bitcoinRunner.GetE2ETestsToRunByName(
6870
e2etests.AllE2ETests,
69-
e2etests.TestBitcoinWithdrawInvalidAddressName,
70-
e2etests.TestBitcoinWithdrawName,
71-
e2etests.TestZetaWithdrawBTCRevertName,
72-
e2etests.TestCrosschainSwapName,
73-
e2etests.TestBitcoinWithdrawRestrictedName,
71+
testNames...,
7472
)
7573
if err != nil {
7674
return fmt.Errorf("bitcoin tests failed: %v", err)

cmd/zetae2e/local/erc20.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func erc20TestRoutine(
1616
conf config.Config,
1717
deployerRunner *runner.E2ERunner,
1818
verbose bool,
19+
testNames ...string,
1920
) func() error {
2021
return func() (err error) {
2122
// return an error on panic
@@ -56,17 +57,10 @@ func erc20TestRoutine(
5657
erc20Runner.WaitForMinedCCTX(txEtherDeposit)
5758
erc20Runner.WaitForMinedCCTX(txERC20Deposit)
5859

59-
//erc20Runner.SetupBitcoinAccount()
60-
//erc20Runner.DepositBTC()
61-
6260
// run erc20 test
6361
testsToRun, err := erc20Runner.GetE2ETestsToRunByName(
6462
e2etests.AllE2ETests,
65-
e2etests.TestERC20WithdrawName,
66-
e2etests.TestMultipleWithdrawsName,
67-
e2etests.TestERC20DepositAndCallRefundName,
68-
e2etests.TestZRC20SwapName,
69-
e2etests.TestERC20DepositRestrictedName,
63+
testNames...,
7064
)
7165
if err != nil {
7266
return fmt.Errorf("erc20 tests failed: %v", err)

cmd/zetae2e/local/ethereum.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ func ethereumTestRoutine(
1616
conf config.Config,
1717
deployerRunner *runner.E2ERunner,
1818
verbose bool,
19+
testHeader bool,
20+
testNames ...string,
1921
) func() error {
2022
return func() (err error) {
2123
// return an error on panic
@@ -47,19 +49,15 @@ func ethereumTestRoutine(
4749
startTime := time.Now()
4850

4951
// depositing the necessary tokens on ZetaChain
50-
txEtherDeposit := ethereumRunner.DepositEther(true)
52+
txEtherDeposit := ethereumRunner.DepositEther(testHeader)
5153
ethereumRunner.WaitForMinedCCTX(txEtherDeposit)
5254

5355
// run ethereum test
5456
// Note: due to the extensive block generation in Ethereum localnet, block header test is run first
5557
// to make it faster to catch up with the latest block header
5658
testsToRun, err := ethereumRunner.GetE2ETestsToRunByName(
5759
e2etests.AllE2ETests,
58-
e2etests.TestEtherWithdrawName,
59-
e2etests.TestContextUpgradeName,
60-
e2etests.TestEtherDepositAndCallName,
61-
e2etests.TestDepositAndCallRefundName,
62-
e2etests.TestEtherWithdrawRestrictedName,
60+
testNames...,
6361
)
6462
if err != nil {
6563
return fmt.Errorf("ethereum tests failed: %v", err)

0 commit comments

Comments
 (0)