From 1bf8660bdf9c126126737acebcf57f34ffb8c205 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 3 Feb 2015 14:02:58 +0100 Subject: [PATCH 01/12] Solidity SHA3 can now take multiple arguments --- SolidityEndToEndTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index f248a5a07..824519fd2 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2095,6 +2095,25 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256,bool)"))); } +BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) +{ + char const* sourceCode = R"( + contract c { + // function foo(uint a) returns (hash d) + function foo(uint a, uint b, uint c) returns (hash d) + { + d = sha3(a, b, c); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10 , 12, 13) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(13))))); +} + BOOST_AUTO_TEST_SUITE_END() } From 4b43f1b564e6f6cf88441646c56c598403e510dc Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 6 Feb 2015 10:42:24 +0100 Subject: [PATCH 02/12] appendArgumentsCopyToMemory() has more complicated logic now - Plus other fixes. --- SolidityEndToEndTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 824519fd2..083f55025 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2107,7 +2107,7 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) })"; compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10 , 12, 13) == encodeArgs( + BOOST_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13) == encodeArgs( dev::sha3( toBigEndian(u256(10)) + toBigEndian(u256(12)) + From 0037a7694af0f93faf9f98b801faf87a513abd10 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 6 Feb 2015 16:27:41 +0100 Subject: [PATCH 03/12] SHA3 of string literals now should work --- SolidityEndToEndTest.cpp | 45 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 083f55025..bd473af56 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2099,7 +2099,6 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) { char const* sourceCode = R"( contract c { - // function foo(uint a) returns (hash d) function foo(uint a, uint b, uint c) returns (hash d) { d = sha3(a, b, c); @@ -2114,6 +2113,50 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) toBigEndian(u256(13))))); } +BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals) +{ + char const* sourceCode = R"( + contract c { + function foo(uint a, uint16 b) returns (hash d) + { + d = sha3(a, b, 145); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(145))))); +} + +BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) +{ + char const* sourceCode = R"( + contract c { + function foo() returns (hash d) + { + d = sha3("foo"); + } + function bar(uint a, uint16 b) returns (hash d) + { + d = sha3(a, b, 145, "foo"); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo"))); +#if 0 // work in progress + BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(145)) + + asBytes("foo"))))); +#endif +} + BOOST_AUTO_TEST_SUITE_END() } From 895b5c13f0189106f71b670affab61b389e7991d Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 6 Feb 2015 17:25:29 +0100 Subject: [PATCH 04/12] Small fixes for proper multitype/multiarg SHA3 --- SolidityEndToEndTest.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index bd473af56..0fd71ac51 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -576,7 +576,7 @@ BOOST_AUTO_TEST_CASE(simple_mapping) " }\n" "}"; compileAndRun(sourceCode); - + BOOST_CHECK(callContractFunction("get(uint8)", byte(0)) == encodeArgs(byte(0x00))); BOOST_CHECK(callContractFunction("get(uint8)", byte(0x01)) == encodeArgs(byte(0x00))); BOOST_CHECK(callContractFunction("get(uint8)", byte(0xa7)) == encodeArgs(byte(0x00))); @@ -933,7 +933,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("data()") == encodeArgs(8)); BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina")); - BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(toBigEndian(u256(123))))); + BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(bytes({0x7b})))); BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337)))); BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); } @@ -2127,8 +2127,8 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals) BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( dev::sha3( toBigEndian(u256(10)) + - toBigEndian(u256(12)) + - toBigEndian(u256(145))))); + bytes({0x0, 0xc}) + + bytes({0x91})))); } BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) @@ -2147,14 +2147,13 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo"))); -#if 0 // work in progress + BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( dev::sha3( toBigEndian(u256(10)) + - toBigEndian(u256(12)) + - toBigEndian(u256(145)) + - asBytes("foo"))))); -#endif + bytes({0x0, 0xc}) + + bytes({0x91}) + + bytes({0x66, 0x6f, 0x6f})))); } BOOST_AUTO_TEST_SUITE_END() From 360f479143aeb13bd8db66d0db499ed56c0c66b5 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Sat, 7 Feb 2015 11:58:38 +0100 Subject: [PATCH 05/12] jsonrpcstub integreted into cmake build process --- webthreestubclient.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/webthreestubclient.h b/webthreestubclient.h index 6a82263d0..b7cdf015c 100644 --- a/webthreestubclient.h +++ b/webthreestubclient.h @@ -213,6 +213,16 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } + bool eth_flush() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_flush",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } Json::Value eth_blockByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) { Json::Value p; @@ -347,13 +357,13 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - bool eth_changed(const int& param1) throw (jsonrpc::JsonRpcException) + Json::Value eth_changed(const int& param1) throw (jsonrpc::JsonRpcException) { Json::Value p; p.append(param1); Json::Value result = this->CallMethod("eth_changed",p); - if (result.isBool()) - return result.asBool(); + if (result.isArray()) + return result; else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } From 34334de1494b21547ed9e353bf2393d92e52886f Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Sat, 7 Feb 2015 12:10:39 +0100 Subject: [PATCH 06/12] missing commands in client --- webthreestubclient.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/webthreestubclient.h b/webthreestubclient.h index b7cdf015c..1836f6506 100644 --- a/webthreestubclient.h +++ b/webthreestubclient.h @@ -387,6 +387,26 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } + Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_getWork",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_submitWork(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_submitWork",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } bool db_put(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) { Json::Value p; From 12505a5b768be6e2d0302f8803dbfa79e7987034 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Mon, 9 Feb 2015 02:06:30 +0100 Subject: [PATCH 07/12] - implemented Empty parameter name story. Now the name of input/return parameters of function can be not specified. - added appropriate tests Conflicts: test/SolidityEndToEndTest.cpp test/SolidityNameAndTypeResolution.cpp --- SolidityABIJSON.cpp | 71 +++++++++++++++++++++++++++++++ SolidityEndToEndTest.cpp | 27 ++++++++++++ SolidityNameAndTypeResolution.cpp | 42 ++++++++++++++++++ 3 files changed, 140 insertions(+) diff --git a/SolidityABIJSON.cpp b/SolidityABIJSON.cpp index 13e65761f..d600340eb 100644 --- a/SolidityABIJSON.cpp +++ b/SolidityABIJSON.cpp @@ -409,7 +409,78 @@ BOOST_AUTO_TEST_CASE(inherited) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) +{ + char const* sourceCode = R"( + contract test { + function f(uint, uint k) returns(uint ret_k, uint ret_g){ + uint g = 8; + ret_k = k; + ret_g = g; + } + })"; + char const* interface = R"([ + { + "name": "f", + "constant": false, + "type": "function", + "inputs": [ + { + "name": "", + "type": "uint256" + }, + { + "name": "k", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "ret_k", + "type": "uint256" + }, + { + "name": "ret_g", + "type": "uint256" + } + ] + } + ])"; + + checkInterface(sourceCode, interface); +} + +BOOST_AUTO_TEST_CASE(empty_name_return_parameter) +{ + char const* sourceCode = R"( + contract test { + function f(uint k) returns(uint){ + return k; + } + })"; + + char const* interface = R"([ + { + "name": "f", + "constant": false, + "type": "function", + "inputs": [ + { + "name": "k", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256" + } + ] + } + ])"; + checkInterface(sourceCode, interface); +} BOOST_AUTO_TEST_SUITE_END() diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 56ee631b9..5bd1e8578 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2113,6 +2113,33 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256,bool)"))); } +BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) +{ + char const* sourceCode = R"( + contract test { + function f(uint, uint k) returns(uint ret_k, uint ret_g){ + uint g = 8; + ret_k = k; + ret_g = g; + } + })"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f(uint256,uint256)", 5, 9) != encodeArgs(5, 8)); + BOOST_CHECK(callContractFunction("f(uint256,uint256)", 5, 9) == encodeArgs(9, 8)); +} + +BOOST_AUTO_TEST_CASE(empty_name_return_parameter) +{ + char const* sourceCode = R"( + contract test { + function f(uint k) returns(uint){ + return k; + } + })"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f(uint256)", 9) == encodeArgs(9)); +} + BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) { char const* sourceCode = R"( diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 05ce6ed66..f4be31f4b 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -904,6 +904,48 @@ BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(empty_name_input_parameter) +{ + char const* text = R"( + contract test { + function f(uint){ + } + })"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); +} + +BOOST_AUTO_TEST_CASE(empty_name_return_parameter) +{ + char const* text = R"( + contract test { + function f() returns(bool){ + } + })"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); +} + +BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) +{ + char const* text = R"( + contract test { + function f(uint, uint k) returns(uint ret_k){ + return k; + } + })"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); +} + +BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one) +{ + char const* text = R"( + contract test { + function f() returns(uint ret_k, uint){ + return 5; + } + })"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type) { char const* sourceCode = "contract c { function f() { var x = f(); } }"; From 8ab9e1b32b969f2f8e0a4f2f116009b2636ba706 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 9 Feb 2015 14:00:12 +0100 Subject: [PATCH 08/12] Changing Solidity Code to use CamelCase enum values --- SolidityScanner.cpp | 124 ++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/SolidityScanner.cpp b/SolidityScanner.cpp index 8088b4d4b..7a72eb710 100644 --- a/SolidityScanner.cpp +++ b/SolidityScanner.cpp @@ -41,17 +41,17 @@ BOOST_AUTO_TEST_CASE(test_empty) BOOST_AUTO_TEST_CASE(smoke_test) { Scanner scanner(CharStream("function break;765 \t \"string1\",'string2'\nidentifier1")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::FUNCTION); - BOOST_CHECK_EQUAL(scanner.next(), Token::BREAK); - BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Function); + BOOST_CHECK_EQUAL(scanner.next(), Token::Break); + BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "765"); - BOOST_CHECK_EQUAL(scanner.next(), Token::STRING_LITERAL); + BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "string1"); - BOOST_CHECK_EQUAL(scanner.next(), Token::COMMA); - BOOST_CHECK_EQUAL(scanner.next(), Token::STRING_LITERAL); + BOOST_CHECK_EQUAL(scanner.next(), Token::Comma); + BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "string2"); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "identifier1"); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } @@ -59,85 +59,85 @@ BOOST_AUTO_TEST_CASE(smoke_test) BOOST_AUTO_TEST_CASE(string_escapes) { Scanner scanner(CharStream(" { \"a\\x61\"")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LBRACE); - BOOST_CHECK_EQUAL(scanner.next(), Token::STRING_LITERAL); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "aa"); } BOOST_AUTO_TEST_CASE(string_escapes_with_zero) { Scanner scanner(CharStream(" { \"a\\x61\\x00abc\"")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LBRACE); - BOOST_CHECK_EQUAL(scanner.next(), Token::STRING_LITERAL); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), std::string("aa\0abc", 6)); } BOOST_AUTO_TEST_CASE(string_escape_illegal) { Scanner scanner(CharStream(" bla \"\\x6rf\" (illegalescape)")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::ILLEGAL); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), ""); // TODO recovery from illegal tokens should be improved - BOOST_CHECK_EQUAL(scanner.next(), Token::ILLEGAL); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::ILLEGAL); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } BOOST_AUTO_TEST_CASE(hex_numbers) { Scanner scanner(CharStream("var x = 0x765432536763762734623472346;")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::VAR); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Var); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Assign); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "0x765432536763762734623472346"); - BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON); + BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } BOOST_AUTO_TEST_CASE(negative_numbers) { Scanner scanner(CharStream("var x = -.2 + -0x78 + -7.3 + 8.9;")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::VAR); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN); - BOOST_CHECK_EQUAL(scanner.next(), Token::SUB); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Var); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Assign); + BOOST_CHECK_EQUAL(scanner.next(), Token::Sub); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), ".2"); - BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); - BOOST_CHECK_EQUAL(scanner.next(), Token::SUB); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Add); + BOOST_CHECK_EQUAL(scanner.next(), Token::Sub); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "0x78"); - BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); - BOOST_CHECK_EQUAL(scanner.next(), Token::SUB); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Add); + BOOST_CHECK_EQUAL(scanner.next(), Token::Sub); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "7.3"); - BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Add); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "8.9"); - BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON); + BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); } BOOST_AUTO_TEST_CASE(locations) { Scanner scanner(CharStream("function_identifier has ; -0x743/*comment*/\n ident //comment")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 0); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 19); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 20); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 23); - BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON); + BOOST_CHECK_EQUAL(scanner.next(), Token::Semicolon); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 24); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 25); - BOOST_CHECK_EQUAL(scanner.next(), Token::SUB); - BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Sub); + BOOST_CHECK_EQUAL(scanner.next(), Token::Number); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 27); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 32); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 45); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 50); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); @@ -147,13 +147,13 @@ BOOST_AUTO_TEST_CASE(ambiguities) { // test scanning of some operators which need look-ahead Scanner scanner(CharStream("<=""<""+ +=a++ =>""<<")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LTE); - BOOST_CHECK_EQUAL(scanner.next(), Token::LT); - BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); - BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN_ADD); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::INC); - BOOST_CHECK_EQUAL(scanner.next(), Token::ARROW); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LessThanOrEquals); + BOOST_CHECK_EQUAL(scanner.next(), Token::LessThan); + BOOST_CHECK_EQUAL(scanner.next(), Token::Add); + BOOST_CHECK_EQUAL(scanner.next(), Token::AssignAdd); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Inc); + BOOST_CHECK_EQUAL(scanner.next(), Token::Arrow); BOOST_CHECK_EQUAL(scanner.next(), Token::SHL); } @@ -174,9 +174,9 @@ BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed_begin) BOOST_AUTO_TEST_CASE(documentation_comments_parsed) { Scanner scanner(CharStream("some other tokens /// Send $(value / 1000) chocolates to the user")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user"); } @@ -186,9 +186,9 @@ BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed) Scanner scanner(CharStream("some other tokens /**\n" "* Send $(value / 1000) chocolates to the user\n" "*/")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user"); } @@ -198,9 +198,9 @@ BOOST_AUTO_TEST_CASE(multiline_documentation_no_stars) Scanner scanner(CharStream("some other tokens /**\n" " Send $(value / 1000) chocolates to the user\n" "*/")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user"); } @@ -210,9 +210,9 @@ BOOST_AUTO_TEST_CASE(multiline_documentation_whitespace_hell) Scanner scanner(CharStream("some other tokens /** \t \r \n" "\t \r * Send $(value / 1000) chocolates to the user\n" "*/")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); - BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); + BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user"); } @@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence) Scanner scanner(CharStream("hello_world ///documentation comment \n" "//simple comment \n" "<<")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::Identifier); BOOST_CHECK_EQUAL(scanner.next(), Token::SHL); BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "documentation comment "); } From 08e38cfa49848d65a153386a52c00bbd0dfa3e68 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 9 Feb 2015 14:08:48 +0100 Subject: [PATCH 09/12] Camelcasing enums in Types.h --- SolidityExpressionCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp index 3c3ea1baa..9cd13dcfd 100644 --- a/SolidityExpressionCompiler.cpp +++ b/SolidityExpressionCompiler.cpp @@ -477,7 +477,7 @@ BOOST_AUTO_TEST_CASE(blockhash) " }\n" "}\n"; bytes code = compileFirstExpression(sourceCode, {}, {}, - {make_shared("block", make_shared(MagicType::Kind::BLOCK))}); + {make_shared("block", make_shared(MagicType::Kind::Block))}); bytes expectation({byte(eth::Instruction::PUSH1), 0x03, byte(eth::Instruction::BLOCKHASH)}); From 190be6c5f50f3b3f0a2f70c77457ac4917bc1636 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 9 Feb 2015 14:12:36 +0100 Subject: [PATCH 10/12] Styling in Natspec Enums --- SolidityABIJSON.cpp | 2 +- SolidityInterface.cpp | 2 +- SolidityNatspecJSON.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SolidityABIJSON.cpp b/SolidityABIJSON.cpp index d600340eb..242a88e77 100644 --- a/SolidityABIJSON.cpp +++ b/SolidityABIJSON.cpp @@ -48,7 +48,7 @@ public: auto msg = std::string("Parsing contract failed with: ") + boost::diagnostic_information(_e); BOOST_FAIL(msg); } - std::string generatedInterfaceString = m_compilerStack.getMetadata("", DocumentationType::ABI_INTERFACE); + std::string generatedInterfaceString = m_compilerStack.getMetadata("", DocumentationType::ABIInterface); Json::Value generatedInterface; m_reader.parse(generatedInterfaceString, generatedInterface); Json::Value expectedInterface; diff --git a/SolidityInterface.cpp b/SolidityInterface.cpp index 3b7d26ec4..78de2356a 100644 --- a/SolidityInterface.cpp +++ b/SolidityInterface.cpp @@ -43,7 +43,7 @@ public: { m_code = _code; BOOST_REQUIRE_NO_THROW(m_compilerStack.parse(_code)); - m_interface = m_compilerStack.getMetadata("", DocumentationType::ABI_SOLIDITY_INTERFACE); + m_interface = m_compilerStack.getMetadata("", DocumentationType::ABISolidityInterface); BOOST_REQUIRE_NO_THROW(m_reCompiler.parse(m_interface)); return m_reCompiler.getContractDefinition(_contractName); } diff --git a/SolidityNatspecJSON.cpp b/SolidityNatspecJSON.cpp index 911820ddd..b652ad10e 100644 --- a/SolidityNatspecJSON.cpp +++ b/SolidityNatspecJSON.cpp @@ -54,9 +54,9 @@ public: } if (_userDocumentation) - generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_USER); + generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NatspecUser); else - generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_DEV); + generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NatspecDev); Json::Value generatedDocumentation; m_reader.parse(generatedDocumentationString, generatedDocumentation); Json::Value expectedDocumentation; From fe515b467a27ad695c0ce26ef785b86776259998 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 9 Feb 2015 13:39:01 -0800 Subject: [PATCH 11/12] Fixed #988. --- CMakeLists.txt | 7 ++++--- natspec.cpp | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36876eea6..ab8afcd70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,10 @@ target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) -target_link_libraries(testeth webthree) -target_link_libraries(testeth natspec) - +if (NOT HEADLESS) + target_link_libraries(testeth webthree) + target_link_libraries(testeth natspec) +endif() if (JSONRPC) target_link_libraries(testeth web3jsonrpc) target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES}) diff --git a/natspec.cpp b/natspec.cpp index 827f96625..8ba660418 100644 --- a/natspec.cpp +++ b/natspec.cpp @@ -19,6 +19,8 @@ * @date 2015 */ +#if !ETH_HEADLESS + #include #include #include @@ -110,3 +112,5 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_error) } BOOST_AUTO_TEST_SUITE_END() + +#endif From 6ce9b4c27c07c19a45a6dd93b155568739143e4a Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Tue, 10 Feb 2015 09:52:19 +0100 Subject: [PATCH 12/12] Addressing issues in Enum style fix --- SolidityScanner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolidityScanner.cpp b/SolidityScanner.cpp index 7a72eb710..2e4e5db08 100644 --- a/SolidityScanner.cpp +++ b/SolidityScanner.cpp @@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(ambiguities) { // test scanning of some operators which need look-ahead Scanner scanner(CharStream("<=""<""+ +=a++ =>""<<")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LessThanOrEquals); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::LessThanOrEqual); BOOST_CHECK_EQUAL(scanner.next(), Token::LessThan); BOOST_CHECK_EQUAL(scanner.next(), Token::Add); BOOST_CHECK_EQUAL(scanner.next(), Token::AssignAdd);