diff --git a/test/libsolidity/semanticTests/types/struct/type_typehash_EIP712_example.sol b/test/libsolidity/semanticTests/types/struct/type_typehash_EIP712_example.sol new file mode 100644 index 000000000..20bcea7ef --- /dev/null +++ b/test/libsolidity/semanticTests/types/struct/type_typehash_EIP712_example.sol @@ -0,0 +1,15 @@ +contract C { + struct Mail { + address from; + address to; + string contents; + } + + function f() public pure returns(bool) { + return type(Mail).typehash == keccak256("Mail(address from,address to,string contents)"); + } +} +// ==== +// compileToEwasm: also +// ---- +// f() -> true diff --git a/test/libsolidity/smtCheckerTests/types/type_typehash_different_scopes.sol b/test/libsolidity/semanticTests/types/struct/type_typehash_different_scopes.sol similarity index 55% rename from test/libsolidity/smtCheckerTests/types/type_typehash_different_scopes.sol rename to test/libsolidity/semanticTests/types/struct/type_typehash_different_scopes.sol index b9d7685c8..5eef3b602 100644 --- a/test/libsolidity/smtCheckerTests/types/type_typehash_different_scopes.sol +++ b/test/libsolidity/semanticTests/types/struct/type_typehash_different_scopes.sol @@ -15,11 +15,11 @@ library B { } contract C { - function f() public pure { - assert(A.a == B.b); + function f() public pure returns(bool) { + return A.a == B.b; } } // ==== -// SMTEngine: all +// compileToEwasm: also // ---- -// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. +// f() -> true diff --git a/test/libsolidity/semanticTests/types/struct/type_typehash_shadow.sol b/test/libsolidity/semanticTests/types/struct/type_typehash_shadow.sol new file mode 100644 index 000000000..5ee8021ea --- /dev/null +++ b/test/libsolidity/semanticTests/types/struct/type_typehash_shadow.sol @@ -0,0 +1,23 @@ +struct S { + uint256 x; +} + +bytes32 constant TYPE_HASH_FILE_LEVEL = type(S).typehash; + +contract C { + struct S { + uint256 y; + } + + function f() public pure returns(bool, bool, bool) { + return ( + type(S).typehash == keccak256("S(uint256 y)"), + type(S).typehash == TYPE_HASH_FILE_LEVEL, + TYPE_HASH_FILE_LEVEL == keccak256("S(uint256 x)") + ); + } +} +// ==== +// compileToEwasm: also +// ---- +// f() -> true, false, true diff --git a/test/libsolidity/semanticTests/types/struct/type_typehash_super.sol b/test/libsolidity/semanticTests/types/struct/type_typehash_super.sol new file mode 100644 index 000000000..f3acb8688 --- /dev/null +++ b/test/libsolidity/semanticTests/types/struct/type_typehash_super.sol @@ -0,0 +1,16 @@ +contract A { + struct S { + string x; + bool[10][] y; + } +} + +contract C is A { + function f() public pure returns(bool) { + return type(S).typehash == keccak256("S(string x,bool[10][] y)"); + } +} +// ==== +// compileToEwasm: also +// ---- +// f() -> true diff --git a/test/libsolidity/smtCheckerTests/types/type_typehash_inheritence.sol b/test/libsolidity/smtCheckerTests/types/type_typehash_inheritence.sol deleted file mode 100644 index cb95d25b9..000000000 --- a/test/libsolidity/smtCheckerTests/types/type_typehash_inheritence.sol +++ /dev/null @@ -1,19 +0,0 @@ -contract A { - struct S { - string x; - } -} - -contract B { - struct S { - bool y; - } -} - -contract C is A, B { - function f() public pure { - assert(type(A.S).typehash != type(B.S).typehash); - } -} -// ---- -// DeclarationError 9097: (72-104): Identifier already declared. diff --git a/test/libsolidity/smtCheckerTests/types/type_typehash_shadow.sol b/test/libsolidity/smtCheckerTests/types/type_typehash_shadow.sol deleted file mode 100644 index 13addbec1..000000000 --- a/test/libsolidity/smtCheckerTests/types/type_typehash_shadow.sol +++ /dev/null @@ -1,27 +0,0 @@ -struct S { - uint256 x; -} - -bytes32 constant TYPE_HASH_FILE_LEVEL = type(S).typehash; - -contract A { - function f() public pure { - // TYPE_HASH_FILE_LEVEL == keccak256("S(uint256 x)") - assert(TYPE_HASH_FILE_LEVEL == 0x2a7af8c10b1d48ad8e0a6aad976d8385e84377b5bd03b59e2c445dc430ac2ca2); - } -} - -contract C { - struct S { - uint256 y; - } - - function f() public pure { - // type(S).typehash == keccak256("S(uint256 y)") and not the shadowed file-level struct S - assert(type(S).typehash == 0xea24952476a382c98f2d2e42112ff8a673d8ed19d22ffc89ee9fe2f415bf6c35); - assert(type(S).typehash != TYPE_HASH_FILE_LEVEL); - } -} -// ---- -// Warning 2519: (327-362): This declaration shadows an existing declaration. -// Info 1391: CHC: 3 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them. diff --git a/test/libsolidity/smtCheckerTests/types/type_typehash_super.sol b/test/libsolidity/smtCheckerTests/types/type_typehash_super.sol deleted file mode 100644 index 6c7e6d29b..000000000 --- a/test/libsolidity/smtCheckerTests/types/type_typehash_super.sol +++ /dev/null @@ -1,15 +0,0 @@ -contract A { - struct S { - string x; - bool[10][] y; - } -} - -contract C is A { - function f() public pure { - // keccak256("S(string x,bool[10][] y)") - assert(type(S).typehash == 0xb4abec9b1d4b9d4724891b27b275d7d5e1692fe69fe6ff78379f613500046c11); - } -} -// ---- -// Info 1391: CHC: 1 verification condition(s) proved safe! Enable the model checker option "show proved safe" to see all of them.