Skip to content

Commit

Permalink
Merge pull request #3274 from ethereum/ci/e2e-mosaic
Browse files Browse the repository at this point in the history
Add E2E Mosaic test
  • Loading branch information
nivida authored Dec 16, 2019
2 parents 4689592 + 54f6eeb commit 4d57461
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ matrix:
env: TEST=unit_and_e2e_clients
- node_js: 10
env: TEST=e2e_truffle
- node_js: 10
env: TEST=e2e_mosaic
- node_js: 10
env: TEST=e2e_browsers
addons:
Expand All @@ -26,6 +28,8 @@ matrix:
allow_failures:
- node_js: 10
env: TEST=e2e_truffle
- node_js: 10
env: TEST=e2e_mosaic

addons:
apt:
Expand All @@ -45,7 +49,7 @@ before_install:
- export DISPLAY=:99.0
- export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
install:
- if [ $TEST != "e2e_truffle" ]; then
- if [[ $TEST != "e2e_truffle" ]] && [[ $TEST != "e2e_mosaic" ]]; then
npm install;
fi
script:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"test:e2e:browsers": "npm run build; npm run test:e2e:chrome; npm run test:e2e:firefox",
"test:e2e:publish": "./scripts/e2e.npm.publish.sh",
"test:e2e:truffle": "./scripts/e2e.truffle.sh",
"test:e2e:mosaic": "./scripts/e2e.mosaic.sh",
"ci": "./scripts/ci.sh",
"coveralls": "./scripts/coveralls.sh"
},
Expand Down
5 changes: 5 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ elif [ "$TEST" = "e2e_truffle" ]; then
npm run test:e2e:publish
npm run test:e2e:truffle

elif [ "$TEST" = "e2e_mosaic" ]; then

npm run test:e2e:publish
npm run test:e2e:mosaic

fi
56 changes: 56 additions & 0 deletions scripts/e2e.mosaic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -------------------------------------------------------------------------------------------
# Run mosaicdao/mosaic-1 fork (w/ buidler truffle5 plugin) using a candidate
# branch of web3 which has been published to a proxy npm registry in `e2e.npm.publish.sh`
#
# This test's purpose is to watch web3 execute a long, complex test suite
# It uses buidler-adapted fork of mosaicdao because that tool is simpler and
# more modular than Truffle and lets us resolve arbitrary versions of web3 more easily.
# --------------------------------------------------------------------------------------------

# Exit immediately on error
set -o errexit

# To mimic `npm install web3` correctly, this test does not install Web3's dev deps.
# However, we need the npm package `semver` to coerce yarn resolutions correctly.
# It must be installed as a dev dep or Node complains. We also need web3's package.json
# to resolve the current version + patch increment. So some file renaming is necessary here...
cp package.json original.package.json
rm package.json
rm package-lock.json
npm init --yes
npm install --save-dev semver

# Install mosaic and set yarn resolutions to virtually published patch version
git clone https://github.com/cgewecke/mosaic-1.git
scripts/js/resolutions.js mosaic-1
cd mosaic-1

# Install via registry and verify
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Installing updated web3 via virtual registry "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

git submodule update --init --recursive
yarn --registry http://localhost:4873

yarn add web3@e2e --registry http://localhost:4873

yarn list web3
yarn list web3-utils
yarn list web3-core
yarn list web3-core-promievent

cat ./package.json

# Test
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Running mosaicdao/mosaic-1 unit tests. "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

# Launch ganache
./tools/run_ganache_cli.sh </dev/null 1>/dev/null 2>&1 &
sleep 10

# Compile and test
npx buidler compile
npm test
1 change: 0 additions & 1 deletion scripts/e2e.npm.publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fi
# what it needs here.
npm install -g verdaccio@4.3.4
npm install -g npm-auth-to-token@1.0.0
npm install -g geth-dev-assistant@0.1.3
npm install -g lerna@3.18.3

# Launch npm proxy registry
Expand Down
3 changes: 3 additions & 0 deletions scripts/e2e.truffle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# Exit immediately on error
set -o errexit

# Install test specific dependencies
npm install -g geth-dev-assistant@0.1.3

# Launch geth
npm run geth

Expand Down
59 changes: 59 additions & 0 deletions scripts/js/resolutions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env node

/**
* This script is a helper for running a buidler based e2e unit test target and is
* used in combination with the npm virtual publishing script.
*
* It discovers the current web3 package version, gets its patch increment
* (also the value of the virtually published version) and attaches a yarn resolutions field
* to the target's package.json to coerce any Web3 packages up to the patch when target is
* installed.
*
* USAGE: resolutions.js <target-folder-name>
* EXAMPLE: node scripts/js/resolutions.js mosaic-1
*
*/
const fs = require('fs');
const path = require('path');

const semver = require('semver');
const web3PackagePath = path.join(process.cwd(), 'original.package.json');
const targetPackagePath = path.join(process.cwd(), process.argv[2], 'package.json');

const web3Package = require(web3PackagePath);
const targetPackage = require(targetPackagePath);

const patch = semver.inc(web3Package.version, 'patch');

targetPackage.resolutions = {
"@nomiclabs/**/web3": `${patch}`,
"@nomiclabs/**/web3-bzz": `${patch}`,
"@nomiclabs/**/web3-core-helpers": `${patch}`,
"@nomiclabs/**/web3-core-method": `${patch}`,
"@nomiclabs/**/web3-core-promievent": `${patch}`,
"@nomiclabs/**/web3-core-requestmanager": `${patch}`,
"@nomiclabs/**/web3-core-subscriptions": `${patch}`,
"@nomiclabs/**/web3-core": `${patch}`,
"@nomiclabs/**/web3-eth-abi": `${patch}`,
"@nomiclabs/**/web3-eth-accounts": `${patch}`,
"@nomiclabs/**/web3-eth-contract": `${patch}`,
"@nomiclabs/**/web3-eth-ens": `${patch}`,
"@nomiclabs/**/web3-eth-iban": `${patch}`,
"@nomiclabs/**/web3-eth-personal": `${patch}`,
"@nomiclabs/**/web3-eth": `${patch}`,
"@nomiclabs/**/web3-net": `${patch}`,
"@nomiclabs/**/web3-providers-http": `${patch}`,
"@nomiclabs/**/web3-providers-ipc": `${patch}`,
"@nomiclabs/**/web3-providers-ws": `${patch}`,
"@nomiclabs/**/web3-shh": `${patch}`,
"@nomiclabs/**/web3-utils": `${patch}`
}

console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
console.log(`Yarn will resolve Web3 packages in "${process.argv[2]}"" to...`);
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

console.log(JSON.stringify(targetPackage.resolutions, null, ' '));

fs.writeFileSync(targetPackagePath, JSON.stringify(targetPackage, null, ' '));

2 changes: 1 addition & 1 deletion test/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -3219,7 +3219,7 @@ describe('typical usage', function() {
// done();
// });

}).timeout(6000);
}).timeout(10000);
// TODO add error check
});

Expand Down

0 comments on commit 4d57461

Please sign in to comment.