Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions test/f_ether_dividends.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ contract("EtherDividendCheckpoint", async (accounts) => {

it("Should not allow reclaiming withholding tax with incorrect index", async () => {
await catchRevert(
I_EtherDividendCheckpoint.withdrawWithholding(300, { from: token_owner, gasPrice: 0 }),
"tx -> failed because dividend index is not valid"
I_EtherDividendCheckpoint.withdrawWithholding(300, { from: token_owner, gasPrice: 0 })
);
});

Expand Down Expand Up @@ -580,8 +579,7 @@ contract("EtherDividendCheckpoint", async (accounts) => {
I_EtherDividendCheckpoint.createDividendWithCheckpointAndExclusions(maturity, expiry, 4, addresses, dividendName, {
from: token_owner,
value: new BN(web3.utils.toWei("10", "ether"))
}),
"tx -> failed because too many address excluded"
})
);
});

Expand Down
26 changes: 8 additions & 18 deletions test/helpers/exceptions.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
const PREFIX = "VM Exception while processing transaction: ";
const PREFIX2 = "Returned error: VM Exception while processing transaction: ";

async function tryCatch(promise, message) {
async function tryCatch(promise, expectedError) {
try {
await promise;
throw null;
} catch (error) {
assert(error, "Expected an error but did not get one");
try {
assert(
error.message.startsWith(PREFIX + message),
"Expected an error starting with '" + PREFIX + message + "' but got '" + error.message + "' instead"
);
} catch (err) {
assert(
error.message.startsWith(PREFIX2 + message),
"Expected an error starting with '" + PREFIX + message + "' but got '" + error.message + "' instead"
);
if (error.message.indexOf(expectedError) === -1) {
throw Error(`Wrong failure type, expected '${expectedError}' and got '${error.message}'`);
}
return;
}

throw Error('Expected failure not received');
}

module.exports = {
catchRevert: async function(promise) {
await tryCatch(promise, "revert");
catchRevert: async function(promise, message = 'revert') {
await tryCatch(promise, message);
},
catchPermission: async function(promise) {
await tryCatch(promise, "revert Permission check failed");
Expand Down
9 changes: 3 additions & 6 deletions test/k_module_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ contract("ModuleRegistry", async (accounts) => {
catchRevert(
I_ModuleRegistryProxy.upgradeToAndCall("1.0.0", I_ModuleRegistry.address, bytesProxy, {
from: account_polymath
}),
"tx-> revert because polymathRegistry address is 0x"
})
);
});

Expand All @@ -165,8 +164,7 @@ contract("ModuleRegistry", async (accounts) => {
catchRevert(
I_ModuleRegistryProxy.upgradeToAndCall("1.0.0", I_ModuleRegistry.address, bytesProxy, {
from: account_polymath
}),
"tx-> revert because owner address is 0x"
})
);
});

Expand All @@ -175,8 +173,7 @@ contract("ModuleRegistry", async (accounts) => {
catchRevert(
I_ModuleRegistryProxy.upgradeToAndCall("1.0.0", I_ModuleRegistry.address, bytesProxy, {
from: account_polymath
}),
"tx-> revert because all params are 0x"
})
);
});

Expand Down
Loading