aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
authorCJentzsch <jentzsch.software@gmail.com>2015-02-11 18:19:44 +0800
committerCJentzsch <jentzsch.software@gmail.com>2015-02-11 18:19:44 +0800
commit87b0a1005207edca25ffc2f4f66c1f2d914521e7 (patch)
tree37bc0805ba62352061c8e7ed56ef733f9aa66dd3 /TestHelper.cpp
parent4578732556684b3c7f24793d0459e2e8b40fe458 (diff)
parent9a792edb33a95f8034cbb368e94e8ca0f4565415 (diff)
downloaddexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar.gz
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar.bz2
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar.lz
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar.xz
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.tar.zst
dexon-solidity-87b0a1005207edca25ffc2f4f66c1f2d914521e7.zip
Merge remote-tracking branch 'upstream/develop' into blockTests
Conflicts: test/transaction.cpp
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 3289305c..43e6106d 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()));