aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
authordebris <marek.kotewicz@gmail.com>2015-02-11 23:24:37 +0800
committerdebris <marek.kotewicz@gmail.com>2015-02-11 23:24:37 +0800
commit396649409eb6ac3a4aad5516f692e6beb31c69b6 (patch)
tree239d24ebef6bc93a25dfeb9bf97e73ada687c9bf /TestHelper.cpp
parent5ab36afaed2372278904b838ba10e3c6d87d1c75 (diff)
parent9a792edb33a95f8034cbb368e94e8ca0f4565415 (diff)
downloaddexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar.gz
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar.bz2
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar.lz
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar.xz
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.tar.zst
dexon-solidity-396649409eb6ac3a4aad5516f692e6beb31c69b6.zip
Merge branch 'develop' into jsoncpp_path
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r--TestHelper.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 5a579702..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());
@@ -108,6 +111,11 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
BOOST_REQUIRE(o.count("storage") > 0);
BOOST_REQUIRE(o.count("code") > 0);
+ 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()) >= c_max256plus1)
+ BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("State 'nonce' is equal or greater than 2**256") );
+
Address address = Address(i.first);
bytes code = importCode(o);
@@ -140,6 +148,15 @@ void ImportTest::importTransaction(json_spirit::mObject& _o)
BOOST_REQUIRE(_o.count("secretKey") > 0);
BOOST_REQUIRE(_o.count("data") > 0);
+ 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()) >= c_max256plus1)
+ BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") );
+ 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()) >= c_max256plus1)
+ 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())) :
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()));