mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
transaction tests, bound tests
This commit is contained in:
parent
7bf407dbe4
commit
0f7b1b3344
@ -414,4 +414,97 @@
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionNonceCheck" : {
|
||||
"env" : {
|
||||
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"pre" :
|
||||
{
|
||||
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||
"balance" : "100000",
|
||||
"code" : "",
|
||||
"nonce" : "10",
|
||||
"storage" : {
|
||||
}
|
||||
}
|
||||
},
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "1000",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"value" : "10"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionNonceCheck2" : {
|
||||
"env" : {
|
||||
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"pre" :
|
||||
{
|
||||
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||
"balance" : "100000",
|
||||
"code" : "",
|
||||
"nonce" : "0",
|
||||
"storage" : {
|
||||
}
|
||||
}
|
||||
},
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "1000",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "10",
|
||||
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"value" : "10"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionCosts555" : {
|
||||
"env" : {
|
||||
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"pre" :
|
||||
{
|
||||
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||
"balance" : "100000",
|
||||
"code" : "",
|
||||
"nonce" : "0",
|
||||
"storage" : {
|
||||
}
|
||||
}
|
||||
},
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "0x00000000000000000000112233445566778f32",
|
||||
"gasLimit" : "1000",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"value" : "0"
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
@ -16,19 +16,10 @@
|
||||
*/
|
||||
/** @file transaction.cpp
|
||||
* @author Dmitrii Khokhlov <winsvega@mail.ru>
|
||||
* @date 2014
|
||||
* @date 2015
|
||||
* Transaaction test functions.
|
||||
*/
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "JsonSpiritHeaders.h"
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libethereum/BlockChain.h>
|
||||
#include <libethereum/State.h>
|
||||
#include <libethereum/ExtVM.h>
|
||||
#include <libethereum/Defaults.h>
|
||||
#include <libevm/VM.h>
|
||||
#include "TestHelper.h"
|
||||
|
||||
using namespace std;
|
||||
@ -55,16 +46,15 @@ Transaction createTransactionFromFields(mObject& _tObj)
|
||||
//Construct Rlp of the given transaction
|
||||
RLPStream rlpStream;
|
||||
rlpStream.appendList(9);
|
||||
rlpStream << toInt(_tObj["nonce"]) << toInt(_tObj["gasPrice"]) << toInt(_tObj["gasLimit"]);
|
||||
rlpStream << bigint(_tObj["nonce"].get_str()) << bigint(_tObj["gasPrice"].get_str()) << bigint(_tObj["gasLimit"].get_str());
|
||||
if (_tObj["to"].get_str().empty())
|
||||
rlpStream << "";
|
||||
else
|
||||
rlpStream << Address(_tObj["to"].get_str());
|
||||
rlpStream << toInt(_tObj["value"]) << importData(_tObj);
|
||||
|
||||
rlpStream << bigint(_tObj["value"].get_str()) << importData(_tObj);
|
||||
u256 r = h256(fromHex(_tObj["r"].get_str()));
|
||||
u256 s = h256(fromHex(_tObj["s"].get_str()));
|
||||
rlpStream << toInt(_tObj["v"]) << r << s;
|
||||
rlpStream << bigint(_tObj["v"].get_str()) << r << s;
|
||||
|
||||
return Transaction(rlpStream.out(), true);
|
||||
}
|
||||
@ -124,13 +114,13 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
||||
rlpStream.appendList(tObj.size());
|
||||
|
||||
if(tObj.count("nonce") > 0)
|
||||
rlpStream << toInt(tObj["nonce"]);
|
||||
rlpStream << bigint(tObj["nonce"].get_str());
|
||||
|
||||
if(tObj.count("gasPrice") > 0)
|
||||
rlpStream << toInt(tObj["gasPrice"]);
|
||||
rlpStream << bigint(tObj["gasPrice"].get_str());
|
||||
|
||||
if(tObj.count("gasLimit") > 0)
|
||||
rlpStream << toInt(tObj["gasLimit"]);
|
||||
rlpStream << bigint(tObj["gasLimit"].get_str());
|
||||
|
||||
if(tObj.count("to") > 0)
|
||||
{
|
||||
@ -141,14 +131,14 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
||||
}
|
||||
|
||||
if(tObj.count("value") > 0)
|
||||
rlpStream << toInt(tObj["value"]);
|
||||
rlpStream << bigint(tObj["value"].get_str());
|
||||
|
||||
|
||||
if(tObj.count("data") > 0)
|
||||
rlpStream << importData(tObj);
|
||||
|
||||
if(tObj.count("v") > 0)
|
||||
rlpStream << toInt(tObj["v"]);
|
||||
rlpStream << bigint(tObj["v"].get_str());
|
||||
|
||||
if(tObj.count("r") > 0)
|
||||
{
|
||||
@ -163,7 +153,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
||||
}
|
||||
|
||||
if(tObj.count("extrafield") > 0)
|
||||
rlpStream << toInt(tObj["extrafield"]);
|
||||
rlpStream << bigint(tObj["extrafield"].get_str());
|
||||
|
||||
o["rlp"] = "0x" + toHex(rlpStream.out());
|
||||
|
||||
@ -174,7 +164,6 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
||||
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("transaction from RLP signature is invalid") );
|
||||
|
||||
o["sender"] = toString(txFromFields.sender());
|
||||
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -194,6 +183,11 @@ BOOST_AUTO_TEST_CASE(ttFillerTest)
|
||||
dev::test::executeTests("ttTransactionTest", "/TransactionTests", dev::test::doTransactionTests);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ttDataStringTest)
|
||||
{
|
||||
dev::test::executeTests("tt10mbDataField", "/TransactionTests", dev::test::doTransactionTests);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ttCreateTest)
|
||||
{
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
|
17
tt10mbDataFieldFiller.json
Normal file
17
tt10mbDataFieldFiller.json
Normal file
File diff suppressed because one or more lines are too long
@ -2,10 +2,10 @@
|
||||
"RightVRSTest" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"data" : "0x5544",
|
||||
"gasLimit" : "2000",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"nonce" : "3",
|
||||
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"value" : "10",
|
||||
"v" : "28",
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
"WrongVRSTest" : {
|
||||
"WrongVRSTestVl27" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
@ -24,13 +24,13 @@
|
||||
"nonce" : "0",
|
||||
"to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
|
||||
"value" : "10",
|
||||
"v" : "1",
|
||||
"v" : "26",
|
||||
"r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a",
|
||||
"s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
|
||||
}
|
||||
},
|
||||
|
||||
"WrongVRSTestVl31" : {
|
||||
"WrongVRSTestVge31" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
@ -87,11 +87,27 @@
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithHihghValue" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "850",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"TransactionWithHihghValueOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
@ -104,5 +120,126 @@
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithSvalueOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "850",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithRvalueOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "850",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "0",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithNonceOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "850",
|
||||
"gasPrice" : "1",
|
||||
"nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639936",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithGasPriceOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "850",
|
||||
"gasPrice" : "115792089237316195423570985008687907853269984665640564039457584007913129639936",
|
||||
"nonce" : "0",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"TransactionWithGasLimitOverflow" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639936",
|
||||
"gasPrice" : "123",
|
||||
"nonce" : "0",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"RLPElementsWithZeros" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "0x0000011222333",
|
||||
"gasLimit" : "1000",
|
||||
"gasPrice" : "00123",
|
||||
"nonce" : "0054",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "00000011",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"RLPHexElementsWithStartingZeros" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "0x0000000012",
|
||||
"gasLimit" : "1000",
|
||||
"gasPrice" : "123",
|
||||
"nonce" : "54",
|
||||
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||
"value" : "11",
|
||||
"v" : "27",
|
||||
"r" : "0x0048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0x00efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
},
|
||||
|
||||
"EmptyTransaction" : {
|
||||
"transaction" :
|
||||
{
|
||||
"data" : "",
|
||||
"gasLimit" : "",
|
||||
"gasPrice" : "",
|
||||
"nonce" : "",
|
||||
"to" : "",
|
||||
"value" : "",
|
||||
"v" : "27",
|
||||
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||
"s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user