Skip to content

Commit

Permalink
add MapInitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
daejunpark committed Sep 23, 2019
1 parent cb40049 commit aeec19d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Test/regressions/MapInitTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pragma solidity >=0.4.24<0.6.0;

contract MapInitTest1 {
mapping (uint256 => uint256) public recoverMap1;

constructor(uint256 owner, uint256 key)
public
{
require(owner != 0);
recoverMap1[key] = owner;
}

function test(uint256 key)
external
{
uint256 owner1 = recoverMap1[key];
uint256 owner2 = recoverMap1[key + 1];
require(owner1 != 0);

assert(owner1 != owner2);
}
}

contract MapInitTest2 {
mapping (uint256 => mapping (uint256 => uint256)) public recoverMap2;

constructor(uint256 owner, uint256 key1, uint256 key2)
public
{
require(owner != 0);
recoverMap2[key1][key2] = owner;
}

function test(uint256 key1, uint256 key2)
external
{
uint256 owner1 = recoverMap2[key1][key2];
uint256 owner2 = recoverMap2[key1][key2 + 1];
require(owner1 != 0);

assert(owner1 != owner2); // <--- false positive corral runs
}
}

1 comment on commit aeec19d

@daejunpark
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.