aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp25
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol11
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol13
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol13
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol16
-rw-r--r--test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol9
8 files changed, 98 insertions, 1 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 92f9569a..1137c7b0 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -32,7 +32,7 @@ REPO_ROOT=$(cd $(dirname "$0")/.. && pwd)
echo $REPO_ROOT
SOLC="$REPO_ROOT/build/solc/solc"
-FULLARGS="--optimize --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
+FULLARGS="--optimize --ignore-missing --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,compact-format,devdoc,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc"
echo "Checking that the bug list is up to date..."
"$REPO_ROOT"/scripts/update_bugs_by_version.py
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index a866e46c..f5813aed 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2077,6 +2077,31 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
+BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
+{
+ char const* sourceCode = R"(
+ contract test {
+ uint120[3] x;
+ function f() view returns (bytes32 hash1, bytes32 hash2, bytes32 hash3) {
+ uint120[] memory y = new uint120[](3);
+ x[0] = y[0] = uint120(-2);
+ x[1] = y[1] = uint120(-3);
+ x[2] = y[2] = uint120(-4);
+ hash1 = keccak256(x);
+ hash2 = keccak256(y);
+ hash3 = keccak256(this.f);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ // Strangely, arrays are encoded with intra-element padding.
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
+ dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
+ dev::keccak256(fromHex(m_contractAddress.hex() + "26121ff0"))
+ ));
+}
+
BOOST_AUTO_TEST_CASE(packed_sha256)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 6163aed0..dd29bf48 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5643,6 +5643,16 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue)
CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and int_const 4294967296");
}
+BOOST_AUTO_TEST_CASE(shift_constant_right_fractional)
+{
+ char const* text = R"(
+ contract C {
+ uint public a = 0x42 >> (1 / 2);
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Operator >> not compatible with types int_const 66 and rational_const 1 / 2");
+}
+
BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack)
{
char const* text = R"(
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
new file mode 100644
index 00000000..9f57c3a4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol
@@ -0,0 +1,11 @@
+contract C {
+ function f() public pure {
+ bytes32 h = keccak256(keccak256, f, this.f.gas, block.blockhash);
+ h;
+ }
+}
+// ----
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
new file mode 100644
index 00000000..a7d13215
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ bool a = address(this).call(address(this).delegatecall, super);
+ bool b = address(this).delegatecall(log0, tx, mulmod);
+ a; b;
+ }
+}
+// ----
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol
new file mode 100644
index 00000000..f27290fd
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol
@@ -0,0 +1,13 @@
+contract C {
+ struct S { uint x; }
+ S s;
+ struct T { }
+ T t;
+ function f() public pure {
+ bytes32 a = sha256(s, t);
+ a;
+ }
+}
+// ----
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
new file mode 100644
index 00000000..991b2237
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol
@@ -0,0 +1,16 @@
+contract C {
+ struct S { uint x; }
+ S s;
+ struct T { }
+ T t;
+ enum A { X, Y }
+ function f() public pure {
+ bool a = address(this).delegatecall(S, A, A.X, T, uint, uint[]);
+ }
+}
+// ----
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
+// TypeError: This type cannot be encoded.
diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol
new file mode 100644
index 00000000..c8364548
--- /dev/null
+++ b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol
@@ -0,0 +1,9 @@
+contract C {
+ uint[3] sarr;
+ function f() view public {
+ uint[3] memory arr;
+ bytes32 h = keccak256(this.f, arr, sarr);
+ h;
+ }
+}
+// ----