diff options
-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..6c6ac2e5 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 6ebe6275..de653a22 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 78615bb4..3e79de11 100644 --- a/ttTransactionTestFiller.json +++ b/ttTransactionTestFiller.json @@ -136,7 +136,22 @@ } }, - "TransactionWithSvalueOverflow" : { + "TransactionWithSvalueHigh" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + } + }, + + "TransactionWithSvalueTooHigh" : { "transaction" : { "data" : "", @@ -151,6 +166,21 @@ } }, + "TransactionWithSvalueOverflow" : { + "transaction" : + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "11", + "v" : "27", + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000" + } + }, + "TransactionWithRvalueOverflow" : { "transaction" : { @@ -161,11 +191,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" : { @@ -181,6 +286,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" : { |