@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
21 lines (20 loc) • 695 B
JavaScript
import { assert } from "chai";
import { network } from "hardhat";
async function tryCatch(promise, reason) {
try {
const tx = await promise;
await tx.wait();
throw null;
}
catch (error) {
assert(error, "Expected an error but did not get one");
assert(error.message.includes(reason), `Expected an ${reason} error`);
}
}
const revertReason = network.name === "hardhat" ? "VM Exception while processing transaction" : "execution reverted";
export const catchRevert = async function (promise) {
await tryCatch(promise, revertReason);
};
export const catchOutOfGas = async function (promise) {
await tryCatch(promise, "out of gas");
};