forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequals.sol
52 lines (45 loc) · 1.65 KB
/
equals.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
contract C {
function concatCall(bytes8 a) public pure returns (bytes memory) {
return bytes.concat(a, a);
}
function equalArguments1(bytes8 a, bytes8 b, bytes8 c, bytes8 d) public pure {
require(a == c);
require(b == d);
bytes memory concat1 = bytes.concat(a, b);
bytes memory concat2 = bytes.concat(c, d);
assert(keccak256(concat1) == keccak256(concat2));
}
function equalArguments2(bytes8 a, bytes8 c) public pure {
require(a == c);
bytes memory concat1 = bytes.concat(a, concatCall(a));
bytes memory concat2 = bytes.concat(c, concatCall(c));
assert(keccak256(concat1) == keccak256(concat2));
}
function equalLengthFixedBytes(bytes8 a, bytes8 b) public pure {
bytes memory concat1 = bytes.concat(a, b);
bytes memory concat2 = bytes.concat(a, b);
assert(concat1.length == concat2.length);
}
function equalLengthMemoryBytes(bytes memory a, bytes memory b) public pure {
bytes memory concat1 = bytes.concat(a, b);
bytes memory concat2 = bytes.concat(a, b);
assert(concat1.length == concat2.length);
}
function equalLengthMixed(bytes memory a, bytes2 b) public pure {
bytes memory concat1 = bytes.concat(a, b);
bytes memory concat2 = bytes.concat(a, b);
assert(concat1.length == concat2.length);
}
function equalLengthLiterals() public pure {
bytes memory a = hex"aa";
bytes1 b = bytes1(0xbb);
bytes memory c = "c";
bytes memory concat1 = bytes.concat(a, b, c);
bytes memory concat2 = bytes.concat(a, b, c);
assert(concat1.length == concat2.length);
}
}
// ====
// SMTEngine: all
// ----
// Info 1391: CHC: 6 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.