Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
samalws-tob committed Apr 10, 2024
1 parent b37911d commit 795226d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/test/Tests/Symbolic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ module Tests.Symbolic (symbolicTests) where

import System.Info (os)
import Test.Tasty (TestTree, testGroup)
import Common (testContract', solved)
import Common (testContract', solved, passed)
import Echidna.Types.Campaign (WorkerType(..))

symbolicTests :: TestTree
symbolicTests = testGroup "Symbolic tests" $ if os /= "linux" then [] else
[
testContract' "symbolic/sym.sol" Nothing Nothing (Just "symbolic/sym.yaml") True SymbolicWorker
[ testContract' "symbolic/sym.sol" Nothing Nothing (Just "symbolic/sym.yaml") True SymbolicWorker
[ ("echidna_sym passed", passed "echidna_sym") ]

, testContract' "symbolic/sym-assert.sol" Nothing Nothing (Just "symbolic/sym-assert.yaml") True SymbolicWorker
[ ("func_one passed", solved "func_one")
, ("func_two passed", solved "func_two") ]
]
15 changes: 15 additions & 0 deletions tests/solidity/symbolic/sym-assert.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
contract VulnerableContract {
mapping (uint256 => uint256) a;
function func_one(uint256 x) public payable {
a[12323] = ((x >> 5) / 7777);
if (a[12323] == 2222) {
assert(false); // BUG
}
}

function func_two(uint256 x) public payable {
if ((x >> 5) / 7777 == 2222) {
assert(false); // BUG
}
}
}
3 changes: 3 additions & 0 deletions tests/solidity/symbolic/sym-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testMode: assertion
symExec: true
workers: 0
10 changes: 8 additions & 2 deletions tests/solidity/symbolic/sym.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
contract VulnerableContract {
mapping (uint256 => uint256) a;
bool y;
bool z;
function func_one(uint256 x) public payable {
a[12323] = ((x >> 5) / 7777);
if (a[12323] == 2222) {
assert(false); // BUG
y = true;
}
}

function func_two(uint256 x) public payable {
if ((x >> 5) / 7777 == 2222) {
assert(false); // BUG
z = true;
}
}

function echidna_sym() public returns (bool) {
return !(y && z);
}
}
1 change: 0 additions & 1 deletion tests/solidity/symbolic/sym.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
testMode: assertion
symExec: true
workers: 0

0 comments on commit 795226d

Please sign in to comment.