diff --git a/.travis.yml b/.travis.yml index 3e0f671b778..7c104d1270a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -26,6 +28,8 @@ matrix: allow_failures: - node_js: 10 env: TEST=e2e_truffle + - node_js: 10 + env: TEST=e2e_mosaic addons: apt: @@ -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: diff --git a/package.json b/package.json index c2a284a3422..b570969283a 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/scripts/ci.sh b/scripts/ci.sh index a1d5e11994a..584ee6431b1 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -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 diff --git a/scripts/e2e.mosaic.sh b/scripts/e2e.mosaic.sh new file mode 100755 index 00000000000..26d84019428 --- /dev/null +++ b/scripts/e2e.mosaic.sh @@ -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 2>&1 & +sleep 10 + +# Compile and test +npx buidler compile +npm test diff --git a/scripts/e2e.npm.publish.sh b/scripts/e2e.npm.publish.sh index b71595f3ad5..884004ccbf2 100755 --- a/scripts/e2e.npm.publish.sh +++ b/scripts/e2e.npm.publish.sh @@ -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 diff --git a/scripts/e2e.truffle.sh b/scripts/e2e.truffle.sh index 984931ab117..1a1b6fa2771 100755 --- a/scripts/e2e.truffle.sh +++ b/scripts/e2e.truffle.sh @@ -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 diff --git a/scripts/js/resolutions.js b/scripts/js/resolutions.js new file mode 100755 index 00000000000..b6134829c16 --- /dev/null +++ b/scripts/js/resolutions.js @@ -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 + * 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, ' ')); + diff --git a/test/contract.js b/test/contract.js index b727ee937b8..7c2d43ec53f 100644 --- a/test/contract.js +++ b/test/contract.js @@ -3219,7 +3219,7 @@ describe('typical usage', function() { // done(); // }); - }).timeout(6000); + }).timeout(10000); // TODO add error check });