Sovryn-smart-contracts
Sovryn-smart-contracts copied to clipboard
Emit an event on toggle function pause
Sovryn-smart-contracts/contracts/connectors/loantoken/LoanTokenSettingsLowerAdmin.sol 175,9: function toggleFunctionPause(
Sovryn-smart-contracts/contracts/mockup/previousLoanToken/PreviousLoanTokenSettingsLowerAdmin.sol 114,9: function toggleFunctionPause(
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");
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,
});
After adding event, tests are not passing:
Error: Transaction reverted: trying to deploy a contract whose code is too large
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