November 2018
Intermediate to advanced
528 pages
13h 21m
English
The tests for out token sale contract will be slightly more involved as they will require references to both our contracts.
We will start by creating a new file, PacktTokenSale.test.js, in the test/ directory of our project. At the head of the file we require abstractions of both contracts:
var PacktTokenSale = artifacts.require('./PacktTokenSale.sol');var PacktToken = artifacts.require('./PacktToken');
We can then set up some variables for use during the tests:
contract('PacktTokenSale', async (accounts) => { let owner = accounts[0]; let buyer = accounts[1]; let tokensToSell = 500000; let tokenPrice = 1000000000000000; let numberOfTokens; ...});We are using Ganache's first address as the owner of the sale, ...
Read now
Unlock full access