New answers tagged

1

As said by @shane you can run the command with the networkId flag or alternatively you can change your config to '*' to match any id provided by ganache.


1

You can set the ganache-cli network ID by using a flag when running it: ganache-cli --networkId 4447


2

Per this comment on solc-js issue #31, you can append this stanza to package.json. "jest": { "testEnvironment": "node" } (which I guess tells jest to run in node, which will bring in the things that solc needs).


2

I needed a promise-based solution that didn't require installing a third-party library. Copy-pasting from Ethan Wessel's amazing article on truffle time testing: advanceTime = (time) => { return new Promise((resolve, reject) => { web3.currentProvider.send({ jsonrpc: '2.0', method: 'evm_increaseTime', params: [time], id: ...


0

On top of Rosco's and Nick's answers, it could also be helpful to know the --show-events flag for debugging. You can use it like this: truffle test --show-events


1

The truffle-assertion package can easily help with this. Once the package is installed you can run the following: // Import the package to your file const truffleAssert = require('truffle-assertions'); // Deploy the contract let testContract = await TestContract.new() // Get the hash of the deployment transaction let txHash = testContract.transactionHash ...


1

It bears noticing that web3.utils.keccak256 and web3.utils.sha3 are synonyms, so no point using both. You should use keccak256, if given a choice, because the function it implements is not actually Sha3 as defined in the NIST standard, but rather a different function (an early implemementation of Keccak256, before it was modified for the SHA3 standard). I've ...


Top 50 recent answers are included