-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinbox.test.js
30 lines (27 loc) · 930 Bytes
/
inbox.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const assert = require('assert');
const ganache = require('ganache-cli')
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const { interface, bytecode } = require('../compile');
let accounts;
let inbox;
beforeEach(async () => {
accounts = await web3.eth.getAccounts();
inbox= await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: bytecode, arguments: ['Hi there!']})
.send({from : accounts[0], gas: '1000000'})
});
describe('Inbox', () => {
it('deploy a contract', () => {
assert.ok(inbox.options.address);
});
it('has a default message', async () => {
const message=await inbox.methods.message().call();
assert.equal(message,"Hi there!");
});
it('can change the message', async () => {
await inbox.methods.setMessage('bye').send({ from: accounts[0] })
const message=await inbox.methods.message().call();
assert.equal(message,'bye');
});
});