From e608be82994310cf29315c6ca004bd5412e50c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 8 May 2015 11:00:17 +0200 Subject: [PATCH 01/38] testeth: fix --singletest option --- TestHelper.cpp | 95 +++++++++++++++++++++++--------------------------- TestHelper.h | 3 +- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 46718c5dd..3171f91cb 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -549,58 +549,50 @@ void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _e } } -void userDefinedTest(string testTypeFlag, std::function doTests) +void userDefinedTest(std::function doTests) { - Options::get(); // parse command line options, e.g. to enable JIT - - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + if (!Options::get().singleTest) { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == testTypeFlag) - { - if (boost::unit_test::framework::master_test_suite().argc <= i + 2) - { - cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " \n"; - return; - } - string filename = boost::unit_test::framework::master_test_suite().argv[i + 1]; - string testname = boost::unit_test::framework::master_test_suite().argv[i + 2]; - int currentVerbosity = g_logVerbosity; - g_logVerbosity = 12; - try - { - cnote << "Testing user defined test: " << filename; - json_spirit::mValue v; - string s = asString(contents(filename)); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. "); - json_spirit::read_string(s, v); - json_spirit::mObject oSingleTest; - - json_spirit::mObject::const_iterator pos = v.get_obj().find(testname); - if (pos == v.get_obj().end()) - { - cnote << "Could not find test: " << testname << " in " << filename << "\n"; - return; - } - else - oSingleTest[pos->first] = pos->second; - - json_spirit::mValue v_singleTest(oSingleTest); - doTests(v_singleTest, false); - } - catch (Exception const& _e) - { - BOOST_ERROR("Failed Test with Exception: " << diagnostic_information(_e)); - g_logVerbosity = currentVerbosity; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed Test with Exception: " << _e.what()); - g_logVerbosity = currentVerbosity; - } - g_logVerbosity = currentVerbosity; - } + cnote << "Missing user test specification\nUsage: testeth --singletest \n"; + return; } + + auto& filename = Options::get().singleTestFile; + auto& testname = Options::get().singleTestName; + int currentVerbosity = g_logVerbosity; + g_logVerbosity = 12; + try + { + cnote << "Testing user defined test: " << filename; + json_spirit::mValue v; + string s = asString(contents(filename)); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. "); + json_spirit::read_string(s, v); + json_spirit::mObject oSingleTest; + + json_spirit::mObject::const_iterator pos = v.get_obj().find(testname); + if (pos == v.get_obj().end()) + { + cnote << "Could not find test: " << testname << " in " << filename << "\n"; + return; + } + else + oSingleTest[pos->first] = pos->second; + + json_spirit::mValue v_singleTest(oSingleTest); + doTests(v_singleTest, false); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed Test with Exception: " << diagnostic_information(_e)); + g_logVerbosity = currentVerbosity; + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed Test with Exception: " << _e.what()); + g_logVerbosity = currentVerbosity; + } + g_logVerbosity = currentVerbosity; } void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests) @@ -739,10 +731,11 @@ Options::Options() inputLimits = true; bigData = true; } - else if (arg == "--singletest" && i + 1 < argc) + else if (arg == "--singletest" && i + 2 < argc) { singleTest = true; - singleTestName = argv[i + 1]; + singleTestFile = argv[i + 1]; + singleTestName = argv[i + 2]; } } } diff --git a/TestHelper.h b/TestHelper.h index 00b520d06..d1da7e24b 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -157,7 +157,7 @@ void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs); void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates); void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function doTests); -void userDefinedTest(std::string testTypeFlag, std::function doTests); +void userDefinedTest(std::function doTests); RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj); eth::LastHashes lastHashes(u256 _currentBlockNumber); json_spirit::mObject fillJsonWithState(eth::State _state); @@ -188,6 +188,7 @@ public: /// Test selection /// @{ bool singleTest = false; + std::string singleTestFile; std::string singleTestName; bool performance = false; bool quadratic = false; From fe4e3b17d81432e2899cf972697f5daf60da3d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 13 May 2015 17:22:35 +0200 Subject: [PATCH 02/38] Add support for --singletest filter in VM tests. Add & correct arithmetic VM tests. From 054c9562d6ebe8a0bc2e738dd0db6f42e2551ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 13 May 2015 18:55:31 +0200 Subject: [PATCH 03/38] Tests: add edge cases for ADDMOD and MULMOD. From 047e72c6792fb4b83e48b6230ae6bfea605cd273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 14 May 2015 16:39:40 +0200 Subject: [PATCH 04/38] Tests: SMOD edge case test. From 7272785f9288b591ed9a4ca59c0b69c65a1f95c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 10 Jun 2015 18:18:38 +0200 Subject: [PATCH 05/38] Add code hash to VM tester. From 0f50090b35dd9038c489dbacfdee4f0cefbc56cb Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 22 Jun 2015 21:42:08 +0200 Subject: [PATCH 06/38] bloom filter exchage protocol From 3a71f292d9527efd6d4a206ce8adbc092838db21 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 22 Jun 2015 22:20:39 +0200 Subject: [PATCH 07/38] bugfix From 44ffc55c1a5f8300adc449d1cdb92a3d808cb9b2 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Tue, 23 Jun 2015 15:00:34 +0200 Subject: [PATCH 08/38] deleted unused variable From e22544e0373ce3fc141f9292261ff0362f39a775 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 24 Jun 2015 13:56:07 +0200 Subject: [PATCH 09/38] BF size changed From cf2919dc3f265bc822204c8516121f043e5debfe Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 24 Jun 2015 15:55:11 +0200 Subject: [PATCH 10/38] minor clean up From 209e16e21122979159eba863ba77b28aa687fd4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 24 Jun 2015 17:43:47 +0200 Subject: [PATCH 11/38] Do not compute code hash twice in VM test engine. From de1cfebc44f75a87d1782f57fe4c62363318261b Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Thu, 25 Jun 2015 12:40:19 +0200 Subject: [PATCH 12/38] Topics of interest advertising made asynchronous From 88f8eb6ad24c88814d411a1a1acb1890b0eddf0a Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 26 Jun 2015 06:46:49 -0400 Subject: [PATCH 13/38] Prep for supporting both cryptopp and secp256k1. Link (old) secp256k1 library to devcrypto. Rename cryptopp Secp256k1 to Secp256k1PP. Update toPublic to use secp256k1 library and add test. From 1ed7bc1562cc0b4ac02e89fb566c9f0787a06c3c Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 26 Jun 2015 07:41:42 -0400 Subject: [PATCH 14/38] Don't link secp256k1 on windows. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d39a5cca1..952b1674f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,9 @@ target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) target_link_libraries(testeth ${CURL_LIBRARIES}) target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) -target_link_libraries(testeth secp256k1) +if (NOT WIN32) + target_link_libraries(testeth secp256k1) +endif() if (JSCONSOLE) target_link_libraries(testeth jsengine) From 7100b14d4dcf3f952f53cd20c58b8ece4a53580c Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 26 Jun 2015 18:35:43 +0200 Subject: [PATCH 15/38] Delete for memory objects. --- libsolidity/SolidityEndToEndTest.cpp | 29 +++++++++++++++++++ libsolidity/SolidityNameAndTypeResolution.cpp | 26 +++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index a01e98cf8..9451c8cf2 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4691,6 +4691,35 @@ BOOST_AUTO_TEST_CASE(memory_types_initialisation) BOOST_CHECK(callContractFunction("nestedStat()") == encodeArgs(vector(3 * 7))); } +BOOST_AUTO_TEST_CASE(memory_arrays_delete) +{ + char const* sourceCode = R"( + contract Test { + function del() returns (uint24[3][4]) { + uint24[3][4] memory x; + for (uint24 i = 0; i < x.length; i ++) + for (uint24 j = 0; j < x[i].length; j ++) + x[i][j] = i * 0x10 + j; + delete x[1]; + delete x[3][2]; + return x; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + vector data(3 * 4); + for (unsigned i = 0; i < 4; i++) + for (unsigned j = 0; j < 3; j++) + { + u256 v = 0; + if (!(i == 1 || (i == 3 && j == 2))) + v = i * 0x10 + j; + data[i * 3 + j] = v; + } + BOOST_CHECK(callContractFunction("del()") == encodeArgs(data)); +} + BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write) { char const* sourceCode = R"( diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index 765593c59..f24930ba5 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1900,6 +1900,18 @@ BOOST_AUTO_TEST_CASE(storage_location_local_variables) BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); } +BOOST_AUTO_TEST_CASE(no_mappings_in_memory_array) +{ + char const* sourceCode = R"( + contract C { + function f() { + mapping(uint=>uint)[] memory x; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable) { char const* sourceCode = R"( @@ -1931,6 +1943,20 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers) +{ + char const* sourceCode = R"( + contract C { + uint[] data; + function f() { + var x = data; + delete x; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_CASE(assignment_mem_storage_variable_directly) { char const* sourceCode = R"( From 3ffde5148b6a43442a66594764e9c460dec83a73 Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 26 Jun 2015 23:49:52 -0400 Subject: [PATCH 16/38] Disable libsecp256k1-specific tests for windows compile. From e1b2a79b8b64199b98ec41377da6202f9c26dfcb Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 29 Jun 2015 12:47:04 +0200 Subject: [PATCH 17/38] Another test for arrays in constructors. --- libsolidity/SolidityEndToEndTest.cpp | 41 +++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 9451c8cf2..a2dbc35e6 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4493,7 +4493,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) } } contract Main is Base { - function Main(bytes s, uint x) Base(x, s){}//f(s)) {} + function Main(bytes s, uint x) Base(x, f(s)) {} function f(bytes s) returns (bytes) { return s; } @@ -4517,6 +4517,45 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) ); } +BOOST_AUTO_TEST_CASE(arrays_in_constructors) +{ + char const* sourceCode = R"( + contract Base { + uint public m_x; + address[] m_s; + function Base(uint x, address[] s) { + m_x = x; + m_s = s; + } + function part(uint i) returns (address) { + return m_s[i]; + } + } + contract Main is Base { + function Main(address[] s, uint x) Base(x, f(s)) {} + function f(address[] s) returns (address[]) { + return s; + } + } + contract Creator { + function f(uint x, address[] s) returns (uint r, address ch) { + var c = new Main(s, x); + r = c.m_x(); + ch = c.part(x); + } + } + )"; + compileAndRun(sourceCode, 0, "Creator"); + vector s1{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + bytes dyn1 = encodeArgs(u256(s1.size()), s1); + u256 x = 7; + bytes args1 = encodeArgs(x, u256(0x40)) + dyn1; + BOOST_REQUIRE( + callContractFunction("f(uint256,address[])", asString(args1)) == + encodeArgs(x, s1[unsigned(x)]) + ); +} + BOOST_AUTO_TEST_CASE(arrays_from_and_to_storage) { char const* sourceCode = R"( From 4a369a8eeedc6916560843de710a50d895c549ae Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 29 Jun 2015 12:46:31 +0200 Subject: [PATCH 18/38] Updated wallet test to latest wallet source. --- libsolidity/SolidityWallet.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libsolidity/SolidityWallet.cpp b/libsolidity/SolidityWallet.cpp index 09820b87b..ba8f198f8 100644 --- a/libsolidity/SolidityWallet.cpp +++ b/libsolidity/SolidityWallet.cpp @@ -200,17 +200,17 @@ contract multiowned { } // the number of owners that must confirm the same operation before it is run. - uint m_required; + uint public m_required; // pointer used to find a free slot in m_owners - uint m_numOwners; + uint public m_numOwners; // list of owners - uint[256] m_owners; + uint[256] public m_owners; uint constant c_maxOwners = 250; // index on the list of owners to allow reverse lookup - mapping(uint => uint) m_ownerIndex; + mapping(uint => uint) public m_ownerIndex; // the ongoing operations. - mapping(bytes32 => PendingState) m_pending; - bytes32[] m_pendingIndex; + mapping(bytes32 => PendingState) public m_pending; + bytes32[] public m_pendingIndex; } // inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable) @@ -251,9 +251,9 @@ contract daylimit is multiowned { } // determines today's index. function today() private constant returns (uint) { return now / 1 days; } - uint m_spentToday; - uint m_dailyLimit; - uint m_lastDay; + uint public m_spentToday; + uint public m_dailyLimit; + uint public m_lastDay; } // interface contract for multisig proxy contracts; see below for docs. contract multisig { @@ -275,11 +275,14 @@ contract Wallet is multisig, multiowned, daylimit { uint value; bytes data; } + /* // logged events: // Funds has arrived into the wallet (record how much). event Deposit(address from, uint value); // Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going). event SingleTransact(address owner, uint value, address to, bytes data); + // Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going). + event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data);*/ // constructor - just pass on the owner arra to the multiowned. event Created(); function Wallet() { @@ -299,7 +302,7 @@ contract Wallet is multisig, multiowned, daylimit { // If not, goes into multisig process. We provide a hash on return to allow the sender to provide // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value // and _data arguments). They still get the option of using them if they want, anyways. - function execute(address _to, uint _value, bytes _data) onlyowner external returns (bytes32 _r) { + function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) { // first, take the opportunity to check that we're under the daily limit. if (underLimit(_value)) { SingleTransact(msg.sender, _value, _to, _data); @@ -332,8 +335,14 @@ contract Wallet is multisig, multiowned, daylimit { delete m_txs[m_pendingIndex[i]]; super.clearPending(); } + // // internally confirm transaction with all of the info. returns true iff confirmed good and executed. + // function confirmVerbose(bytes32 _h, address _to, uint _value, bytes _data) private onlymanyowners(_h) returns (bool) { + // _to.call.value(_value)(_data); + // MultiTransact("out", msg.sender, _h, _value, _to); + // return true; + // } // pending transactions we have at present. - mapping (bytes32 => Transaction) m_txs; + mapping (bytes32 => Transaction) public m_txs; } )DELIMITER"; From c2d3dfe87bfb67c5a736684bcae3445630636758 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 29 Jun 2015 15:29:58 +0200 Subject: [PATCH 19/38] a minor refactoring From 4e62efc7ff24cbe55a0690c44e406fadf3b596e0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 29 Jun 2015 20:05:41 +0200 Subject: [PATCH 20/38] Memory arrays cannot be resized. --- libsolidity/SolidityNameAndTypeResolution.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index f24930ba5..df976eaea 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2026,6 +2026,19 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) +{ + char const* sourceCode = R"( + contract C { + function f() { + uint[] memory x; + x.length = 2; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } From c707811fe39f78dda26ae784a61f1659774ee0e9 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 29 Jun 2015 13:01:05 +0200 Subject: [PATCH 21/38] uninstallWatch() fixed + test From 807f7e6579cb9f315bca4b6820d39e7a872c7868 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 23 Jun 2015 16:56:59 +0200 Subject: [PATCH 22/38] Fixed checking of abstract functions. Fixes #2264 --- libsolidity/SolidityNameAndTypeResolution.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index df976eaea..4914ef975 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -403,6 +403,23 @@ BOOST_AUTO_TEST_CASE(abstract_contract) BOOST_CHECK(derived->getDefinedFunctions()[0]->isFullyImplemented()); } +BOOST_AUTO_TEST_CASE(abstract_contract_with_overload) +{ + ASTPointer sourceUnit; + char const* text = R"( + contract base { function foo(bool); } + contract derived is base { function foo(uint) {} } + )"; + ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed"); + std::vector> nodes = sourceUnit->getNodes(); + ContractDefinition* base = dynamic_cast(nodes[0].get()); + ContractDefinition* derived = dynamic_cast(nodes[1].get()); + BOOST_REQUIRE(base); + BOOST_CHECK(!base->isFullyImplemented()); + BOOST_REQUIRE(derived); + BOOST_CHECK(!derived->isFullyImplemented()); +} + BOOST_AUTO_TEST_CASE(create_abstract_contract) { ASTPointer sourceUnit; From 48eff32c8f109287a53aef58050842d3c09f280a Mon Sep 17 00:00:00 2001 From: arkpar Date: Tue, 30 Jun 2015 17:24:32 +0200 Subject: [PATCH 23/38] style From 3a6c08d57d035ac4ad1b4b545aa964435785a408 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 24 Jun 2015 23:07:05 +0200 Subject: [PATCH 24/38] blockchain isKnown block / transaction From ff328a9971b8942a38d3fc83e898845723762606 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 24 Jun 2015 23:25:13 +0200 Subject: [PATCH 25/38] getBlockBy** and getBlockTransactionCountBy** return null if block is not found From 72dc1c76fdf0cd8f0e97dab21f50e85003b43f78 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 1 Jul 2015 14:36:10 +0200 Subject: [PATCH 26/38] Squashed 'libjsqrc/ethereumjs/' changes from 2a0b46a..d5d2115 d5d2115 example contract using array, fixed #185 21ed235 removed connection keep-alive c44fe01 version 0.7.1 d9b785e fixed #248 490dde5 fixed encoding/decoding strings, #249 b3f5d09 fixed long bytes dynamic decoding/encoding, #249 d097821 small filter improvement d59b1cd removed xhr from browser 42b6e9d version 0.7.0 fe6defd gulp 44dcd24 set connection keepalive 2b17c0f gulpfile changes 4a46c73 Merge pull request #228 from ethereum/strings 93c8006 tests for encoding and decoding prematurely terminated strings and strings containing internal zeros 7dd44e7 Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings 390a9ff Merge branch 'develop' into strings bcd9cfb updated deps, removed unused karma ef15fc1 Merge pull request #244 from ethereum/allevents 6f74d57 Merge branch 'develop' into allevents 7aca17e Merge branch 'develop' into allevents c5ee34d fix for optional event parameters 8170a0a Merge pull request #245 from ethereum/filterInstantWatch 76a094c fixed all issues noted by marek d78b512 add possible callback to filters e1b17a9 re-build develop af9c027 all events filter b270616 version 0.6.1 c47d6a8 gulp 7cf7cf3 map file 6da1d3e gulp 450042e Update eth.js 3951286 Added sendRawTransaction 323b529 merged develop 16ffdf6 merged master ecf0a2c changed | to Math.floor d2b5ba2 Merge pull request #239 from ethereum/mistFixes 9e6bf9d removed browser XHR 9061116 fixed build issues in formatInputDynamicBytes 0e3b29c fixed coverage issue d51e9a2 merged latest develop f0247aa made meteor package available on the server side as well e97c5f5 fixed and tested meteor package init 3e49f56 add currentProvidor and mist fixes bd6d9ba merged develop 7b730b1 Merge branch 'strings' of github.com:ethereum/web3.js into strings cc533d9 fixed bytes wrong encoding 8c6f976 Merge branch 'develop' into strings 7c970e3 add bytes32 test with leading 0 9c7f7bb re-add .map files 189484f add extra int tests 73cc711 Merge branch 'develop' into strings fa3239f abi string type, fixes #216, #218, #219 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: d5d2115bf9ad07a736a189e1022b7d3a549e4006 --- batch.js | 25 ++++++- coder.decodeParam.js | 98 +++++++++++++++++++++----- coder.encodeParam.js | 87 ++++++++++++++++++++--- contract.js | 141 +++++++++++++++++++++++++++++++++++++ polling.js | 40 +++++++++++ utils.toHex.js | 1 + web3.eth.filter.methods.js | 8 +-- 7 files changed, 368 insertions(+), 32 deletions(-) diff --git a/batch.js b/batch.js index f368a5d74..5a06f0e7b 100644 --- a/batch.js +++ b/batch.js @@ -28,6 +28,16 @@ describe('lib/web3/batch', function () { done(); }; + provider.injectValidation(function (payload) { + var first = payload[0]; + var second = payload[1]; + + assert.equal(first.method, 'eth_getBalance'); + assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']); + assert.equal(second.method, 'eth_getBalance'); + assert.deepEqual(second.params, ['0x0000000000000000000000000000000000000005', 'latest']); + }); + var batch = web3.createBatch(); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback)); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000005', 'latest', callback2)); @@ -55,7 +65,7 @@ describe('lib/web3/batch', function () { }]; - var address = '0x0000000000000000000000000000000000000000'; + var address = '0x1000000000000000000000000000000000000001'; var result = '0x126'; var result2 = '0x0000000000000000000000000000000000000000000000000000000000000123'; @@ -71,6 +81,19 @@ describe('lib/web3/batch', function () { done(); }; + provider.injectValidation(function (payload) { + var first = payload[0]; + var second = payload[1]; + + assert.equal(first.method, 'eth_getBalance'); + assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']); + assert.equal(second.method, 'eth_call'); + assert.deepEqual(second.params, [{ + 'to': '0x1000000000000000000000000000000000000001', + 'data': '0xe3d670d70000000000000000000000001000000000000000000000000000000000000001' + }]); + }); + var batch = web3.createBatch(); batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback)); batch.add(web3.eth.contract(abi).at(address).balance.request(address, callback2)); diff --git a/coder.decodeParam.js b/coder.decodeParam.js index 959e96cf2..5555b7800 100644 --- a/coder.decodeParam.js +++ b/coder.decodeParam.js @@ -20,10 +20,53 @@ describe('lib/solidity/coder', function () { test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'}); test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); - test({ type: 'bytes32', expected: 'gavofyork', value: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ type: 'bytes', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' + + test({ type: 'int8', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int32', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int64', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int128', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'bytes32', expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000', + value: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', expected: '0x6761766f66796f726b', + value: '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000009' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes32', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + value: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'bytes', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000020' + + '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'bytes', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'bytes', expected: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000060' + + '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'string', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'string', expected: '\xc3\xa4\x00\x00\xc3\xa4', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000006' + + 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); + test({ type: 'string', expected: '\xc3', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000001' + + 'c300000000000000000000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', expected: '0xc3a40000c3a4', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000006' + + 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); + test({ type: 'bytes32', expected: '0xc3a40000c3a40000000000000000000000000000000000000000000000000000', + value: 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); test({ type: 'int[]', expected: [], value: '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000000'}); test({ type: 'int[]', expected: [new bn(3)], value: '0000000000000000000000000000000000000000000000000000000000000020' + @@ -49,6 +92,11 @@ describe('lib/solidity/coder', function () { test({ type: 'ureal', expected: new bn(8.5), value: '0000000000000000000000000000000880000000000000000000000000000000'}); test({ type: 'address', expected: '0x407d73d8a49eeb85d32cf465507dd71d507100c1', value: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1'}); + test({ type: 'string', expected: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.', + value: '0000000000000000000000000000000000000000000000000000000000000020' + + '000000000000000000000000000000000000000000000000000000000000003e' + + '77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' + + '657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000'}); }); }); @@ -62,26 +110,44 @@ describe('lib/solidity/coder', function () { test({ types: ['int'], expected: [new bn(1)], values: '0000000000000000000000000000000000000000000000000000000000000001'}); - test({ types: ['bytes32', 'int'], expected: ['gavofyork', new bn(5)], + test({ types: ['bytes32', 'int'], expected: ['0x6761766f66796f726b0000000000000000000000000000000000000000000000', new bn(5)], values: '6761766f66796f726b0000000000000000000000000000000000000000000000' + '0000000000000000000000000000000000000000000000000000000000000005'}); - test({ types: ['int', 'bytes32'], expected: [new bn(5), 'gavofyork'], + test({ types: ['int', 'bytes32'], expected: [new bn(5), '0x6761766f66796f726b0000000000000000000000000000000000000000000000'], values: '0000000000000000000000000000000000000000000000000000000000000005' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4), + test({ types: ['int', 'string', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4), [new bn(5), new bn(6), new bn(7)]], values: '0000000000000000000000000000000000000000000000000000000000000001' + - '00000000000000000000000000000000000000000000000000000000000000c0' + - '0000000000000000000000000000000000000000000000000000000000000002' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000004' + - '0000000000000000000000000000000000000000000000000000000000000100' + - '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000' + - '0000000000000000000000000000000000000000000000000000000000000003' + - '0000000000000000000000000000000000000000000000000000000000000005' + - '0000000000000000000000000000000000000000000000000000000000000006' + - '0000000000000000000000000000000000000000000000000000000000000007'}); + '00000000000000000000000000000000000000000000000000000000000000c0' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000004' + + '0000000000000000000000000000000000000000000000000000000000000100' + + '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000005' + + '0000000000000000000000000000000000000000000000000000000000000006' + + '0000000000000000000000000000000000000000000000000000000000000007'}); + test({ types: ['int', 'bytes', 'int', 'bytes'], expected: [ + new bn(5), + '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + new bn(3), + '0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + ], + values: '0000000000000000000000000000000000000000000000000000000000000005' + + '0000000000000000000000000000000000000000000000000000000000000080' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '00000000000000000000000000000000000000000000000000000000000000e0' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); }); }); diff --git a/coder.encodeParam.js b/coder.encodeParam.js index 55ff657c2..71ae7804e 100644 --- a/coder.encodeParam.js +++ b/coder.encodeParam.js @@ -20,10 +20,37 @@ describe('lib/solidity/coder', function () { test({ type: 'int256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}); test({ type: 'int256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}); test({ type: 'int256', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); - test({ type: 'bytes32', value: 'gavofyork', expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ type: 'bytes', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000020' + + test({ type: 'bytes32', value: '0x6761766f66796f726b', + expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes32', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + expected: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'bytes32', value: '0x02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29', + expected: '02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29'}); + test({ type: 'bytes', value: '0x6761766f66796f726b', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000009' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000020' + + '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'string', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', value: '0xc3a40000c3a4', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000006' + + 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); + test({ type: 'bytes32', value: '0xc3a40000c3a4', + expected: 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); + test({ type: 'string', value: '\xc3\xa4\x00\x00\xc3\xa4', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000006' + + 'c3a40000c3a40000000000000000000000000000000000000000000000000000'}); + test({ type: 'string', value: '\xc3', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000001' + + 'c300000000000000000000000000000000000000000000000000000000000000'}); test({ type: 'int[]', value: [], expected: '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000000'}); test({ type: 'int[]', value: [3], expected: '0000000000000000000000000000000000000000000000000000000000000020' + @@ -48,6 +75,25 @@ describe('lib/solidity/coder', function () { test({ type: 'ureal', value: 1, expected: '0000000000000000000000000000000100000000000000000000000000000000'}); test({ type: 'ureal', value: 2.125, expected: '0000000000000000000000000000000220000000000000000000000000000000'}); test({ type: 'ureal', value: 8.5, expected: '0000000000000000000000000000000880000000000000000000000000000000'}); + test({ type: 'bytes', value: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'bytes', value: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000060' + + '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); + test({ type: 'string', value: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.', + expected: '0000000000000000000000000000000000000000000000000000000000000020' + + '000000000000000000000000000000000000000000000000000000000000003e' + + '77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' + + '657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000'}); }); }); @@ -67,8 +113,9 @@ describe('lib/solidity/coder', function () { test({ types: ['int256'], values: [1], expected: '0000000000000000000000000000000000000000000000000000000000000001'}); test({ types: ['int256'], values: [16], expected: '0000000000000000000000000000000000000000000000000000000000000010'}); test({ types: ['int256'], values: [-1], expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); - test({ types: ['bytes32'], values: ['gavofyork'], expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ types: ['bytes'], values: ['gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000020' + + test({ types: ['bytes32'], values: ['0x6761766f66796f726b'], + expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['string'], values: ['gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000020' + '0000000000000000000000000000000000000000000000000000000000000009' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); test({ types: ['int[]'], values: [[3]], expected: '0000000000000000000000000000000000000000000000000000000000000020' + @@ -91,18 +138,18 @@ describe('lib/solidity/coder', function () { '0000000000000000000000000000000000000000000000000000000000000002' + '0000000000000000000000000000000000000000000000000000000000000003' + '0000000000000000000000000000000000000000000000000000000000000004'}); - test({ types: ['bytes32', 'int'], values: ['gavofyork', 5], + test({ types: ['bytes32', 'int'], values: ['0x6761766f66796f726b', 5], expected: '6761766f66796f726b0000000000000000000000000000000000000000000000' + '0000000000000000000000000000000000000000000000000000000000000005'}); - test({ types: ['int', 'bytes32'], values: [5, 'gavofyork'], + test({ types: ['int', 'bytes32'], values: [5, '0x6761766f66796f726b'], expected: '0000000000000000000000000000000000000000000000000000000000000005' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ types: ['bytes', 'int'], values: ['gavofyork', 5], + test({ types: ['string', 'int'], values: ['gavofyork', 5], expected: '0000000000000000000000000000000000000000000000000000000000000040' + '0000000000000000000000000000000000000000000000000000000000000005' + '0000000000000000000000000000000000000000000000000000000000000009' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ types: ['bytes', 'bool', 'int[]'], values: ['gavofyork', true, [1, 2, 3]], + test({ types: ['string', 'bool', 'int[]'], values: ['gavofyork', true, [1, 2, 3]], expected: '0000000000000000000000000000000000000000000000000000000000000060' + '0000000000000000000000000000000000000000000000000000000000000001' + '00000000000000000000000000000000000000000000000000000000000000a0' + @@ -112,7 +159,7 @@ describe('lib/solidity/coder', function () { '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000002' + '0000000000000000000000000000000000000000000000000000000000000003'}); - test({ types: ['bytes', 'int[]'], values: ['gavofyork', [1, 2, 3]], + test({ types: ['string', 'int[]'], values: ['gavofyork', [1, 2, 3]], expected: '0000000000000000000000000000000000000000000000000000000000000040' + '0000000000000000000000000000000000000000000000000000000000000080' + '0000000000000000000000000000000000000000000000000000000000000009' + @@ -121,12 +168,12 @@ describe('lib/solidity/coder', function () { '0000000000000000000000000000000000000000000000000000000000000001' + '0000000000000000000000000000000000000000000000000000000000000002' + '0000000000000000000000000000000000000000000000000000000000000003'}); - test({ types: ['int', 'bytes'], values: [5, 'gavofyork'], + test({ types: ['int', 'string'], values: [5, 'gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000005' + '0000000000000000000000000000000000000000000000000000000000000040' + '0000000000000000000000000000000000000000000000000000000000000009' + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); - test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]], + test({ types: ['int', 'string', 'int', 'int', 'int', 'int[]'], values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]], expected: '0000000000000000000000000000000000000000000000000000000000000001' + '00000000000000000000000000000000000000000000000000000000000000c0' + '0000000000000000000000000000000000000000000000000000000000000002' + @@ -139,6 +186,24 @@ describe('lib/solidity/coder', function () { '0000000000000000000000000000000000000000000000000000000000000005' + '0000000000000000000000000000000000000000000000000000000000000006' + '0000000000000000000000000000000000000000000000000000000000000007'}); + test({ types: ['int', 'bytes', 'int', 'bytes'], values: [ + 5, + '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + 3, + '0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b', + ], + expected: '0000000000000000000000000000000000000000000000000000000000000005' + + '0000000000000000000000000000000000000000000000000000000000000080' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '00000000000000000000000000000000000000000000000000000000000000e0' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '0000000000000000000000000000000000000000000000000000000000000040' + + '331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' + + '431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'}); }); }); diff --git a/contract.js b/contract.js index 2632575f5..71ac20701 100644 --- a/contract.js +++ b/contract.js @@ -127,6 +127,147 @@ describe('web3.eth.contract', function () { }); }); + it('should create event filter and watch immediately', function (done) { + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); // reset different polls + var signature = 'Changed(address,uint256,uint256,uint256)'; + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + step = 1; + provider.injectResult('0x3'); + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_newFilter'); + assert.deepEqual(payload.params[0], { + topics: [ + '0x' + sha3(signature), + '0x0000000000000000000000001234567890123456789012345678901234567890', + null + ], + address: '0x1234567890123456789012345678901234567890' + }); + } else if (step === 1) { + step = 2; + provider.injectResult([{ + address: address, + topics: [ + '0x' + sha3(signature), + '0x0000000000000000000000001234567890123456789012345678901234567890', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + number: 2, + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }]); + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_getFilterLogs'); + } else if (step === 2 && utils.isArray(payload)) { + provider.injectBatchResults([[{ + address: address, + topics: [ + '0x' + sha3(signature), + '0x0000000000000000000000001234567890123456789012345678901234567890', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + number: 2, + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }]]); + var r = payload.filter(function (p) { + return p.jsonrpc === '2.0' && p.method === 'eth_getFilterChanges' && p.params[0] === '0x3'; + }); + assert.equal(r.length > 0, true); + } + }); + + var contract = web3.eth.contract(desc).at(address); + + var res = 0; + var event = contract.Changed({from: address}, function(err, result) { + assert.equal(result.args.from, address); + assert.equal(result.args.amount, 1); + assert.equal(result.args.t1, 1); + assert.equal(result.args.t2, 8); + res++; + if (res === 2) { + done(); + } + }); + }); + + it('should create all event filter', function (done) { + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); // reset different polls + var signature = 'Changed(address,uint256,uint256,uint256)'; + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + step = 1; + provider.injectResult('0x3'); + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_newFilter'); + assert.deepEqual(payload.params[0], { + topics: [ + null, + null, + null, + null, + null + ], + address: '0x1234567890123456789012345678901234567890' + }); + } else if (step === 1) { + step = 2; + provider.injectResult([{ + address: address, + topics: [ + '0x' + sha3(signature), + '0x0000000000000000000000001234567890123456789012345678901234567890', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + number: 2, + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }]); + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_getFilterLogs'); + } else if (step === 2 && utils.isArray(payload)) { + provider.injectBatchResults([[{ + address: address, + topics: [ + '0x' + sha3(signature), + '0x0000000000000000000000001234567890123456789012345678901234567890', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + number: 2, + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }]]); + var r = payload.filter(function (p) { + return p.jsonrpc === '2.0' && p.method === 'eth_getFilterChanges' && p.params[0] === '0x3'; + }); + assert.equal(r.length > 0, true); + } + }); + + var contract = web3.eth.contract(desc).at(address); + + var res = 0; + var event = contract.allEvents(); + event.watch(function(err, result) { + assert.equal(result.args.from, address); + assert.equal(result.args.amount, 1); + assert.equal(result.args.t1, 1); + assert.equal(result.args.t2, 8); + res++; + if (res === 2) { + done(); + } + }); + }); + it('should call constant function', function () { var provider = new FakeHttpProvider(); web3.setProvider(provider); diff --git a/polling.js b/polling.js index 8bd2b041c..88cfee4cc 100644 --- a/polling.js +++ b/polling.js @@ -63,6 +63,8 @@ var testPolling = function (tests) { var filter = web3[test.protocol].filter.apply(null, test.args); provider.injectBatchResults([test.secondResult]); filter.watch(function (err, result) { + console.log(err, result); + if (test.err) { // todo } else { @@ -72,6 +74,44 @@ var testPolling = function (tests) { }); }); + it('should create && successfully poll filter when passed as callback', function (done) { + + // given + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); + provider.injectResult(test.firstResult); + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + step = 1; + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, test.firstPayload.method); + assert.deepEqual(payload.params, test.firstPayload.params); + } else if (step === 1 && utils.isArray(payload)) { + var r = payload.filter(function (p) { + return p.jsonrpc === '2.0' && p.method === test.secondPayload.method && p.params[0] === test.firstResult; + }); + assert.equal(r.length > 0, true); + } + + }); + + // add callback + test.args.push(function (err, result) { + if (test.err) { + // todo + } else { + assert.equal(result, test.secondResult[0]); + } + done(); + + }); + + // when + var filter = web3[test.protocol].filter.apply(null, test.args); + provider.injectBatchResults([test.secondResult]); + }); }); }); }; diff --git a/utils.toHex.js b/utils.toHex.js index 0a328e345..fdf88cd38 100644 --- a/utils.toHex.js +++ b/utils.toHex.js @@ -14,6 +14,7 @@ var tests = [ { value: '-0x1', expected: '-0x1'}, { value: '-15', expected: '-0xf'}, { value: '-0xf', expected: '-0xf'}, + { value: '0x657468657265756d', expected: '0x657468657265756d'}, { value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'}, { value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, { value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'}, diff --git a/web3.eth.filter.methods.js b/web3.eth.filter.methods.js index f40f3d0ac..c15d720e2 100644 --- a/web3.eth.filter.methods.js +++ b/web3.eth.filter.methods.js @@ -14,10 +14,10 @@ var implementation = { describe('web3.eth.filter', function () { describe('methods', function () { - //var f = filter({}, implementation); + // var f = filter({}, implementation); - //u.methodExists(f, 'watch'); - //u.methodExists(f, 'stopWatching'); - //u.methodExists(f, 'get'); + // u.methodExists(f, 'watch'); + // u.methodExists(f, 'stopWatching'); + // u.methodExists(f, 'get'); }); }); From c42110c90af1f8f81d080cc3f84bac56066ad3a4 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Fri, 26 Jun 2015 17:28:47 +0200 Subject: [PATCH 27/38] Distribution Rate test introduced From 1af066d5299c49f37e78726e47f7b57c38dded89 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Tue, 30 Jun 2015 18:31:00 +0200 Subject: [PATCH 28/38] style fix From 380ebe817f90600212b915de94d42bf14184966b Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 1 Jul 2015 11:49:04 +0200 Subject: [PATCH 29/38] mega enhanced style fix From 5476196c655bb65fafcc79d7accbb9c842ff8071 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 1 Jul 2015 14:41:02 +0200 Subject: [PATCH 30/38] super mega enhanced update From 600a16218aafa0569ffb3b98385ee6f7bd30642e Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 1 Jul 2015 13:53:53 +0200 Subject: [PATCH 31/38] Documentation and tests for RangeMask. From ca1d6de497675a65ce1da0b6837523a82dbd433b Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 1 Jul 2015 20:49:18 +0200 Subject: [PATCH 32/38] build fix From 05254514c145553cab8b68656e5b9cd24e13e51f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 2 Jul 2015 15:17:20 +0200 Subject: [PATCH 33/38] add transactionQueue tests From 3f03b3e14f0b165094a36a47f86ebf592f8f91fa Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 3 Jul 2015 00:01:12 +0200 Subject: [PATCH 34/38] style From fd0d432b24bcbd52612fee90f70f99546555381c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 3 Jul 2015 10:10:20 +0200 Subject: [PATCH 35/38] Fix for crap compilers. Fix for tests. From fc8f83b84e9e7ac97ef41f88202baa9cec117405 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 30 Jun 2015 11:54:51 +0200 Subject: [PATCH 36/38] Memory structs. --- libsolidity/SolidityEndToEndTest.cpp | 143 +++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index a2dbc35e6..5ad8e6f3d 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4806,6 +4806,149 @@ BOOST_AUTO_TEST_CASE(memory_arrays_dynamic_index_access_write) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0x20), u256(4), data)); } +BOOST_AUTO_TEST_CASE(memory_structs_read_write) +{ + char const* sourceCode = R"( + contract Test { + struct S { uint8 x; uint16 y; uint z; uint8[2] a; } + S[5] data; + function testInit() returns (uint8 x, uint16 y, uint z, uint8 a, bool flag) { + S[2] memory d; + x = d[0].x; + y = d[0].y; + z = d[0].z; + a = d[0].a[1]; + flag = true; + } + function testCopyRead() returns (uint8 x, uint16 y, uint z, uint8 a) { + data[2].x = 1; + data[2].y = 2; + data[2].z = 3; + data[2].a[1] = 4; + S memory s = data[2]; + x = s.x; + y = s.y; + z = s.z; + a = s.a[1]; + } + function testAssign() returns (uint8 x, uint16 y, uint z, uint8 a) { + S memory s; + s.x = 1; + s.y = 2; + s.z = 3; + s.a[1] = 4; + x = s.x; + y = s.y; + z = s.z; + a = s.a[1]; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + BOOST_CHECK(callContractFunction("testInit()") == encodeArgs(u256(0), u256(0), u256(0), u256(0), true)); + BOOST_CHECK(callContractFunction("testCopyRead()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); + BOOST_CHECK(callContractFunction("testAssign()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); +} + +BOOST_AUTO_TEST_CASE(memory_structs_as_function_args) +{ + char const* sourceCode = R"( + contract Test { + struct S { uint8 x; uint16 y; uint z; } + function test() returns (uint x, uint y, uint z) { + S memory data = combine(1, 2, 3); + x = extract(data, 0); + y = extract(data, 1); + z = extract(data, 2); + } + function extract(S s, uint which) internal returns (uint x) { + if (which == 0) return s.x; + else if (which == 1) return s.y; + else return s.z; + } + function combine(uint8 x, uint16 y, uint z) internal returns (S s) { + s.x = x; + s.y = y; + s.z = z; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3))); +} + +BOOST_AUTO_TEST_CASE(memory_structs_wrapped) +{ + char const* sourceCode = R"( + contract Test { + struct S { uint8 x; uint16 y; uint z; } + struct X { uint8 x; S s; } + function test() returns (uint a, uint x, uint y, uint z) { + X memory d = combine(1, 2, 3, 4); + a = extract(d, 0); + x = extract(d, 1); + y = extract(d, 2); + z = extract(d, 3); + } + function extract(X s, uint which) internal returns (uint x) { + if (which == 0) return s.x; + else if (which == 1) return s.s.x; + else if (which == 2) return s.s.y; + else return s.s.z; + } + function combine(uint8 a, uint8 x, uint16 y, uint z) internal returns (X s) { + s.x = a; + s.s.x = x; + s.s.y = y; + s.s.z = z; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); +} + +BOOST_AUTO_TEST_CASE(memory_structs_wrapped_load) +{ + char const* sourceCode = R"( + contract Test { + struct S { uint8 x; uint16 y; uint z; } + struct X { uint8 x; S s; } + X m_x; + function load() returns (uint a, uint x, uint y, uint z) { + m_x.x = 1; + m_x.s.x = 2; + m_x.s.y = 3; + m_x.s.z = 4; + X memory d = m_x; + a = d.x; + x = d.s.x; + y = d.s.y; + z = d.s.z; + } + function store() returns (uint a, uint x, uint y, uint z) { + X memory d = m_x; + d.x = 1; + d.s.x = 2; + d.s.y = 3; + d.s.z = 4; + m_x = d; + a = m_x.x; + x = m_x.s.x; + y = m_x.s.y; + z = m_x.s.z; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + BOOST_CHECK(callContractFunction("load()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); + BOOST_CHECK(callContractFunction("store()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); +} + BOOST_AUTO_TEST_SUITE_END() } From 3350f1d304c8f8ff01c2af506f7aca98bc9cdc40 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 30 Jun 2015 21:03:23 +0200 Subject: [PATCH 37/38] Fix for copying arrays to storage. --- libsolidity/SolidityEndToEndTest.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 5ad8e6f3d..c631b83b7 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4879,7 +4879,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_as_function_args) BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3))); } -BOOST_AUTO_TEST_CASE(memory_structs_wrapped) +BOOST_AUTO_TEST_CASE(memory_structs_nested) { char const* sourceCode = R"( contract Test { @@ -4911,42 +4911,51 @@ BOOST_AUTO_TEST_CASE(memory_structs_wrapped) BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); } -BOOST_AUTO_TEST_CASE(memory_structs_wrapped_load) +BOOST_AUTO_TEST_CASE(memory_structs_nested_load) { char const* sourceCode = R"( contract Test { struct S { uint8 x; uint16 y; uint z; } - struct X { uint8 x; S s; } + struct X { uint8 x; S s; uint8[2] a; } X m_x; - function load() returns (uint a, uint x, uint y, uint z) { + function load() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) { m_x.x = 1; m_x.s.x = 2; m_x.s.y = 3; m_x.s.z = 4; + m_x.a[0] = 5; + m_x.a[1] = 6; X memory d = m_x; a = d.x; x = d.s.x; y = d.s.y; z = d.s.z; + a1 = d.a[0]; + a2 = d.a[1]; } - function store() returns (uint a, uint x, uint y, uint z) { - X memory d = m_x; + function store() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) { + X memory d; d.x = 1; d.s.x = 2; d.s.y = 3; d.s.z = 4; + d.a[0] = 5; + d.a[1] = 6; m_x = d; a = m_x.x; x = m_x.s.x; y = m_x.s.y; z = m_x.s.z; + a1 = m_x.a[0]; + a2 = m_x.a[1]; } } )"; compileAndRun(sourceCode, 0, "Test"); - BOOST_CHECK(callContractFunction("load()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); - BOOST_CHECK(callContractFunction("store()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); + auto out = encodeArgs(u256(1), u256(2), u256(3), u256(4), u256(5), u256(6)); + BOOST_CHECK(callContractFunction("load()") == out); + BOOST_CHECK(callContractFunction("store()") == out); } BOOST_AUTO_TEST_SUITE_END() From a393acd0b26d6c9cc2bd7c74730fdfb9d6fc9ed6 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 30 Jun 2015 21:08:34 +0200 Subject: [PATCH 38/38] Struct constructors. --- libsolidity/SolidityEndToEndTest.cpp | 43 +++++++++++++++++++ libsolidity/SolidityNameAndTypeResolution.cpp | 41 ++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index c631b83b7..3ddb05528 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4958,6 +4958,49 @@ BOOST_AUTO_TEST_CASE(memory_structs_nested_load) BOOST_CHECK(callContractFunction("store()") == out); } +BOOST_AUTO_TEST_CASE(struct_constructor_nested) +{ + char const* sourceCode = R"( + contract C { + struct X { uint x1; uint x2; } + struct S { uint s1; uint[3] s2; X s3; } + S s; + function C() { + uint[3] memory s2; + s2[1] = 9; + s = S(1, s2, X(4, 5)); + } + function get() returns (uint s1, uint[3] s2, uint x1, uint x2) + { + s1 = s.s1; + s2 = s.s2; + x1 = s.s3.x1; + x2 = s.s3.x2; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + + auto out = encodeArgs(u256(1), u256(0), u256(9), u256(0), u256(4), u256(5)); + BOOST_CHECK(callContractFunction("get()") == out); +} + +BOOST_AUTO_TEST_CASE(struct_named_constructor) +{ + char const* sourceCode = R"( + contract C { + struct S { uint a; bool x; } + S public s; + function C() { + s = S({a: 1, x: true}); + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + + BOOST_CHECK(callContractFunction("s()") == encodeArgs(u256(1), true)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index 4914ef975..50fcdbbe5 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2056,6 +2056,47 @@ BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(struct_constructor) +{ + char const* sourceCode = R"( + contract C { + struct S { uint a; bool x; } + function f() { + S memory s = S(1, true); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + +BOOST_AUTO_TEST_CASE(struct_constructor_nested) +{ + char const* sourceCode = R"( + contract C { + struct X { uint x1; uint x2; } + struct S { uint s1; uint[3] s2; X s3; } + function f() { + uint[3] memory s2; + S memory s = S(1, s2, X(4, 5)); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + +BOOST_AUTO_TEST_CASE(struct_named_constructor) +{ + char const* sourceCode = R"( + contract C { + struct S { uint a; bool x; } + function f() { + S memory s = S({a: 1, x: true}); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + BOOST_AUTO_TEST_SUITE_END() }