Skip to content

Commit

Permalink
Merge pull request #4 from lidofinance/fix/callscript-contract-check
Browse files Browse the repository at this point in the history
Check callsScript is a contract in EVMScriptExecutor's constructor
  • Loading branch information
bulbozaur authored Aug 13, 2021
2 parents 3d10897 + 585b9db commit 3f24b81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/EvmScriptExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pragma solidity ^0.8.4;

import "OpenZeppelin/openzeppelin-contracts@4.2.0/contracts/utils/StorageSlot.sol";
import "OpenZeppelin/openzeppelin-contracts@4.2.0/contracts/utils/Address.sol";

interface ICallsScript {
function execScript(
Expand All @@ -22,6 +23,11 @@ contract EVMScriptExecutor {
// -------------
event ScriptExecuted(address indexed _caller, bytes _evmScript);

// -------------
// ERRORS
// -------------
string private constant ERROR_NOT_CONTRACT = "NOT_CONTRACT";

// ------------
// CONSTANTS
// ------------
Expand Down Expand Up @@ -54,6 +60,7 @@ contract EVMScriptExecutor {
address _easyTrack,
address _voting
) {
require(Address.isContract(_callsScript), ERROR_NOT_CONTRACT);
voting = _voting;
easyTrack = _easyTrack;
callsScript = _callsScript;
Expand Down
7 changes: 7 additions & 0 deletions tests/test_evm_script_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def test_deploy(owner, easy_track, calls_script, voting):
assert contract.voting() == voting


def test_deploy_calls_script_not_contract(owner, accounts, easy_track, voting):
"Must revert with message 'NOT_CONTRACT'"
not_contract = accounts[6]
with reverts("NOT_CONTRACT"):
owner.deploy(EVMScriptExecutor, not_contract, easy_track, voting)


def test_execute_evm_script_revert_msg(
voting,
easy_track,
Expand Down

0 comments on commit 3f24b81

Please sign in to comment.