Last active
January 11, 2019 09:00
-
-
Save twxia/7ad4f15d7b5e285cd8f14255b5c097c3 to your computer and use it in GitHub Desktop.
Wrap contract with web3.js v1.0.0 instead truffle-contract in truffle solidity unit testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3'); // v1.0.0 | |
const Election = artifacts.require('ElectionMock'); | |
contract ('Election', (accounts) => { | |
const web3 = new Web3(new Web3.providers.WebsocketProvider('ws://127.0.0.1:8545')); | |
let election; | |
before('setup web3 contract', async () => { | |
await Election.new(); | |
}); | |
beforeEach('setup contract for each test', async () => { | |
const deployedContract = await Election.deployed(); | |
election = new web3.eth.Contract( | |
deployedContract.abi, | |
deployedContract.address, | |
) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment