Add more tests

This commit is contained in:
Amir Bandeali 2019-09-13 15:29:07 -05:00
parent 057aee8ad2
commit 6fd55b2f49
3 changed files with 33 additions and 2 deletions

View File

@ -155,7 +155,7 @@ contract AssetProxyOwner is
// Ensure that function call was successful
require(
didSucceed,
"EXECUTION_FAILURE"
"FAILED_EXECUTION"
);
}
emit Execution(transactionId);

View File

@ -31,12 +31,19 @@ contract ContractCallReceiver {
uint256 value
);
bytes4 constant internal ALWAYS_REVERT_SELECTOR = 0xF1F2F3F4;
function ()
external
payable
{
bytes4 selector = msg.data.readBytes4(0);
if (selector == ALWAYS_REVERT_SELECTOR) {
revert();
}
emit ContractCall(
msg.data.readBytes4(0),
selector,
msg.data,
msg.value
);

View File

@ -586,6 +586,30 @@ blockchainTests.resets('AssetProxyOwner', env => {
const tx = assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(results.txId);
expect(tx).to.revertWith(RevertReason.TxAlreadyExecuted);
});
it('should revert if the only call is unsuccessful', async () => {
const alwaysRevertSelector = '0xF1F2F3F4';
const data = [alwaysRevertSelector];
const destinations = [receiver.address];
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
data,
destinations,
signerAddresses,
DEFAULT_TIME_LOCK,
);
expect(tx).to.revertWith(RevertReason.FailedExecution);
});
it('should revert if the any call is unsuccessful', async () => {
const alwaysRevertSelector = '0xF1F2F3F4';
const data = [hexRandom(), alwaysRevertSelector];
const destinations = [receiver.address, receiver.address];
const tx = assetProxyOwnerWrapper.submitConfirmAndExecuteTransactionAsync(
data,
destinations,
signerAddresses,
DEFAULT_TIME_LOCK,
);
expect(tx).to.revertWith(RevertReason.FailedExecution);
});
it('should be able to call registerFunctionCall after the default timelock', async () => {
const reg = createFunctionRegistration(1, 1, 1);
const data = [