aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubtly <subtly>2015-07-15 23:58:28 +0800
committersubtly <subtly>2015-07-15 23:58:28 +0800
commit9fa220b808c6d2587171c00314dd8ad7df0e20df (patch)
treef3a96457a4e0f3c988e4d217529f349075b2ef4b
parentc89cd00e36f633e7273237e320743f3eba4062f9 (diff)
parentf66eabed76282a3078d8c1ded1a3e2573ae760b6 (diff)
downloaddexon-solidity-9fa220b808c6d2587171c00314dd8ad7df0e20df.tar.gz
dexon-solidity-9fa220b808c6d2587171c00314dd8ad7df0e20df.tar.zst
dexon-solidity-9fa220b808c6d2587171c00314dd8ad7df0e20df.zip
Merge branch 'develop' into netFix
-rw-r--r--TestHelper.cpp4
-rw-r--r--TestHelper.h3
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp61
-rw-r--r--libsolidity/SolidityNameAndTypeResolution.cpp39
-rw-r--r--libsolidity/solidityExecutionFramework.h6
5 files changed, 96 insertions, 17 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 9a1b1693..f49ed1e0 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -479,7 +479,7 @@ bytes importCode(json_spirit::mObject& _o)
{
bytes code;
if (_o["code"].type() == json_spirit::str_type)
- if (_o["code"].get_str().find_first_of("0x") != 0)
+ if (_o["code"].get_str().find("0x") != 0)
code = compileLLL(_o["code"].get_str(), false);
else
code = fromHex(_o["code"].get_str().substr(2));
@@ -767,6 +767,8 @@ Options::Options()
wallet = true;
else if (arg == "--nonetwork")
nonetwork = true;
+ else if (arg == "--network")
+ nonetwork = false;
else if (arg == "--nodag")
nodag = true;
else if (arg == "--all")
diff --git a/TestHelper.h b/TestHelper.h
index 1c1dfb5f..42027883 100644
--- a/TestHelper.h
+++ b/TestHelper.h
@@ -188,6 +188,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin);
void doStateTests(json_spirit::mValue& v, bool _fillin);
void doVMTests(json_spirit::mValue& v, bool _fillin);
void doBlockchainTests(json_spirit::mValue& _v, bool _fillin);
+void doRlpTests(json_spirit::mValue& v, bool _fillin);
template<typename mapType>
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
@@ -223,7 +224,7 @@ public:
bool inputLimits = false;
bool bigData = false;
bool wallet = false;
- bool nonetwork = false;
+ bool nonetwork = true;
bool nodag = true;
/// @}
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index 3ddb0552..9f806347 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -564,20 +564,6 @@ BOOST_AUTO_TEST_CASE(strings)
BOOST_CHECK(callContractFunction("pipeThrough(bytes2,bool)", string("\0\x02", 2), true) == encodeArgs(string("\0\x2", 2), true));
}
-BOOST_AUTO_TEST_CASE(empty_string_on_stack)
-{
- char const* sourceCode = R"(
- contract test {
- function run() external returns(bytes2 ret) {
- var y = "";
- ret = y;
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("run()") == encodeArgs(byte(0x00)));
-}
-
BOOST_AUTO_TEST_CASE(inc_dec_operators)
{
char const* sourceCode = R"(
@@ -599,6 +585,22 @@ BOOST_AUTO_TEST_CASE(inc_dec_operators)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(0x53866));
}
+BOOST_AUTO_TEST_CASE(bytes_comparison)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() returns (bool) {
+ bytes2 a = "a";
+ bytes2 x = "aa";
+ bytes2 b = "b";
+ return a < x && x < b;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_CASE(state_smoke_test)
{
char const* sourceCode = "contract test {\n"
@@ -5001,6 +5003,37 @@ BOOST_AUTO_TEST_CASE(struct_named_constructor)
BOOST_CHECK(callContractFunction("s()") == encodeArgs(u256(1), true));
}
+BOOST_AUTO_TEST_CASE(literal_strings)
+{
+ char const* sourceCode = R"(
+ contract Test {
+ string public long;
+ string public medium;
+ string public short;
+ string public empty;
+ function f() returns (string) {
+ long = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+ medium = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
+ short = "123";
+ empty = "";
+ return "Hello, World!";
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Test");
+ string longStr = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+ string medium = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
+ string shortStr = "123";
+ string hello = "Hello, World!";
+
+ BOOST_CHECK(callContractFunction("f()") == encodeDyn(hello));
+ BOOST_CHECK(callContractFunction("long()") == encodeDyn(longStr));
+ BOOST_CHECK(callContractFunction("medium()") == encodeDyn(medium));
+ BOOST_CHECK(callContractFunction("short()") == encodeDyn(shortStr));
+ BOOST_CHECK(callContractFunction("empty()") == encodeDyn(string()));
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp
index 50fcdbbe..0f5e4800 100644
--- a/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(large_string_literal)
char const* text = "contract test {\n"
" function f() { var x = \"123456789012345678901234567890123\"; }"
"}\n";
- BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
BOOST_AUTO_TEST_CASE(balance)
@@ -2097,6 +2097,43 @@ BOOST_AUTO_TEST_CASE(struct_named_constructor)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode));
}
+BOOST_AUTO_TEST_CASE(literal_strings)
+{
+ char const* text = R"(
+ contract Foo {
+ function f() {
+ string memory long = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+ string memory short = "123";
+ }
+ }
+ )";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(invalid_integer_literal_fraction)
+{
+ char const* text = R"(
+ contract Foo {
+ function f() {
+ var x = 1.20;
+ }
+ }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp)
+{
+ char const* text = R"(
+ contract Foo {
+ function f() {
+ var x = 1e2;
+ }
+ }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/libsolidity/solidityExecutionFramework.h b/libsolidity/solidityExecutionFramework.h
index 200940a4..03a201c7 100644
--- a/libsolidity/solidityExecutionFramework.h
+++ b/libsolidity/solidityExecutionFramework.h
@@ -145,6 +145,12 @@ public:
{
return bytes();
}
+ //@todo might be extended in the future
+ template <class Arg>
+ static bytes encodeDyn(Arg const& _arg)
+ {
+ return encodeArgs(u256(0x20), u256(_arg.size()), _arg);
+ }
private:
template <class CppFunction, class... Args>