From f8d78cdb95508eebe7d9db013714c3c8c38cf195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 16 Nov 2023 09:45:31 +0100 Subject: [PATCH] chore(test): drop usage of ganache in old E2E tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Ganache tool has been replaced by Hardhat: https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.tests-e2e | 58 +++------ src/app_service/common/network_constants.nim | 118 ------------------ src/constants.nim | 3 +- src/env_cli_vars.nim | 5 - test/libs/StatusGoQt/test_wallet.cpp | 4 - .../suite_wallet/dev/docker-compose.yml | 9 -- .../testSuites/suite_wallet/dev/readme.md | 21 ---- 7 files changed, 18 insertions(+), 200 deletions(-) delete mode 100644 test/ui-test/testSuites/suite_wallet/dev/docker-compose.yml delete mode 100644 test/ui-test/testSuites/suite_wallet/dev/readme.md diff --git a/ci/Jenkinsfile.tests-e2e b/ci/Jenkinsfile.tests-e2e index 5bc860c0a7..1db952b3f1 100644 --- a/ci/Jenkinsfile.tests-e2e +++ b/ci/Jenkinsfile.tests-e2e @@ -75,9 +75,6 @@ pipeline { /* Container ports */ RPC_PORT = "${8545 + env.EXECUTOR_NUMBER.toInteger()}" P2P_PORT = "${6010 + env.EXECUTOR_NUMBER.toInteger()}" - /* Ganache config */ - GANACHE_RPC_PORT = "${9545 + env.EXECUTOR_NUMBER.toInteger()}" - GANACHE_MNEMONIC = 'pelican chief sudden oval media rare swamp elephant lawsuit wheat knife initial' /* Runtime flag to make testing of the app easier. */ STATUS_RUNTIME_TEST_MODE = '1' } @@ -97,44 +94,27 @@ pipeline { } stage('Client') { - environment { - STATUS_RUNTIME_GANACHE_NETWORK_RPC_URL = "http://localhost:${env.GANACHE_RPC_PORT}" - } steps { script { linux.bundle('nim_status_client') } } } - stage('Containers') { - parallel { - stage('Ganache') { steps { script { - ganache = docker.image( - 'trufflesuite/ganache:v7.4.1' - ).run( - ["-p 127.0.0.1:${env.GANACHE_RPC_PORT}:8545", - "-v ${env.WORKSPACE}/test/ui-test/fixtures/ganache-dbs/goerli:/goerli-db"].join(' '), - ["-m='${GANACHE_MNEMONIC}'", "-e=10", - '--chain.chainId=5', - '--database.dbPath=/goerli-db'].join(' ') - ) - } } } - - stage('Nim-Waku') { steps { script { - nimwaku = docker.image( - 'statusteam/nim-waku:v0.13.0' - ).run( - ["-p 127.0.0.1:${env.RPC_PORT}:8545", - "-p 127.0.0.1:${env.P2P_PORT}:30303/tcp", - "-p 127.0.0.1:${env.P2P_PORT}:30303/udp", - "-v ${env.WORKSPACE}/ci/mailserver/config.json:/config.json"].join(' '), - ['--store=true', - '--keep-alive=true', - '--rpc-address=0.0.0.0', - '--nat=none'].join(' ') - ) - env.TEST_PEER_ENR = getPeerAddress() - } } } - } + stage('Nim-Waku') { + steps { script { + nimwaku = docker.image( + 'statusteam/nim-waku:v0.13.0' + ).run( + ["-p 127.0.0.1:${env.RPC_PORT}:8545", + "-p 127.0.0.1:${env.P2P_PORT}:30303/tcp", + "-p 127.0.0.1:${env.P2P_PORT}:30303/udp", + "-v ${env.WORKSPACE}/ci/mailserver/config.json:/config.json"].join(' '), + ['--store=true', + '--keep-alive=true', + '--rpc-address=0.0.0.0', + '--nat=none'].join(' ') + ) + env.TEST_PEER_ENR = getPeerAddress() + } } } stage('Tests') { @@ -169,10 +149,7 @@ pipeline { } } } } post { - failure { script { - sh("docker logs ${nimwaku.id}") - sh("docker logs ${ganache.id}") - } } + failure { script { sh("docker logs ${nimwaku.id}") } } } } } @@ -189,7 +166,6 @@ pipeline { } } cleanup { script { sh './scripts/clean-git.sh' - if (binding.hasVariable('ganache')) { ganache.stop() } if (binding.hasVariable('nimwaku')) { nimwaku.stop() } } } } diff --git a/src/app_service/common/network_constants.nim b/src/app_service/common/network_constants.nim index 2985be3e75..47884ea414 100644 --- a/src/app_service/common/network_constants.nim +++ b/src/app_service/common/network_constants.nim @@ -140,124 +140,6 @@ var NETWORKS* = %* [ } ] -if GANACHE_NETWORK_RPC_URL != "": - NETWORKS = %* [ - { - "chainId": 1, - "chainName": "Mainnet", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://etherscan.io/", - "iconUrl": "network/Network=Ethereum", - "chainColor": "#627EEA", - "shortName": "eth", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": false, - "layer": 1, - "enabled": true, - "tokenOverrides": [ - { - "symbol": "SNT", - "address": "0x8571Ddc46b10d31EF963aF49b6C7799Ea7eff818" - } - ], - "relatedChainId": 5, - }, - { - "chainId": 5, - "chainName": "Mainnet", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://goerli.etherscan.io/", - "iconUrl": "network/Network=Ethereum", - "chainColor": "#627EEA", - "shortName": "eth", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": true, - "layer": 1, - "enabled": true, - "tokenOverrides": [ - { - "symbol": "STT", - "address": "0x8571Ddc46b10d31EF963aF49b6C7799Ea7eff818" - } - ], - "relatedChainId": 1, - }, - { - "chainId": 10, - "chainName": "Optimism", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://optimistic.etherscan.io", - "iconUrl": "network/Network=Optimism", - "chainColor": "#E90101", - "shortName": "opt", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": false, - "layer": 2, - "enabled": true, - "relatedChainId": 420, - }, - { - "chainId": 420, - "chainName": "Optimism", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://goerli-optimism.etherscan.io/", - "iconUrl": "network/Network=Optimism", - "chainColor": "#E90101", - "shortName": "opt", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": true, - "layer": 2, - "enabled": false, - "relatedChainId": 10, - }, - { - "chainId": 42161, - "chainName": "Arbitrum", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://arbiscan.io/", - "iconUrl": "network/Network=Arbitrum", - "chainColor": "#51D0F0", - "shortName": "arb", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": false, - "layer": 2, - "enabled": true, - "relatedChainId": 421613, - }, - { - "chainId": 421613, - "chainName": "Arbitrum", - "rpcUrl": GANACHE_NETWORK_RPC_URL, - "fallbackUrl": GANACHE_NETWORK_RPC_URL, - "blockExplorerUrl": "https://goerli.arbiscan.io/", - "iconUrl": "network/Network=Arbitrum", - "chainColor": "#51D0F0", - "shortName": "arb", - "nativeCurrencyName": "Ether", - "nativeCurrencySymbol": "ETH", - "nativeCurrencyDecimals": 18, - "isTest": true, - "layer": 2, - "enabled": false, - "relatedChainId": 42161, - } - ] - var NODE_CONFIG* = %* { "BrowsersConfig": { "Enabled": true diff --git a/src/constants.nim b/src/constants.nim index 36c472010b..98db89fa2e 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -37,7 +37,6 @@ let # runtime variables TEST_MODE_ENABLED* = desktopConfig.testMode WALLET_ENABLED* = desktopConfig.enableWallet - GANACHE_NETWORK_RPC_URL* = desktopConfig.genacheNetworkRpcUrl TORRENT_CONFIG_PORT* = desktopConfig.defaultTorentConfigPort WAKU_V2_PORT* = desktopConfig.defaultWakuV2Port STATUS_PORT* = desktopConfig.statusPort @@ -54,4 +53,4 @@ let ALCHEMY_OPTIMISM_MAINNET_TOKEN_RESOLVED* = desktopConfig.alchemyOptimismMainnetToken ALCHEMY_OPTIMISM_GOERLI_TOKEN_RESOLVED* = desktopConfig.alchemyOptimismGoerliToken OPENSEA_API_KEY_RESOLVED* = desktopConfig.openseaApiKey - WALLET_CONNECT_PROJECT_ID* = BUILD_WALLET_CONNECT_PROJECT_ID \ No newline at end of file + WALLET_CONNECT_PROJECT_ID* = BUILD_WALLET_CONNECT_PROJECT_ID diff --git a/src/env_cli_vars.nim b/src/env_cli_vars.nim index 0ca8878037..42c769b56f 100644 --- a/src/env_cli_vars.nim +++ b/src/env_cli_vars.nim @@ -143,11 +143,6 @@ type StatusDesktopConfig = object desc: "Determines if the wallet section is enabled" name: "ENABLE_WALLET" abbr: "enable-wallet" .}: bool - genacheNetworkRpcUrl* {. - defaultValue: "" - desc: "Sets ganache network rpc url" - name: "GANACHE_NETWORK_RPC_URL" - abbr: "ganache-network-rpc-url" .}: string defaultTorentConfigPort* {. defaultValue: 0 desc: "Sets default torrent config port" diff --git a/test/libs/StatusGoQt/test_wallet.cpp b/test/libs/StatusGoQt/test_wallet.cpp index 2293c4f4e3..1c16de1d32 100644 --- a/test/libs/StatusGoQt/test_wallet.cpp +++ b/test/libs/StatusGoQt/test_wallet.cpp @@ -356,7 +356,6 @@ TEST(WalletApi, TestGetTokensBalancesForChainIDs_WatchOnlyAccount) ASSERT_GT(addressBalance.at(sntMain.address), 0); } -// TODO: this is a debugging test. Augment it with local Ganache environment to have a reliable integration test TEST(WalletApi, TestCheckRecentHistory) { ScopedTestAccount testAccount(test_info_->name()); @@ -399,7 +398,6 @@ TEST(WalletApi, TestCheckRecentHistory) ASSERT_TRUE(historyReady); } -// TODO: this is a debugging test. Augment it with local Ganache environment to have a reliable integration test TEST(WalletApi, TestGetBalanceHistory) { ScopedTestAccount testAccount(test_info_->name()); @@ -538,7 +536,6 @@ TEST(WalletApi, TestGetBalanceHistory) } } -// TODO: this is a debugging test. Augment it with local Ganache environment to have a reliable integration test TEST(WalletApi, TestStartWallet) { ScopedTestAccount testAccount(test_info_->name()); @@ -589,7 +586,6 @@ TEST(WalletApi, TestStartWallet) ASSERT_EQ(bhEndedReceivedCount, 2); } -// TODO: this is a debugging test. Augment it with local Ganache environment to have a reliable integration test TEST(WalletApi, TestStopBalanceHistory) { ScopedTestAccount testAccount(test_info_->name()); diff --git a/test/ui-test/testSuites/suite_wallet/dev/docker-compose.yml b/test/ui-test/testSuites/suite_wallet/dev/docker-compose.yml deleted file mode 100644 index f10bb8d768..0000000000 --- a/test/ui-test/testSuites/suite_wallet/dev/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: '2.1' -services: - uitestganache: - image: trufflesuite/ganache:v7.4.1 - ports: - - 127.0.0.1:${GANACHE_RPC_PORT}:8545 - volumes: - - ${GANACHE_DB_FOLDER}:/test_data/goerli-db - command: ["-m='${GANACHE_MNEMONIC}'", "-e=10", "--chain.chainId=5", "--database.dbPath=/test_data/goerli-db"] diff --git a/test/ui-test/testSuites/suite_wallet/dev/readme.md b/test/ui-test/testSuites/suite_wallet/dev/readme.md deleted file mode 100644 index 1bcbd0f963..0000000000 --- a/test/ui-test/testSuites/suite_wallet/dev/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# Developer helpers to run ganache dependent test cases locally - -Ganache is used in tests to avoid depending on RPC internet calls - -In CI ganache is started as a docker container directly from the [test suite](../../../../../ci/Jenkinsfile.e2e) (see stage `Containers`). In order to run locally you need to start ganache manually with the same options as Jenkins environment. - -## How to run e2e tests locally - -Optionally edit [`.env`](./.env) file to match your personal setup if the defaults don't work for you. The file is loaded by `desktop-compose` from the run step. - -Running - -- Compile to include the squish specific configuration like this `GANACHE_NETWORK_RPC_URL="http://localhost:9545" make -j10` - - This is required because `GANACHE_NETWORK_RPC_URL` is a `const` Nim variable and cannot be changed at runtime (`make clean` if binary is already built without the `GANACHE_NETWORK_RPC_URL`) - - Upon this step the production `NETWORKS` configuration in `status-desktop/src/app_service/common/network_constants.nim` is overridden with the second pair that includes the `GANACHE_NETWORK_RPC_URL` variable for all nodes along with specific token contract override for `SNT` and `STT` -- Start ganache docker environment `docker-compose up uitestganache` -- Run squish desired tests (if all is setup correctly, you should see RPC output calls in the `docker-compose up` output) - -**Beware** that the default `.env` will alter the in sources test data. Using the in-sources test data folder makes it is easy to add changes to the git index. - -- Solution: a copy of the `/test/ui-test/fixtures/ganache-dbs/goerli` can be made outside sources and docker-compose redirected to use a personal `.env` file (using the `--env-file` option) pointing to the personal clone of the test data folder.