Unit testing 'utility belt' for Ethereum Solidity contracts
npm install chaithereum
const Chaithereum = require('chaithereum')
const chaithereum = new Chaithereum(/*options*/)
One good place to look for chaithereum examples is the safemarket/protocol repo. Those tests were written with chaithereum@1.0, however their API is the same. The only difference is that in chaithereum@2.0, require('chaithereum')
returns a Chaithereum
constructor instead of a chaithereum
instance.
A Web3 constructor. Default listed in package.json.
A chai instance. Default listed in package.json.
A Web3 provider instance. Default is provider generated by testrpc listed in package.json
A custom chai instance
A custom web3 instance suited for unit testing
The provider used to instantiate web3
A Q promise that will be fulfilled when chaithereum is ready. Typically you would start a test waiting for the chaitheruem promise.
before(() => { return chaithereum.promise })
A list of 10 accounts
The first account, set as web3.eth.defaultAccount
Generate an address asynchronously. chaithereum.generateAddress().then((address) => { ... }))
Generate an addresses asynchronously. chaithereum.generateAddresses(5).then((addresses[5]) => { ... }))
Jump forward in time asynchronously. chaithereum.increaseTime(42).then(() => { ... }))
Mine a block. chaithereum.mineBlock().then(() => { ... }))
Mine count
blocks. chaithereum.mineBlocks(...).then(() => { ... }))
Take a snapshot of the current state. chaithereum.takeSnapshot(...).then((id) => { ... }))
Take a snapshot of the current state. chaithereum.revertSnapshot(...).then(() => { ... }))
Chaithereum loads bindings from the following packages