Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Echidna/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ genTx world deployedContracts = do
genDelay :: MonadRandom m => W256 -> Set W256 -> m W256
genDelay mv ds =
join $ oftenUsually fromDict randValue
where randValue = fromIntegral <$> getRandomR (1 :: Integer, fromIntegral mv)
where randValue = fromIntegral <$> getRandomR (0 :: Integer, fromIntegral mv)
fromDict = (`mod` (mv + 1)) <$> rElem' ds

genValue
Expand Down
3 changes: 3 additions & 0 deletions src/test/Tests/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ integrationTests = testGroup "Solidity Integration Testing"
, testContract "basic/delay.sol" Nothing
[ ("echidna_block_number passed", solved "echidna_block_number")
, ("echidna_timestamp passed", solved "echidna_timestamp") ]
, testContract "basic/no-delay.sol" (Just "basic/no-delay.yaml")
[ ("echidna_block_number failed", passed "echidna_block_number")
, ("echidna_timestamp failed", passed "echidna_timestamp") ]
, testContractV "basic/immutable.sol" (Just (>= solcV (0,6,0))) Nothing
[ ("echidna_test passed", solved "echidna_test") ]
, testContractV "basic/immutable-2.sol" (Just (>= solcV (0,6,0))) Nothing
Expand Down
31 changes: 31 additions & 0 deletions tests/solidity/basic/no-delay.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
contract C {
uint blockA;
uint timeA;
uint blockB;
uint timeB;

constructor() public {
blockA = block.number;
timeA = block.timestamp;
blockB = block.number;
timeB = block.timestamp;
}

function f() public {
blockA = block.number;
timeA = block.timestamp;
}

function g() public {
blockB = block.number;
timeB = block.timestamp;
}

function echidna_block_number() public returns (bool) {
return blockA == blockB;
}

function echidna_timestamp() public returns (bool) {
return timeA == timeB;
}
}
2 changes: 2 additions & 0 deletions tests/solidity/basic/no-delay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
maxTimeDelay: 0
maxBlockDelay: 0
Loading