Skip to content

Commit

Permalink
Merge branch '1.x' into provider-related-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Jan 15, 2020
2 parents 7b6a389 + 513116f commit f937631
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
- node_js: 10
env: TEST=unit_and_e2e_clients
- node_js: 10
env: TEST=e2e_truffle
env: TEST=e2e_ganache
- node_js: 10
env: TEST=e2e_mosaic
- node_js: 10
Expand All @@ -27,7 +27,7 @@ matrix:
firefox: latest
allow_failures:
- node_js: 10
env: TEST=e2e_truffle
env: TEST=e2e_ganache
- node_js: 10
env: TEST=e2e_mosaic

Expand All @@ -49,7 +49,7 @@ before_install:
- export DISPLAY=:99.0
- export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
install:
- if [[ $TEST != "e2e_truffle" ]] && [[ $TEST != "e2e_mosaic" ]]; then
- if [[ $TEST != "e2e_ganache" ]] && [[ $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 @@ -46,6 +46,7 @@
"test:e2e:publish": "./scripts/e2e.npm.publish.sh",
"test:e2e:truffle": "./scripts/e2e.truffle.sh",
"test:e2e:mosaic": "./scripts/e2e.mosaic.sh",
"test:e2e:ganache:core": "./scripts/e2e.ganache.core.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 @@ -44,4 +44,9 @@ elif [ "$TEST" = "e2e_mosaic" ]; then
npm run test:e2e:publish
npm run test:e2e:mosaic

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

npm run test:e2e:publish
npm run test:e2e:ganache:core

fi
48 changes: 48 additions & 0 deletions scripts/e2e.ganache.core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ----------------------------------------------------------------------------------------
# Run trufflesuite/ganache-core 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
# ----------------------------------------------------------------------------------------

# Exit immediately on error
set -o errexit

# Install ganache-core
git clone https://github.com/trufflesuite/ganache-core
cd ganache-core

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

npm install
npm uninstall --save-dev web3
npm install --save-dev web3@e2e --registry http://localhost:4873

npm list web3
npm list web3-utils
npm list web3-core
npm list web3-core-promievent

cat ./package.json

# Test
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Running trufflesuite/ganache-core unit tests. "
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

npm run build

# NB: there's one failing ganache test, which checks
# whether the object returned by the server is an
# instanceof StateManager. Also fails locally & doesn't
# seem web3 related. Skipping it with grep / invert.
TEST_BUILD=node npx mocha \
--grep "instance of" \
--invert \
--check-leaks \
--recursive \
--globals _scratch \
--opts ./test/.mocharc
2 changes: 1 addition & 1 deletion scripts/e2e.geth.automine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ echo " "
geth-dev-assistant --period 2 --accounts 1 --tag 'stable'

# Test
nyc --no-clean --silent _mocha -- \
GETH_AUTOMINE=true nyc --no-clean --silent _mocha -- \
--reporter spec \
--grep 'E2E' \
--timeout 15000 \
Expand Down
5 changes: 5 additions & 0 deletions scripts/e2e.truffle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

# --------------------------------------------------------------------------------
# NB: This script temporarily removed from CI while truffle remains on Web3@1.2.1.
# To re-enable, add a `env: TEST=e2e_truffle` job to the matrix in travis.yml.
# --------------------------------------------------------------------------------

# -------------------------------------------------------------------------
# Run @truffle/contract's unit tests using a candidate branch of web3
# which has been published to a proxy npm registry in `e2e.npm.publish.sh`
Expand Down
23 changes: 23 additions & 0 deletions test/e2e.contract.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,29 @@ describe('contract.deploy [ @E2E ]', function() {
assert(err.receipt.status === false);
}
});

it('fires the confirmation handler', function(){
// Http confirmations poll at 1s interval.
// Automine has a 2s interval.
if (!process.env.GETH_AUTOMINE) return;

return new Promise(async (resolve, reject) => {
var startBlock = await web3.eth.getBlockNumber();

await basic
.deploy()
.send({from: accounts[0]})
.on('confirmation', async (number, receipt) => {
assert(receipt.contractAddress);

if (number === 1) { // Confirmation numbers are zero indexed
var endBlock = await web3.eth.getBlockNumber();
assert(endBlock >= (startBlock + 2));
resolve();
}
})
});
});
});

describe('ws', function() {
Expand Down
52 changes: 52 additions & 0 deletions test/e2e.method.signing.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,58 @@ describe('transaction and message signing [ @E2E ]', function() {
}
});

it('wallet executes method call using chain & hardfork options', async function(){
// Geth --dev errors with 'invalid sender' when using these options.
// Requires a custom common configuration (see next test). Ganache doesn't care
if(!process.env.GANACHE) return;

basic = new web3.eth.Contract(Basic.abi, basicOptions);
basic.defaultChain = 'mainnet';
basic.defaultHardfork = 'istanbul';

instance = await basic
.deploy()
.send({from: wallet[0].address});

const receipt = await instance
.methods
.setValue('1')
.send({from: wallet[0].address});

assert(receipt.status === true);
assert(web3.utils.isHexStrict(receipt.transactionHash));
});

it('wallet executes method call using customCommon option', async function(){
const networkId = await web3.eth.net.getId();
const chainId = await web3.eth.getChainId();

const customCommon = {
baseChain: 'mainnet',
customChain: {
name: 'custom-network',
networkId: networkId,
chainId: chainId,
},
harfork: 'istanbul',
};

basic = new web3.eth.Contract(Basic.abi, basicOptions);
basic.defaultCommon = customCommon;

instance = await basic
.deploy()
.send({from: wallet[0].address});

const receipt = await instance
.methods
.setValue('1')
.send({from: wallet[0].address});

assert(receipt.status === true);
assert(web3.utils.isHexStrict(receipt.transactionHash));
});

it('transactions sent with wallet throws error correctly (with receipt)', async function(){
const data = instance
.methods
Expand Down

0 comments on commit f937631

Please sign in to comment.