From 8f655c247ab1c392447168d71743928cc03de32c Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Wed, 25 Mar 2020 11:26:45 -0300 Subject: [PATCH 1/6] Update install-solc.sh --- .travis/install-solc.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis/install-solc.sh b/.travis/install-solc.sh index eddfb9e7b..d47b90bb6 100755 --- a/.travis/install-solc.sh +++ b/.travis/install-solc.sh @@ -19,6 +19,9 @@ fetch_stack_linux() { wget https://github.com/ethereum/solidity/releases/download/v0.5.7/solc-static-linux; chmod +x solc-static-linux; mv solc-static-linux ~/.local/bin/solc-0.5.7; + wget https://github.com/ethereum/solidity/releases/download/v0.6.2/solc-static-linux; + chmod +x solc-static-linux; + mv solc-static-linux ~/.local/bin/solc-0.6.2; } if [ "$(uname)" != "Darwin" ]; then From 88da913695dba617a891859d5d262880138981b8 Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Wed, 25 Mar 2020 11:27:32 -0300 Subject: [PATCH 2/6] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b4264bd33..5d6397d6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,8 +50,9 @@ script: stack --no-terminal test --ghc-options="$GHC_OPTIONS" $STACK_OPTS } - run_tests_using "solc-0.4.25" + #run_tests_using "solc-0.4.25" run_tests_using "solc-0.5.7" + run_tests_using "solc-0.6.2" set +ex notifications: From b925be370e714ffb5ec1eb9d594cd4fe5f4f8f56 Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Wed, 25 Mar 2020 12:10:13 -0300 Subject: [PATCH 3/6] Disabled fallback test --- src/test/Spec.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/Spec.hs b/src/test/Spec.hs index 4d991b7ac..15ee5d536 100644 --- a/src/test/Spec.hs +++ b/src/test/Spec.hs @@ -191,8 +191,8 @@ integrationTests = testGroup "Solidity Integration Testing" [ ("echidna_balance failed", passed "echidna_balance") ] , testContract "basic/library.sol" (Just "basic/library.yaml") [ ("echidna_library_call failed", solved "echidna_library_call") ] - , testContract "basic/fallback.sol" Nothing - [ ("echidna_fallback failed", solved "echidna_fallback") ] +-- , testContract "basic/fallback.sol" Nothing +-- [ ("echidna_fallback failed", solved "echidna_fallback") ] , testContract "basic/darray.sol" Nothing [ ("echidna_darray passed", solved "echidna_darray") , ("echidna_darray didn't shrink optimally", solvedLen 1 "echidna_darray") ] From 6bd0f61e83d2396df63f99793a57ae87fd44371d Mon Sep 17 00:00:00 2001 From: Will Song Date: Wed, 25 Mar 2020 15:30:57 -0400 Subject: [PATCH 4/6] refactor version specific testing --- src/test/Spec.hs | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/test/Spec.hs b/src/test/Spec.hs index 15ee5d536..33a24c8a9 100644 --- a/src/test/Spec.hs +++ b/src/test/Spec.hs @@ -157,7 +157,7 @@ integrationTests = testGroup "Solidity Integration Testing" , testContract "basic/nearbyMining.sol" (Just "coverage/test.yaml") [ ("echidna_findNearby passed", solved "echidna_findNearby") ] - , testContract' "basic/smallValues.sol" Nothing (Just "coverage/test.yaml") False + , testContract' "basic/smallValues.sol" Nothing (Just "coverage/test.yaml") False Nothing [ ("echidna_findSmall passed", solved "echidna_findSmall") ] , testContract "basic/multisender.sol" (Just "basic/multisender.yaml") $ @@ -180,7 +180,7 @@ integrationTests = testGroup "Solidity Integration Testing" [ ("echidna_found_sender failed", solved "echidna_found_sender") ] , testContract "basic/rconstants.sol" Nothing [ ("echidna_found failed", solved "echidna_found") ] - , testContract' "basic/cons-create-2.sol" (Just "C") Nothing True + , testContract' "basic/cons-create-2.sol" (Just "C") Nothing True Nothing [ ("echidna_state failed", solved "echidna_state") ] -- single.sol is really slow and kind of unstable. it also messes up travis. -- , testContract "coverage/single.sol" (Just "coverage/test.yaml") @@ -191,8 +191,8 @@ integrationTests = testGroup "Solidity Integration Testing" [ ("echidna_balance failed", passed "echidna_balance") ] , testContract "basic/library.sol" (Just "basic/library.yaml") [ ("echidna_library_call failed", solved "echidna_library_call") ] --- , testContract "basic/fallback.sol" Nothing --- [ ("echidna_fallback failed", solved "echidna_fallback") ] + , testContract' "basic/fallback.sol" Nothing Nothing True (Just ["0.4.25", "0.5.7"]) + [ ("echidna_fallback failed", solved "echidna_fallback") ] , testContract "basic/darray.sol" Nothing [ ("echidna_darray passed", solved "echidna_darray") , ("echidna_darray didn't shrink optimally", solvedLen 1 "echidna_darray") ] @@ -207,14 +207,9 @@ integrationTests = testGroup "Solidity Integration Testing" [ ("echidna_construct passed", solved "echidna_construct") ] , testContract "basic/gasprice.sol" Nothing [ ("echidna_state passed", solved "echidna_state") ] - , let fp = "basic_multicontract/contracts/Foo.sol"; cfg = Just "basic_multicontract/echidna_config.yaml" in - testCase fp $ - do sv <- readProcess "solc" ["--version"] "" - when ("Version: 0.4.25" `isInfixOf` sv) $ do - c <- set (sConf . quiet) True <$> maybe (pure testConfig) (fmap _econfig . parseConfig) cfg - res <- runContract fp (Just "Foo") c - assertBool "echidna_test passed" $ solved "echidna_test" res - , testContract' "basic/multi-abi.sol" (Just "B") (Just "basic/multi-abi.yaml") True + , testContract' "basic_multicontract/contracts/Foo.sol" Nothing (Just "basic_multicontract/echidna_config.yaml") True (Just ["0.4.25"]) + [ ("echidna_test passed", solved "echidna_test") ] + , testContract' "basic/multi-abi.sol" (Just "B") (Just "basic/multi-abi.yaml") True Nothing [ ("echidna_test passed", solved "echidna_test") ] , testContract "abiv2/Ballot.sol" Nothing [ ("echidna_test passed", solved "echidna_test") ] @@ -246,15 +241,22 @@ testConfig = defaultConfig & sConf . quiet .~ True & cConf .~ (defaultConfig ^. cConf) { testLimit = 10000, shrinkLimit = 2500 } testContract :: FilePath -> Maybe FilePath -> [(String, Campaign -> Bool)] -> TestTree -testContract fp cfg = testContract' fp Nothing cfg True - -testContract' :: FilePath -> Maybe Text -> Maybe FilePath -> Bool -> [(String, Campaign -> Bool)] -> TestTree -testContract' fp n cfg s as = testCase fp $ do - c <- set (sConf . quiet) True <$> maybe (pure testConfig) (fmap _econfig . parseConfig) cfg - let c' = c & sConf . quiet .~ True - & if s then cConf .~ (c ^. cConf) { testLimit = 10000, shrinkLimit = 2500 } else id - res <- runContract fp n c' - mapM_ (\(t,f) -> assertBool t $ f res) as +testContract fp cfg = + testContract' fp Nothing cfg True Nothing + +testContract' :: FilePath -> Maybe Text -> Maybe FilePath -> Bool -> Maybe [String] -> [(String, Campaign -> Bool)] -> TestTree +testContract' fp n cfg s vs as = testCase fp $ + case vs of + Just vs' -> do + sv <- readProcess "solc" ["--version"] "" + when (any (`isInfixOf` sv) (("Version: "<>) <$> vs')) doTest + Nothing -> doTest + where doTest = do + c <- set (sConf . quiet) True <$> maybe (pure testConfig) (fmap _econfig . parseConfig) cfg + let c' = c & sConf . quiet .~ True + & if s then cConf .~ (c ^. cConf) { testLimit = 10000, shrinkLimit = 2500 } else id + res <- runContract fp n c' + mapM_ (\(t,f) -> assertBool t $ f res) as runContract :: FilePath -> Maybe Text -> EConfig -> IO Campaign runContract fp n c = @@ -299,7 +301,6 @@ solvedLen i t = (== Just i) . fmap length . solnFor t solvedWith :: SolCall -> Text -> Campaign -> Bool solvedWith c t = maybe False (any $ (== SolCall c) . view call) . solnFor t - -- Encoding JSON tests instance Arbitrary Addr where From 6105782072d6f1069e7943a771e9f17f14b0f016 Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Tue, 31 Mar 2020 11:43:51 -0300 Subject: [PATCH 5/6] Missing space --- src/test/Spec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/Spec.hs b/src/test/Spec.hs index 33a24c8a9..0b0ddfa5f 100644 --- a/src/test/Spec.hs +++ b/src/test/Spec.hs @@ -249,7 +249,7 @@ testContract' fp n cfg s vs as = testCase fp $ case vs of Just vs' -> do sv <- readProcess "solc" ["--version"] "" - when (any (`isInfixOf` sv) (("Version: "<>) <$> vs')) doTest + when (any (`isInfixOf` sv) (("Version: " <>) <$> vs')) doTest Nothing -> doTest where doTest = do c <- set (sConf . quiet) True <$> maybe (pure testConfig) (fmap _econfig . parseConfig) cfg From 0d8381530a2252b951e4b4d726517c9cc091a156 Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Tue, 31 Mar 2020 11:56:04 -0300 Subject: [PATCH 6/6] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5d6397d6f..aaa59fb73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ script: stack --no-terminal test --ghc-options="$GHC_OPTIONS" $STACK_OPTS } - #run_tests_using "solc-0.4.25" + run_tests_using "solc-0.4.25" run_tests_using "solc-0.5.7" run_tests_using "solc-0.6.2" set +ex