diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 8a00a5462..5e7472105 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -247,7 +247,7 @@ byte toByte(json_spirit::mValue const& _v) bytes importByteArray(std::string const& _str) { - return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str); + return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str, ThrowType::Throw); } bytes importData(json_spirit::mObject& _o) diff --git a/test/stTransactionTestFiller.json b/test/stTransactionTestFiller.json index e5369f0cd..214a0ae7c 100644 --- a/test/stTransactionTestFiller.json +++ b/test/stTransactionTestFiller.json @@ -189,6 +189,53 @@ } }, + "InternalCallHittingGasLimit" : { + "env" : { + "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1100", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "code" : "{ (CALL 5000 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b 1 0 0 0 0) }", + "nonce" : "0", + "storage" : { + } + }, + + "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0", + "code" : "{[[1]]55}", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "1100", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + "TransactionFromCoinbaseHittingBlockGasLimit" : { "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", @@ -623,7 +670,7 @@ "balance" : "100000", "code" : "", "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "nonce" : "10000000", + "nonce" : "10000", "storage" : { } } @@ -634,7 +681,7 @@ "gasLimit" : "1000", "gasPrice" : "1", "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "nonce" : "10000000", + "nonce" : "10000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "value" : "100" @@ -864,5 +911,106 @@ "to" : "0xffffffffffffffffffffffffffffffffffffffff", "value" : "100" } + }, + + "CreateTransactionReverted" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", + "gasLimit" : "882", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "" + } + }, + + "CreateTransactionWorking" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", + "gasLimit" : "883", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "100" + } + }, + + "CreateMessageReverted" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0", + "code" : "{(MSTORE 0 0x600c600055) (CREATE 0 27 5)}", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "882", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "100" + } } } diff --git a/test/transaction.cpp b/test/transaction.cpp index b51494d84..9f9429534 100644 --- a/test/transaction.cpp +++ b/test/transaction.cpp @@ -64,7 +64,7 @@ RLPStream createRLPStreamFromTransactionFields(mObject& _tObj) rlpStream << bigint(_tObj["r"].get_str()); if (_tObj.count("s") > 0) - rlpStream << bigint(_tObj["s"].get_str()); + rlpStream << bigint(_tObj["s"].get_str()); if (_tObj.count("extrafield") > 0) rlpStream << bigint(_tObj["extrafield"].get_str()); @@ -82,18 +82,18 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin) if (_fillin == false) { BOOST_REQUIRE(o.count("rlp") > 0); - bytes rlpReaded = importByteArray(o["rlp"].get_str()); Transaction txFromRlp; - try { - txFromRlp = Transaction(rlpReaded, CheckSignature::Sender); + bytes stream = importByteArray(o["rlp"].get_str()); + RLP rlp(stream); + txFromRlp = Transaction(rlp.data(), CheckSignature::Sender); if (!txFromRlp.signature().isValid()) BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("transaction from RLP signature is invalid") ); } catch(...) { - BOOST_CHECK_MESSAGE(o.count("transaction") == 0, "A transction object should not be defined because the RLP is invalid!"); + BOOST_CHECK_MESSAGE(o.count("transaction") == 0, "A transaction object should not be defined because the RLP is invalid!"); return; } @@ -115,6 +115,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin) Address addressReaded = Address(o["sender"].get_str()); BOOST_CHECK_MESSAGE(txFromFields.sender() == addressReaded || txFromRlp.sender() == addressReaded, "Signature address of sender does not match given sender address!"); + } else {