From 8b0a2f7f92084dff407fefca967af4afef24823f Mon Sep 17 00:00:00 2001 From: Or Neeman Date: Mon, 19 Jul 2021 14:58:05 -0600 Subject: [PATCH] Don't use mycelo for e2e tests by default. (#8291) ### Description Following up on #8086, we realized that using mycelo for the tests by default introduces friction for developers making changes to the core contracts, since it requires them to also update the migrations which mycelo uses, which are in the celo-blockchain repo and in Go rather than javascript. So as a compromise, this PR modifies the tests back to not use mycelo by default. Instead, they can be switched by devs to use mycelo temporarily (for local runs) as desired, or forced to use mycelo by setting an env variable: ``` export E2E_TESTS_FORCE_USE_MYCELO=true ``` We expect that for the celo-blockchain CI we will set this environment variable, but we won't for the monorepo CI. ### Tested Verified that the tests now don't use mycelo, but do if you specify the env variable to be true. --- .../src/e2e-tests/blockchain_parameters_tests.ts | 2 +- packages/celotool/src/e2e-tests/cip35_tests.ts | 2 +- packages/celotool/src/e2e-tests/governance_tests.ts | 2 +- packages/celotool/src/e2e-tests/replica_tests.ts | 2 +- packages/celotool/src/e2e-tests/slashing_tests.ts | 2 +- packages/celotool/src/e2e-tests/sync_tests.ts | 1 - packages/celotool/src/e2e-tests/transfer_tests.ts | 2 +- packages/celotool/src/e2e-tests/utils.ts | 12 +++++++++--- .../celotool/src/e2e-tests/validator_order_tests.ts | 2 +- packages/celotool/src/lib/env-utils.ts | 1 + 10 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/celotool/src/e2e-tests/blockchain_parameters_tests.ts b/packages/celotool/src/e2e-tests/blockchain_parameters_tests.ts index d52e0aaa04e..601df548a90 100644 --- a/packages/celotool/src/e2e-tests/blockchain_parameters_tests.ts +++ b/packages/celotool/src/e2e-tests/blockchain_parameters_tests.ts @@ -16,7 +16,7 @@ describe('Blockchain parameters tests', function (this: any) { let parameters: BlockchainParametersWrapper const gethConfig: GethRunConfig = { - useMycelo: true, + migrate: true, runPath: TMP_PATH, keepData: false, networkId: 1101, diff --git a/packages/celotool/src/e2e-tests/cip35_tests.ts b/packages/celotool/src/e2e-tests/cip35_tests.ts index 04d4c969f46..7fc0766832f 100644 --- a/packages/celotool/src/e2e-tests/cip35_tests.ts +++ b/packages/celotool/src/e2e-tests/cip35_tests.ts @@ -128,7 +128,7 @@ function generateTestCases(cipIsActivated: boolean) { function getGethRunConfig(withDonut: boolean): GethRunConfig { console.log('getGethRunConfig', withDonut) return { - useMycelo: true, + migrate: true, runPath: TMP_PATH, keepData: false, networkId: 1101, diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 95c74c55063..769efa9647d 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -177,7 +177,7 @@ describe('governance tests', () => { const gethConfig: GethRunConfig = { runPath: TMP_PATH, verbosity: 3, - useMycelo: true, + migrate: true, networkId: 1101, network: 'local', genesisConfig: { diff --git a/packages/celotool/src/e2e-tests/replica_tests.ts b/packages/celotool/src/e2e-tests/replica_tests.ts index a168a9faadd..55cdb60df9c 100644 --- a/packages/celotool/src/e2e-tests/replica_tests.ts +++ b/packages/celotool/src/e2e-tests/replica_tests.ts @@ -35,7 +35,7 @@ const verbose = false describe('replica swap tests', () => { const gethConfig: GethRunConfig = { - useMycelo: true, + migrate: true, runPath: TMP_PATH, verbosity: 4, networkId: 1101, diff --git a/packages/celotool/src/e2e-tests/slashing_tests.ts b/packages/celotool/src/e2e-tests/slashing_tests.ts index afd075c11ad..0b260014a6c 100644 --- a/packages/celotool/src/e2e-tests/slashing_tests.ts +++ b/packages/celotool/src/e2e-tests/slashing_tests.ts @@ -97,7 +97,7 @@ describe('slashing tests', function (this: any) { network: 'local', networkId: 1101, runPath: TMP_PATH, - useMycelo: true, + migrate: true, genesisConfig: { churritoBlock: 0, donutBlock: 0, diff --git a/packages/celotool/src/e2e-tests/sync_tests.ts b/packages/celotool/src/e2e-tests/sync_tests.ts index 0182b219476..2d057cabc6c 100644 --- a/packages/celotool/src/e2e-tests/sync_tests.ts +++ b/packages/celotool/src/e2e-tests/sync_tests.ts @@ -21,7 +21,6 @@ describe('sync tests', function (this: any) { churritoBlock: 0, donutBlock: 0, }, - useMycelo: true, instances: [ { name: 'validator0', diff --git a/packages/celotool/src/e2e-tests/transfer_tests.ts b/packages/celotool/src/e2e-tests/transfer_tests.ts index ce1133f6254..887e1c9bb80 100644 --- a/packages/celotool/src/e2e-tests/transfer_tests.ts +++ b/packages/celotool/src/e2e-tests/transfer_tests.ts @@ -170,7 +170,7 @@ describe('Transfer tests', function (this: any) { const syncModes = ['full', 'fast', 'light', 'lightest'] const gethConfig: GethRunConfig = { - useMycelo: true, + migrate: true, networkId: 1101, network: 'local', runPath: TMP_PATH, diff --git a/packages/celotool/src/e2e-tests/utils.ts b/packages/celotool/src/e2e-tests/utils.ts index 02db2ece41c..b970829f84f 100644 --- a/packages/celotool/src/e2e-tests/utils.ts +++ b/packages/celotool/src/e2e-tests/utils.ts @@ -6,6 +6,7 @@ import { join as joinPath, resolve as resolvePath } from 'path' import readLastLines from 'read-last-lines' import Web3 from 'web3' import { spawnCmd, spawnCmdWithExitOnFailure } from '../lib/cmd-utils' +import { envVar, fetchEnvOrFallback } from '../lib/env-utils' import { AccountType, getPrivateKeysFor, @@ -34,6 +35,7 @@ import { import { GethInstanceConfig } from '../lib/interfaces/geth-instance-config' import { GethRepository } from '../lib/interfaces/geth-repository' import { GethRunConfig } from '../lib/interfaces/geth-run-config' +import { stringToBoolean } from '../lib/utils' const MonorepoRoot = resolvePath(joinPath(__dirname, '../..', '../..')) const verboseOutput = false @@ -215,6 +217,10 @@ export function getHooks(gethConfig: GethRunConfig) { } export function getContext(gethConfig: GethRunConfig, verbose: boolean = verboseOutput) { + // Use of mycelo can be enabled through gethConfig or through an env variable + const useMycelo = + !!gethConfig.useMycelo || + stringToBoolean(fetchEnvOrFallback(envVar.E2E_TESTS_FORCE_USE_MYCELO, 'false')) const validatorInstances = gethConfig.instances.filter((x: any) => x.validating) const numValidators = validatorInstances.length @@ -240,7 +246,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose await checkoutGethRepo(repo.branch || 'master', repo.path) } - if (gethConfig.useMycelo) { + if (useMycelo) { await buildGethAll(repo.path) } else { await buildGeth(repo.path) @@ -255,7 +261,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose fs.mkdirSync(gethConfig.runPath, { recursive: true }) } - if (gethConfig.useMycelo) { + if (useMycelo) { // Compile the contracts first because mycelo assumes they are compiled already, unless told not to if (!gethConfig.myceloSkipCompilingContracts) { await spawnCmdWithExitOnFailure('yarn', ['truffle', 'compile'], { @@ -312,7 +318,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose } } - if (gethConfig.useMycelo || !(gethConfig.migrate || gethConfig.migrateTo)) { + if (useMycelo || !(gethConfig.migrate || gethConfig.migrateTo)) { // Just need to initialize the nodes in this case. No need to actually start the network // since we don't need to run the migrations against it. for (const instance of gethConfig.instances) { diff --git a/packages/celotool/src/e2e-tests/validator_order_tests.ts b/packages/celotool/src/e2e-tests/validator_order_tests.ts index 2e1e9097a76..02ca28556dd 100644 --- a/packages/celotool/src/e2e-tests/validator_order_tests.ts +++ b/packages/celotool/src/e2e-tests/validator_order_tests.ts @@ -16,7 +16,7 @@ describe('governance tests', () => { networkId: 1101, network: 'local', runPath: TMP_PATH, - useMycelo: true, + migrate: true, instances: _.range(VALIDATORS).map((i) => ({ name: `validator${i}`, validating: true, diff --git a/packages/celotool/src/lib/env-utils.ts b/packages/celotool/src/lib/env-utils.ts index 8035bc45c7a..bc7afdf9793 100644 --- a/packages/celotool/src/lib/env-utils.ts +++ b/packages/celotool/src/lib/env-utils.ts @@ -53,6 +53,7 @@ export enum envVar { CONSENSUS_TYPE = 'CONSENSUS_TYPE', CONTEXTS = 'CONTEXTS', DONUT_BLOCK = 'DONUT_BLOCK', + E2E_TESTS_FORCE_USE_MYCELO = 'E2E_TESTS_FORCE_USE_MYCELO', EKSPORTISTO_DOCKER_IMAGE_REPOSITORY = 'EKSPORTISTO_DOCKER_IMAGE_REPOSITORY', EKSPORTISTO_DOCKER_IMAGE_TAG = 'EKSPORTISTO_DOCKER_IMAGE_TAG', EKSPORTISTO_SUFFIX = 'EKSPORTISTO_SUFFIX',