Sovryn-smart-contracts icon indicating copy to clipboard operation
Sovryn-smart-contracts copied to clipboard

Emit an event on toggle function pause

Open tjcloa opened this issue 3 years ago • 5 comments

tjcloa avatar Jun 30 '21 08:06 tjcloa

Sovryn-smart-contracts/contracts/connectors/loantoken/LoanTokenSettingsLowerAdmin.sol 175,9: function toggleFunctionPause(

Sovryn-smart-contracts/contracts/mockup/previousLoanToken/PreviousLoanTokenSettingsLowerAdmin.sol 114,9: function toggleFunctionPause(

computerphysicslab avatar Jun 30 '21 10:06 computerphysicslab

Adding test to check event is really emitted.

Sovryn-smart-contracts/tests-js/loan-token/Administration.test.js 127,25: await localLoanToken.toggleFunctionPause(functionSignature, true); 137,25: await localLoanToken.toggleFunctionPause(functionSignature, false); 147,38: await expectRevert(localLoanToken.toggleFunctionPause("mint(address,uint256)", true, { from: accounts[1] }), "onlyPauser");

computerphysicslab avatar Jul 02 '21 11:07 computerphysicslab

Hardhat testing what events were emitted with what arguments:

According to https://ethereum-waffle.readthedocs.io/en/latest/matchers.html?highlight=events#emitting-events this code should work:

await expect(localLoanToken.toggleFunctionPause(functionSignature, true))
    .to.emit(localLoanToken, 'ToggleFunctionPause')
    .withArgs(functionSignature, true);

But it is not! So I had to use this one:

let tx = await localLoanToken.toggleFunctionPause(functionSignature, true);
// Check event is properly emitted
await expectEvent.inTransaction(tx.receipt.rawLogs[0].transactionHash, LoanTokenLogicStandard, "ToggleFunctionPause", {
    funcId: functionSignature,
    isPaused: true,
});

computerphysicslab avatar Jul 02 '21 11:07 computerphysicslab

After adding event, tests are not passing:

Error: Transaction reverted: trying to deploy a contract whose code is too large

computerphysicslab avatar Jul 03 '21 09:07 computerphysicslab

Added event ToggleFunctionPause: https://github.com/DistributedCollective/Sovryn-smart-contracts/commit/6dec0cf13677e78a6e8a90b4a211e1cdc0c4b1b8

Added event check on test: https://github.com/DistributedCollective/Sovryn-smart-contracts/commit/b7bcb0568ca6235c60c496374a2920727d48042b

computerphysicslab avatar Jul 13 '21 08:07 computerphysicslab