From 53a0a912a1e6360ec780d98f069e2f43a650f0f9 Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Tue, 28 May 2024 15:54:55 +0200 Subject: [PATCH] avoid a crash when invalid filtering is used and provide a better error message (#1258) --- lib/Echidna/Solidity.hs | 3 +++ lib/Echidna/Types/Solidity.hs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Echidna/Solidity.hs b/lib/Echidna/Solidity.hs index b75c19f55..1868ff246 100644 --- a/lib/Echidna/Solidity.hs +++ b/lib/Echidna/Solidity.hs @@ -206,6 +206,9 @@ loadSpecified env name cs = do Just ne -> Map.singleton mainContract.runtimeCodehash ne Nothing -> mempty + when (Map.null abiMapping) $ + throwM $ InvalidMethodFilters solConf.methodFilter + -- Set up initial VM, either with chosen contract or Etheno initialization file -- need to use snd to add to ABI dict initVM <- stToIO $ initialVM solConf.allowFFI diff --git a/lib/Echidna/Types/Solidity.hs b/lib/Echidna/Types/Solidity.hs index 82bcc7a59..792c1b269 100644 --- a/lib/Echidna/Types/Solidity.hs +++ b/lib/Echidna/Types/Solidity.hs @@ -49,7 +49,7 @@ instance Show SolException where OnlyTests -> "Only tests and no public functions found in ABI" ConstructorArgs s -> "Constructor arguments are required: " ++ s NoCryticCompile -> "crytic-compile not installed or not found in PATH. To install it, run:\n pip install crytic-compile" - InvalidMethodFilters f -> "Applying " ++ show f ++ " to the methods produces an empty list. Are you filtering the correct functions or fuzzing the correct contract?" + InvalidMethodFilters f -> "Applying the filter " ++ show f ++ " to the methods produces an empty list. Are you filtering the correct functions using `filterFunctions` or fuzzing the correct contract?" SetUpCallFailed -> "Calling the setUp() function failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.)" DeploymentFailed a t -> "Deploying the contract " ++ show a ++ " failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.):\n" ++ unpack t OutdatedSolcVersion v -> "Solc version " ++ toString v ++ " detected. Echidna doesn't support versions of solc before " ++ toString minSupportedSolcVersion ++ ". Please use a newer version."