forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SMTChecker] Support constants via modules
- Loading branch information
Leo Alt
committed
Sep 16, 2021
1 parent
4284499
commit a1bea36
Showing
9 changed files
with
118 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/libsolidity/smtCheckerTests/file_level/module_constants_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
==== Source: s1.sol ==== | ||
uint constant a = 89; | ||
==== Source: s2.sol ==== | ||
uint constant a = 88; | ||
|
||
==== Source: s3.sol ==== | ||
import "s1.sol" as M; | ||
import "s2.sol" as N; | ||
|
||
contract C { | ||
function f() internal pure returns (uint, uint) { | ||
return (M.a, N.a); | ||
} | ||
function p() public pure { | ||
(uint x, uint y) = f(); | ||
assert(x == 89); // should hold | ||
assert(x == 88); // should fail | ||
assert(y == 88); // should hold | ||
assert(y == 89); // should fail | ||
} | ||
} | ||
// ==== | ||
// SMTEngine: chc | ||
// ---- | ||
// Warning 6328: (s3.sol:223-238): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 89\ny = 88\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call | ||
// Warning 6328: (s3.sol:291-306): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 89\ny = 88\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call |
46 changes: 46 additions & 0 deletions
46
test/libsolidity/smtCheckerTests/file_level/module_constants_functions_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
==== Source: s1.sol ==== | ||
uint constant a = 89; | ||
|
||
function fre() pure returns (uint) { | ||
return a; | ||
} | ||
|
||
==== Source: s2.sol ==== | ||
function foo() pure returns (uint) { | ||
return 42; | ||
} | ||
|
||
==== Source: s3.sol ==== | ||
import {fre as foo} from "s1.sol"; | ||
import "s1.sol" as M; | ||
import "s2.sol" as N; | ||
|
||
uint256 constant a = 13; | ||
|
||
contract C { | ||
function f() internal pure returns (uint, uint, uint, uint) { | ||
return (a, foo(), N.foo(), M.a); | ||
} | ||
function p() public pure { | ||
(uint x, uint y, uint z, uint t) = f(); | ||
|
||
assert(x == 13); // should hold | ||
assert(x == 89); // should fail | ||
|
||
assert(y == 89); // should hold | ||
assert(y == 42); // should fail | ||
|
||
assert(z == 42); // should hold | ||
assert(z == 89); // should fail | ||
|
||
assert(t == 89); // should hold | ||
assert(t == 13); // should fail | ||
} | ||
} | ||
// ==== | ||
// SMTEngine: all | ||
// ---- | ||
// Warning 6328: (s3.sol:327-342): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 13\ny = 89\nz = 42\nt = 89\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call\n s1.sol:fre() -- internal call\n s2.sol:foo() -- internal call | ||
// Warning 6328: (s3.sol:396-411): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 13\ny = 89\nz = 42\nt = 89\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call\n s1.sol:fre() -- internal call\n s2.sol:foo() -- internal call | ||
// Warning 6328: (s3.sol:465-480): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 13\ny = 89\nz = 42\nt = 89\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call\n s1.sol:fre() -- internal call\n s2.sol:foo() -- internal call | ||
// Warning 6328: (s3.sol:534-549): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 13\ny = 89\nz = 42\nt = 89\n\nTransaction trace:\nC.constructor()\nC.p()\n C.f() -- internal call\n s1.sol:fre() -- internal call\n s2.sol:foo() -- internal call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters