Skip to content

Commit e0ab0f2

Browse files
authored
Merge pull request #15256 from ethereum/smt-more-test-simplification
SMTChecker: Further test simplifications
2 parents 790b181 + f53bb02 commit e0ab0f2

File tree

8 files changed

+29
-75
lines changed

8 files changed

+29
-75
lines changed

test/libsolidity/smtCheckerTests/deployment/deploy_trusted_flow.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
contract D {
22
uint x;
3-
function inc() public { ++x; }
3+
function inc() public { require(x < 5); ++x; }
44
function f() public view returns (uint) { return x; }
55
}
66

@@ -18,9 +18,7 @@ contract C {
1818
// ====
1919
// SMTEngine: all
2020
// SMTExtCalls: trusted
21+
// SMTTargets: assert
2122
// ----
22-
// Warning 4984: (47-50): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
23-
// Warning 6328: (304-322): CHC: Assertion violation might happen here.
23+
// Warning 6328: (320-338): CHC: Assertion violation happens here.
2424
// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
25-
// Warning 2661: (47-50): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
26-
// Warning 4661: (304-322): BMC: Assertion violation happens here.
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
contract Other {
2-
C c;
3-
constructor(C _c) {
4-
c = _c;
5-
}
6-
function h() public {
2+
function h(C c) public {
73
c.setOwner(address(0));
84
}
95
}
106

117
contract State {
128
uint x;
139
Other o;
14-
C c;
15-
constructor(C _c) {
16-
c = _c;
17-
o = new Other(_c);
10+
constructor() {
11+
o = new Other();
1812
}
19-
function f() public returns (uint) {
20-
o.h();
13+
function f(C c) public returns (uint) {
14+
o.h(c);
2115
return c.g();
2216
}
2317
}
@@ -29,7 +23,7 @@ contract C {
2923

3024
constructor() {
3125
owner = msg.sender;
32-
s = new State(this);
26+
s = new State();
3327
}
3428

3529
function setOwner(address _owner) public {
@@ -38,7 +32,7 @@ contract C {
3832

3933
function f() public {
4034
address prevOwner = owner;
41-
uint z = s.f();
35+
uint z = s.f(this);
4236
assert(z == y); // should hold
4337
assert(prevOwner == owner); // should not hold because of reentrancy
4438
}
@@ -52,5 +46,5 @@ contract C {
5246
// SMTEngine: chc
5347
// SMTExtCalls: trusted
5448
// ----
55-
// Warning 6328: (531-545): CHC: Assertion violation might happen here.
56-
// Warning 6328: (564-590): CHC: Assertion violation happens here.
49+
// Warning 6328: (509-535): CHC: Assertion violation happens here.
50+
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/external_calls/external_inc.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ contract C {
77
D d;
88

99
function inc() public {
10+
require(x < 10);
1011
++x;
1112
}
1213

1314
function f() public {
1415
d.d();
15-
assert(x < 10);
16+
assert(x < 5);
1617
}
1718
}
1819
// ====
1920
// SMTEngine: all
2021
// SMTIgnoreCex: yes
2122
// ----
22-
// Warning 4984: (113-116): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
23-
// Warning 6328: (156-170): CHC: Assertion violation happens here.
24-
// Warning 2661: (113-116): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
23+
// Warning 6328: (175-188): CHC: Assertion violation happens here.\nCounterexample:\nx = 5, d = 0\n\nTransaction trace:\nC.constructor()\nState: x = 0, d = 0\nC.inc()\nState: x = 1, d = 0\nC.inc()\nState: x = 2, d = 0\nC.inc()\nState: x = 3, d = 0\nC.inc()\nState: x = 4, d = 0\nC.f()\n d.d() -- untrusted external call, synthesized as:\n C.inc() -- reentrant call
24+
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/external_calls/external_safe.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ contract C {
66
uint x;
77
D d;
88
function f() public {
9-
if (x < 10)
9+
if (x < 5)
1010
++x;
1111
}
1212
function g() public {
1313
d.d();
14-
assert(x < 11);
14+
assert(x < 6);
1515
}
1616
}
1717
// ====
1818
// SMTEngine: all
19-
// SMTIgnoreOS: macos
2019
// ----
2120
// Info 1391: CHC: 2 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/types/array_branches_3d.sol

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ contract C
1515
}
1616
// ====
1717
// SMTEngine: all
18-
// SMTIgnoreOS: macos
18+
// SMTTargets: assert
1919
// ----
20-
// Warning 6368: (124-131): CHC: Out of bounds access might happen here.
21-
// Warning 6368: (124-134): CHC: Out of bounds access might happen here.
22-
// Warning 6368: (152-159): CHC: Out of bounds access might happen here.
23-
// Warning 6368: (152-162): CHC: Out of bounds access might happen here.
24-
// Warning 6368: (177-184): CHC: Out of bounds access might happen here.
25-
// Warning 6368: (177-187): CHC: Out of bounds access might happen here.
26-
// Info 1391: CHC: 7 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
20+
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/types/array_branches_3d_show_unproved.sol

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_1.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ contract C
55
mapping (uint => uint8)[2] severalMaps8;
66
mapping (uint => uint)[2][2] severalMaps3d;
77
function f(mapping (uint => uint) storage map) internal {
8-
// Accesses are safe but oob is reported because of aliasing.
98
severalMaps[0][0] = 42;
109
severalMaps8[0][0] = 42;
1110
severalMaps3d[0][0][0] = 42;
@@ -15,8 +14,7 @@ contract C
1514
// Should not fail since knowledge is erased only for mapping (uint => uint).
1615
assert(severalMaps8[0][0] == 42);
1716
// Should fail since map == severalMaps3d[0][0] is possible.
18-
// Removed because current Spacer seg faults in cex generation.
19-
//assert(severalMaps3d[0][0][0] == 42);
17+
assert(severalMaps3d[0][0][0] == 42);
2018
}
2119
function g(uint x) public {
2220
require(x < severalMaps.length);
@@ -26,6 +24,8 @@ contract C
2624
// ====
2725
// SMTEngine: all
2826
// SMTIgnoreCex: yes
27+
// SMTTargets: assert
2928
// ----
30-
// Warning 6328: (456-487): CHC: Assertion violation happens here.
31-
// Info 1391: CHC: 8 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
29+
// Warning 6328: (392-423): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n C.f(map) -- counterexample incomplete; parameter name used instead of value -- internal call
30+
// Warning 6328: (606-642): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n C.f(map) -- counterexample incomplete; parameter name used instead of value -- internal call
31+
// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

test/libsolidity/smtCheckerTests/types/array_static_mapping_aliasing_2.sol

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ contract C
55
mapping (uint => uint8)[2] severalMaps8;
66
mapping (uint => uint)[2][2] severalMaps3d;
77
function f(mapping (uint => uint) storage map) internal {
8-
// Accesses are safe but reported as unsafe due to aliasing.
98
map[0] = 42;
109
severalMaps[0][0] = 42;
1110
severalMaps8[0][0] = 42;
@@ -16,8 +15,7 @@ contract C
1615
// Should not fail since knowledge is erased only for mapping (uint => uint).
1716
assert(severalMaps8[0][0] == 42);
1817
// Should not fail since singleMap == severalMaps3d[0][0] is not possible.
19-
// Removed because of Spacer nondeterminism.
20-
//assert(severalMaps3d[0][0][0] == 42);
18+
assert(severalMaps3d[0][0][0] == 42);
2119
// Should fail since singleMap == map is possible.
2220
assert(map[0] == 42);
2321
}
@@ -29,9 +27,7 @@ contract C
2927
// ====
3028
// SMTEngine: all
3129
// SMTIgnoreCex: yes
30+
// SMTTargets: assert
3231
// ----
33-
// Warning 6368: (340-355): CHC: Out of bounds access might happen here.
34-
// Warning 6368: (612-627): CHC: Out of bounds access might happen here.
35-
// Warning 6328: (860-880): CHC: Assertion violation happens here.
36-
// Warning 6368: (936-952): CHC: Out of bounds access might happen here.
37-
// Info 1391: CHC: 7 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.
32+
// Warning 6328: (748-768): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n C.f(map) -- counterexample incomplete; parameter name used instead of value -- internal call
33+
// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.

0 commit comments

Comments
 (0)