diff options
Diffstat (limited to 'packages/contracts/test/asset_proxy/authorizable.ts')
-rw-r--r-- | packages/contracts/test/asset_proxy/authorizable.ts | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts index 636b9096b..52e9ea87f 100644 --- a/packages/contracts/test/asset_proxy/authorizable.ts +++ b/packages/contracts/test/asset_proxy/authorizable.ts @@ -20,6 +20,12 @@ describe('Authorizable', () => { let address: string; let authorizable: MixinAuthorizableContract; before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = address = accounts[0]; notOwner = accounts[1]; @@ -42,12 +48,18 @@ describe('Authorizable', () => { ).to.be.rejectedWith(constants.REVERT); }); it('should allow owner to add an authorized address', async () => { - await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const isAuthorized = await authorizable.authorized.callAsync(address); expect(isAuthorized).to.be.true(); }); it('should throw if owner attempts to authorize a duplicate address', async () => { - await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); return expect( authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), ).to.be.rejectedWith(constants.REVERT); @@ -56,7 +68,10 @@ describe('Authorizable', () => { describe('removeAuthorizedAddress', () => { it('should throw if not called by owner', async () => { - await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); return expect( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner, @@ -65,10 +80,16 @@ describe('Authorizable', () => { }); it('should allow owner to remove an authorized address', async () => { - await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }); - await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const isAuthorized = await authorizable.authorized.callAsync(address); expect(isAuthorized).to.be.false(); }); @@ -86,16 +107,22 @@ describe('Authorizable', () => { it('should return all authorized addresses', async () => { const initial = await authorizable.getAuthorizedAddresses.callAsync(); expect(initial).to.have.length(0); - await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); expect(afterAdd).to.have.length(1); expect(afterAdd).to.include(address); - await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); expect(afterRemove).to.have.length(0); }); |