Add awaitTransactionMinedAsync after every sent transaction
This commit is contained in:
@@ -48,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);
|
||||
@@ -62,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,
|
||||
@@ -71,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();
|
||||
});
|
||||
@@ -92,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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user