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 | |
parent | dfe567f20c6c48d2a2c4f18bcf378802e654dbfc (diff) | |
parent | 567c4cd94200caf8c3ea6f4575aaee2786c60378 (diff) | |
download | dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.gz dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.tar.zst dexon-solidity-157f93898ae57cff875beb6549314bcb4ac66cdf.zip |
Merge pull request #1149 from winsvega/develop
More Transaction Tests
-rw-r--r-- | TestHelper.cpp | 50 | ||||
-rw-r--r-- | transaction.cpp | 3 | ||||
-rw-r--r-- | ttTransactionTestFiller.json | 152 |
3 files changed, 182 insertions, 23 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) diff --git a/transaction.cpp b/transaction.cpp index 8c6db941..c7a0e61d 100644 --- a/transaction.cpp +++ b/transaction.cpp @@ -90,8 +90,9 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin) o["sender"] = toString(txFromFields.sender()); } - catch(...) + catch(Exception const& _e) { + cnote << "Transaction Exception: " << diagnostic_information(_e); o.erase(o.find("transaction")); } } diff --git a/ttTransactionTestFiller.json b/ttTransactionTestFiller.json index 04289f37..23a384d5 100644 --- a/ttTransactionTestFiller.json +++ b/ttTransactionTestFiller.json @@ -151,7 +151,22 @@ } }, - "TransactionWithSvalueOverflow" : { + "TransactionWithSvalueHigh" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + } + }, + + "TransactionWithSvalueTooHigh" : { "transaction" : { "data" : "", @@ -166,6 +181,21 @@ } }, + "TransactionWithSvalueOverflow" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000" + } + }, + "TransactionWithRvalueOverflow" : { "transaction" : { @@ -176,11 +206,86 @@ "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "11", "v" : "27", + "r" : "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641410000", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + + "TransactionWithRvalueHigh" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140", + "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3" + } + }, + + "TransactionWithRvalueTooHigh" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", "r" : "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" } }, + "TransactionWithRvalueWrongSize" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0xebaaedce6af48a03bbfd25e8cd0364141", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + + "TransactionWithSvalueWrongSize" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a", + "s" : "0xef0b28ad43601b4ab949f53faa07bd2c804" + } + }, + + "TransactionWithHihghNonce" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + "TransactionWithNonceOverflow" : { "transaction" : { @@ -196,6 +301,51 @@ } }, + "TransactionWithHihghGas" : { + "transaction" : + { + "data" : "", + "gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + + "TransactionWithHihghGasPrice" : { + "transaction" : + { + "data" : "", + "gasLimit" : "1000", + "gasPrice" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + + "TransactionWithGasLimitxPriceOverflow" : { + "transaction" : + { + "data" : "", + "gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "gasPrice" : "100000000000000000", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + } + }, + "TransactionWithGasPriceOverflow" : { "transaction" : { |