diff options
author | Gav Wood <g@ethdev.com> | 2015-02-27 01:38:02 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-02-27 01:38:02 +0800 |
commit | 157f93898ae57cff875beb6549314bcb4ac66cdf (patch) | |
tree | 75cde752b2349b4e7646671099771850b06e4795 /TestHelper.cpp | |
parent | dfe567f20c6c48d2a2c4f18bcf378802e654dbfc (diff) | |
parent | 567c4cd94200caf8c3ea6f4575aaee2786c60378 (diff) | |
download | dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.gz dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.bz2 dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.lz dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.xz dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.zst dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.zip |
Merge pull request #1149 from winsvega/develop
More Transaction Tests
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r-- | TestHelper.cpp | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp index 71d38103..ea44111c 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -139,27 +139,35 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) } void ImportTest::importTransaction(json_spirit::mObject& _o) -{ - BOOST_REQUIRE(_o.count("nonce")> 0); - BOOST_REQUIRE(_o.count("gasPrice") > 0); - BOOST_REQUIRE(_o.count("gasLimit") > 0); - BOOST_REQUIRE(_o.count("to") > 0); - BOOST_REQUIRE(_o.count("value") > 0); - 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())); +{ + if (_o.count("secretKey") > 0) + { + BOOST_REQUIRE(_o.count("nonce") > 0); + BOOST_REQUIRE(_o.count("gasPrice") > 0); + BOOST_REQUIRE(_o.count("gasLimit") > 0); + BOOST_REQUIRE(_o.count("to") > 0); + BOOST_REQUIRE(_o.count("value") > 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())); + } + else + { + RLPStream transactionRLPStream = createRLPStreamFromTransactionFields(_o); + RLP transactionRLP(transactionRLPStream.out()); + m_transaction = Transaction(transactionRLP.data(), CheckSignature::Sender); + } } void ImportTest::exportTest(bytes _output, State& _statePost) |