aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/cmdlineTests.sh2
-rw-r--r--test/contracts/AuctionRegistrar.cpp2
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp2
-rw-r--r--test/contracts/Wallet.cpp2
-rwxr-xr-xtest/externalTests.sh4
-rw-r--r--test/liblll/Compiler.cpp4
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp19
-rw-r--r--test/libsolidity/StandardCompiler.cpp65
-rw-r--r--test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol15
-rw-r--r--test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol15
-rw-r--r--test/libsolidity/syntaxTests/array/length/parentheses.sol2
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol2
12 files changed, 125 insertions, 9 deletions
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index f7577cb3..78e45429 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -177,6 +177,8 @@ do
then
echo " - $dir"
cd "$dir"
+ # Replace version pragmas
+ find . -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
compileFull -w *.sol */*.sol
cd ..
fi
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 70503605..eb274c09 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -40,7 +40,7 @@ namespace
{
static char const* registrarCode = R"DELIMITER(
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract NameRegister {
function addr(string memory _name) public view returns (address o_owner);
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index ae921a96..e82f389f 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -53,7 +53,7 @@ static char const* registrarCode = R"DELIMITER(
// @authors:
// Gav Wood <g@ethdev.com>
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract Registrar {
event Changed(string indexed name);
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index e0e3045c..9fe02e46 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -56,7 +56,7 @@ static char const* walletCode = R"DELIMITER(
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed.
-pragma solidity ^0.4.0;
+pragma solidity >=0.4.0 <0.6.0;
contract multiowned {
diff --git a/test/externalTests.sh b/test/externalTests.sh
index f2839083..0168fb03 100755
--- a/test/externalTests.sh
+++ b/test/externalTests.sh
@@ -56,10 +56,10 @@ function test_truffle
echo "Current commit hash: `git rev-parse HEAD`"
npm install
find . -name soljson.js -exec cp "$SOLJSON" {} \;
- if [ "$name" == "Gnosis" ]; then
+ if [ "$name" == "Zeppelin" -o "$name" == "Gnosis" ]; then
echo "Replaced fixed-version pragmas..."
# Replace fixed-version pragmas in Gnosis (part of Consensys best practice)
- find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/'
+ find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
fi
assertsol="node_modules/truffle/build/Assert.sol"
if [ -f "$assertsol" ]
diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp
index be798dc8..a4394f54 100644
--- a/test/liblll/Compiler.cpp
+++ b/test/liblll/Compiler.cpp
@@ -186,6 +186,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
"60006000600060003c",
"3d",
"6000600060003e",
+ "60003f",
"600040",
"41",
"42",
@@ -291,6 +292,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
"{ (EXTCODECOPY 0 0 0 0) }",
"{ (RETURNDATASIZE) }",
"{ (RETURNDATACOPY 0 0 0) }",
+ "{ (EXTCODEHASH 0) }",
"{ (BLOCKHASH 0) }",
"{ (COINBASE) }",
"{ (TIMESTAMP) }",
@@ -409,6 +411,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
"3c",
"3d",
"3e",
+ "3f",
"40",
"41",
"42",
@@ -547,6 +550,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
"{ (asm EXTCODECOPY) }",
"{ (asm RETURNDATASIZE) }",
"{ (asm RETURNDATACOPY) }",
+ "{ (asm EXTCODEHASH) }",
"{ (asm BLOCKHASH) }",
"{ (asm COINBASE) }",
"{ (asm TIMESTAMP) }",
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index af8465fc..640bf4d0 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
- expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs.")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -407,9 +407,24 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
)";
// This needs special treatment, because the message mentions the EVM version,
// so cannot be run via isoltest.
+ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
+ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
+ });
+ if (!dev::test::Options::get().evmVersion().hasCreate2())
+ expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs.")));
+ CHECK_ALLOW_MULTI(text, expectations);
+}
+
+BOOST_AUTO_TEST_CASE(extcodehash_as_variable)
+{
+ char const* text = R"(
+ contract c { function f() public view { uint extcodehash; extcodehash; assembly { pop(extcodehash(0)) } }}
+ )";
+ // This needs special treatment, because the message mentions the EVM version,
+ // so cannot be run via isoltest.
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
- {Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
+ {Error::Type::Warning, "The \"extcodehash\" instruction is not supported by the VM version"},
}));
}
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index d34bacda..1570a9d2 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -225,6 +225,71 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_CHECK(containsAtMostWarnings(result));
}
+BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": "wrong"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"enabled\" setting must be a boolean."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_a_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": "not a number"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_an_unsigned_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": -1
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
BOOST_AUTO_TEST_CASE(basic_compilation)
{
char const* input = R"(
diff --git a/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol
new file mode 100644
index 00000000..fd8f3078
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/length/fixed_size_multidim_zero_length.sol
@@ -0,0 +1,15 @@
+contract C {
+ function a() public pure returns(int[0][500] memory) {}
+ function b() public pure returns(uint[0][500] memory) {}
+ function c() public pure returns(byte[0][500] memory) {}
+ function d() public pure returns(bytes32[0][500] memory) {}
+ function e() public pure returns(bytes[0][500] memory) {}
+ function e() public pure returns(string[0][500] memory) {}
+}
+// ----
+// TypeError: (52-53): Array with zero length specified.
+// TypeError: (111-112): Array with zero length specified.
+// TypeError: (170-171): Array with zero length specified.
+// TypeError: (232-233): Array with zero length specified.
+// TypeError: (292-293): Array with zero length specified.
+// TypeError: (353-354): Array with zero length specified.
diff --git a/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol
new file mode 100644
index 00000000..b38939e3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/array/length/fixed_size_zero_length.sol
@@ -0,0 +1,15 @@
+contract C {
+ int[0] a;
+ uint[0] b;
+ byte[0] c;
+ bytes32[0] d;
+ bytes[0] e;
+ string[0] f;
+}
+// ----
+// TypeError: (19-20): Array with zero length specified.
+// TypeError: (32-33): Array with zero length specified.
+// TypeError: (45-46): Array with zero length specified.
+// TypeError: (61-62): Array with zero length specified.
+// TypeError: (75-76): Array with zero length specified.
+// TypeError: (90-91): Array with zero length specified.
diff --git a/test/libsolidity/syntaxTests/array/length/parentheses.sol b/test/libsolidity/syntaxTests/array/length/parentheses.sol
index 40f55ad6..8dbcc0a4 100644
--- a/test/libsolidity/syntaxTests/array/length/parentheses.sol
+++ b/test/libsolidity/syntaxTests/array/length/parentheses.sol
@@ -21,5 +21,5 @@ contract C {
uint[((2) + 1) + 1] a12;
uint[(2 + 1) + ((1))] a13;
uint[(((2) + 1)) + (((1)))] a14;
- uint[((((2) + 1)) + (((1))))%1] a15;
+ uint[((((3) + 1)) + (((1))))%2] a15;
}
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
index 9181222e..9adf6f12 100644
--- a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
@@ -1,6 +1,6 @@
contract c {
uint[10] a;
uint[] a2;
- struct x { uint[2**20] b; y[0] c; }
+ struct x { uint[2**20] b; y[1] c; }
struct y { uint d; mapping(uint=>x)[] e; }
}