From f7f26d0fbd6f8ba1f00a547dd243f4394e3b524c Mon Sep 17 00:00:00 2001 From: winsvega Date: Sat, 31 Jan 2015 21:00:35 +0300 Subject: state test conditions to filler files --- TestHelper.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 5a579702..8cb4e11c 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -108,6 +108,12 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) BOOST_REQUIRE(o.count("storage") > 0); BOOST_REQUIRE(o.count("code") > 0); + bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); + if (bigint(o["balance"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'balance' is equal or grater than 2**256") ); + if (bigint(o["nonce"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'nonce' is equal or grater than 2**256") ); + Address address = Address(i.first); bytes code = importCode(o); @@ -140,6 +146,16 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) BOOST_REQUIRE(_o.count("secretKey") > 0); BOOST_REQUIRE(_o.count("data") > 0); + bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); + if (bigint(_o["nonce"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'nonce' is equal or grater than 2**256") ); + if (bigint(_o["gasPrice"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasPrice' is equal or grater than 2**256") ); + if (bigint(_o["gasLimit"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasLimit' is equal or grater than 2**256") ); + if (bigint(_o["value"].get_str()) >= biValue256) + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'value' is equal or grater than 2**256") ); + m_transaction = _o["to"].get_str().empty() ? Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str())) : Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), Address(_o["to"].get_str()), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str())); -- cgit From 4d760868602ec35e4d6013c854b405d5b6def8a8 Mon Sep 17 00:00:00 2001 From: winsvega Date: Fri, 6 Feb 2015 18:28:48 +0300 Subject: nonce value from 0 to "0" in fillers --- TestHelper.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 8cb4e11c..fc05de85 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -110,9 +110,9 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); if (bigint(o["balance"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'balance' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); if (bigint(o["nonce"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'nonce' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'nonce' is equal or greater than 2**256") ); Address address = Address(i.first); @@ -148,13 +148,14 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); if (bigint(_o["nonce"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'nonce' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); if (bigint(_o["gasPrice"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasPrice' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") ); if (bigint(_o["gasLimit"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasLimit' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") ); if (bigint(_o["value"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'value' is equal or grater than 2**256") ); + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") ); + m_transaction = _o["to"].get_str().empty() ? Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str())) : -- cgit From f853f4a937215a571bc8b2b6a12b0565039de6a1 Mon Sep 17 00:00:00 2001 From: winsvega Date: Sat, 7 Feb 2015 14:23:17 +0300 Subject: Style Changes New exception for values larger than 2**256 Auto format .json files --- TestHelper.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index fc05de85..fbb302f1 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -110,9 +110,9 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); if (bigint(o["balance"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); if (bigint(o["nonce"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("State 'nonce' is equal or greater than 2**256") ); + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'nonce' is equal or greater than 2**256") ); Address address = Address(i.first); @@ -148,14 +148,13 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); if (bigint(_o["nonce"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); if (bigint(_o["gasPrice"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") ); + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") ); if (bigint(_o["gasLimit"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") ); + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") ); if (bigint(_o["value"].get_str()) >= biValue256) - BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") ); - + BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") ); m_transaction = _o["to"].get_str().empty() ? Transaction(toInt(_o["value"]), toInt(_o["gasPrice"]), toInt(_o["gasLimit"]), importData(_o), toInt(_o["nonce"]), Secret(_o["secretKey"].get_str())) : -- cgit From d77b3a672cb5f3e210c419672aaed0643a8e87c2 Mon Sep 17 00:00:00 2001 From: winsvega Date: Mon, 9 Feb 2015 23:40:47 +0300 Subject: Bigint bigint(1) << 256 --- TestHelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index fbb302f1..ed351bb7 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -108,7 +108,7 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) BOOST_REQUIRE(o.count("storage") > 0); BOOST_REQUIRE(o.count("code") > 0); - bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); + bigint biValue256 = bigint(1) << 256; if (bigint(o["balance"].get_str()) >= biValue256) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); if (bigint(o["nonce"].get_str()) >= biValue256) @@ -146,7 +146,7 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) BOOST_REQUIRE(_o.count("secretKey") > 0); BOOST_REQUIRE(_o.count("data") > 0); - bigint biValue256 = bigint("115792089237316195423570985008687907853269984665640564039457584007913129639936"); + bigint biValue256 = bigint(1) << 256; if (bigint(_o["nonce"].get_str()) >= biValue256) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); if (bigint(_o["gasPrice"].get_str()) >= biValue256) -- cgit From c09b7885e88b842a024e6b8a2e6cf5fd5d845ab3 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 10 Feb 2015 13:07:31 +0300 Subject: Test related Constant in TestHelper.h Exception in TestHelper.h --- TestHelper.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index ed351bb7..8e4c493e 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -108,10 +108,9 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) BOOST_REQUIRE(o.count("storage") > 0); BOOST_REQUIRE(o.count("code") > 0); - bigint biValue256 = bigint(1) << 256; - if (bigint(o["balance"].get_str()) >= biValue256) + if (bigint(o["balance"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'balance' is equal or greater than 2**256") ); - if (bigint(o["nonce"].get_str()) >= biValue256) + if (bigint(o["nonce"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'nonce' is equal or greater than 2**256") ); Address address = Address(i.first); @@ -146,14 +145,13 @@ void ImportTest::importTransaction(json_spirit::mObject& _o) BOOST_REQUIRE(_o.count("secretKey") > 0); BOOST_REQUIRE(_o.count("data") > 0); - bigint biValue256 = bigint(1) << 256; - if (bigint(_o["nonce"].get_str()) >= biValue256) + if (bigint(_o["nonce"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") ); - if (bigint(_o["gasPrice"].get_str()) >= biValue256) + if (bigint(_o["gasPrice"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") ); - if (bigint(_o["gasLimit"].get_str()) >= biValue256) + if (bigint(_o["gasLimit"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") ); - if (bigint(_o["value"].get_str()) >= biValue256) + if (bigint(_o["value"].get_str()) >= c_max256plus1) BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") ); m_transaction = _o["to"].get_str().empty() ? -- cgit From 9a792edb33a95f8034cbb368e94e8ca0f4565415 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 10 Feb 2015 20:53:38 +0100 Subject: Test stuff into cpp from header. Additional debug stuff in cmake. --- TestHelper.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'TestHelper.cpp') diff --git a/TestHelper.cpp b/TestHelper.cpp index 8e4c493e..8a00a546 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -64,6 +64,9 @@ void connectClients(Client& c1, Client& c2) namespace test { +struct ValueTooLarge: virtual Exception {}; +bigint const c_max256plus1 = bigint(1) << 256; + ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o) { importEnv(_o["env"].get_obj()); -- cgit