November 2018
Intermediate to advanced
528 pages
13h 21m
English
We start by removing the redundancy in the test block as we did previously for the Cplayer tests. We will create a beforeEach hook, which takes care of the contract's creation and adds three players to the Cplayer instance. All these elements will help us to perform unit tests for the Ctontine contract. Keep in mind that all the Ctontine tests should be defined within the second contract function in the test file. As a result, we add the following code to the Ctontine test suite:
contract('Ctontine', function(accounts) { const [firstAccount, secondAccount, thirdAccount] = accounts; let Cp; let Ct; beforeEach(async function() { Cp = await Cplayer.new(); Ct = await Ctontine.new(Cp.address); for (let i = 0; i < 3; i++) { await ...Read now
Unlock full access