DistributedCollective / Sovryn-smart-contracts

Smart contracts for the Sovryn protocol and external integrations
https://live.sovryn.app/
Apache License 2.0
124 stars 46 forks source link

Emit an event on toggle function pause #297

Open tjcloa opened 3 years ago

computerphysicslab commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

After adding event, tests are not passing:

Error: Transaction reverted: trying to deploy a contract whose code is too large
computerphysicslab commented 3 years ago

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