import { BigNumberish , Wallet } from 'ethers' ; import { solidity } from 'ethereum-waffle' ; import { expect , use } from 'chai' ; import { MAX_BURN_BOUND } from 'utils' ; import { loadFixture } from 'fixtures/beforeEachWithFixture' ; import { TrueGold , TrueGold__factory , } from 'contracts' ; use ( solidity ) ; describe ( 'TrueGold - Initializable' , ( ) => { let proxy ; let token ; async function fixture ( [ deployer , proxy ] ) { const trueGoldFactory = new TrueGold__factory ( deployer ) ; const token = await trueGoldFactory . deploy ( ) ; return { proxy , token } ; } beforeEach ( async ( ) => { ( { proxy , token } = await loadFixture ( fixture ) ) ; } ) ; function initialize ( caller , minBurnAmount = 12441000 , maxBurnAmount = MAX_BURN_BOUND ) { return token . connect ( caller ) . initialize ( minBurnAmount , maxBurnAmount ) ; } describe ( 'initialize' , ( ) => { it ( 'can be called by other address than contract deployer' , async ( ) => { await expect ( initialize ( proxy ) ) . not . to . be . reverted ; } ) ; it ( 'cannot be called twice' , async ( ) => { await initialize ( proxy ) ; await expect ( initialize ( proxy ) ) . to . be . revertedWith ( 'Contract instance has already been initialized' ) ; } ) ; it ( 'makes the caller the owner of the contract' , async ( ) => { await initialize ( proxy ) ; expect ( await token . owner ( ) ) . to . eq ( proxy . address ) ; } ) ; it ( 'sets burn bounds' , async ( ) => { await initialize ( proxy ) ; expect ( await token . burnMin ( ) ) . to . eq ( 12441000 ) ; expect ( await token . burnMax ( ) ) . to . eq ( MAX_BURN_BOUND ) ; } ) ; it ( 'validates burn bounds values' , async ( ) => { await expect ( initialize ( proxy , 8000000 , MAX_BURN_BOUND ) ) . to . be . revertedWith ( 'TrueGold: min amount is not a multiple of 12,441,000' ) ; await expect ( initialize ( proxy , 0 , 8000000 ) ) . to . be . revertedWith ( 'TrueGold: max amount is not a multiple of 12,441,000' ) ; await expect ( initialize ( proxy , 12441000 * 2 , 12441000 ) ) . to . be . revertedWith ( 'TrueMintableBurnable: min is greater then max' ) ; } ) ; } ) ; } ) ;