Skip to content

Commit

Permalink
Update example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
marekkirejczyk authored Jul 16, 2018
1 parent 7885d26 commit 9b52fd1
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,58 @@ Sweeter and simpler than truffle. Taste best with web3js, chai and ES6.
* No need to run mock rpc server

## Philosophy
* Clear, simple syntax, utilize ES6 constructions
* Simplicity over complexity
* Lib (toolbox) rather than framework
* Explicite over implicte (no magic!)
* Easy to customize
* Easy to customize and extend

## Using:
## Install:
To start using with npm, type:
```sh
npm i ethereum-waffle
```

or with Yarn:
```sh
yarn add ethereum-waffle
```

### First test
```js
import createWeb3 from 'ethereum-waffle';
import aContractJson from '../build/aContract.json';
import StandardToken from '../build/StandardToken.json';

describe('A contract', () => {
describe('StandardToken', () => {
const amount = 100;
let web3;
let from;
let aContract;
let accounts;
let token;
let to;
let from;

beforeEach(async () => {
web3 = createWeb3();
[from] = await web3.eth.getAccounts();
aContract = await deployContract(aContractJson);
{web3, [from]} = createWeb3();
token = await deployContract(StandardTokenMock.new(account[0], amount));
});

it("Should add and emit event", async () => {
it("Should transfer", async () => {
const [from] = accounts;
await token.methods.transfer(to, amount).send({from});

expect(await token.balanceOf(from)).to.eq('0');
expect(await token.balanceOf(to)).to.eq('0');
const recipientBalance = await this.token.balanceOf(to);
assert.equal(recipientBalance, amount);

expect(await aContract.methods.transfer().send({from})).to.emitEvent('Transfered').withParams(...);
});

it("Transfer should emit event", async () => {
expect(token.methods.transfer(to, amount).send({from})).to
.to.emitEvent('Transfered')
.withParams(from, to, amount);
});
}
```
Expand Down

0 comments on commit 9b52fd1

Please sign in to comment.