Merge pull request #738 from crytic/dev-test-reentrancy-benign

Added tests for reentrancy-benign detector
pull/756/head
Feist Josselin 4 years ago committed by GitHub
commit 08b87c4aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 61
      tests/detectors/reentrancy-benign/reentrancy-benign.sol
  2. 4580
      tests/detectors/reentrancy-benign/reentrancy-benign.sol.0.4.26.ReentrancyBenign.json
  3. 5
      tests/test_detectors.py

@ -0,0 +1,61 @@
pragma solidity ^0.4.0;
contract ReentrancyBenign {
uint8 anotherVariableToChange;
uint8 counter = 0;
function bad0() public {
if (!(msg.sender.call())) {
revert();
}
counter += 1;
}
function bad1(address target) public {
(bool success) = target.call();
require(success);
counter += 1;
}
function bad2(address target) public {
(bool success) = target.call();
if (success) {
address(target).call.value(1000)();
counter += 1;
}
else {
revert();
}
}
function bad3(address target) public {
externalCaller(target);
varChanger();
ethSender(target);
}
function bad4(address target) public {
externalCaller(target);
ethSender(address(0));
varChanger();
address(target).call.value(2)();
}
function bad5(address target) public {
ethSender(address(0));
varChanger();
ethSender(address(0));
}
function externalCaller(address target) private {
address(target).call();
}
function ethSender(address target) private {
address(target).call.value(1)();
}
function varChanger() private {
anotherVariableToChange++;
}
}

@ -53,6 +53,11 @@ def id_test(test_item: Test):
ALL_TESTS = [ ALL_TESTS = [
Test(
all_detectors.ReentrancyBenign,
"tests/detectors/reentrancy-benign/reentrancy-benign.sol",
"0.4.26",
),
Test( Test(
all_detectors.ReentrancyReadBeforeWritten, all_detectors.ReentrancyReadBeforeWritten,
"tests/detectors/reentrancy-before-write/reentrancy-write.sol", "tests/detectors/reentrancy-before-write/reentrancy-write.sol",

Loading…
Cancel
Save