mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
More Transaction Tests
Some tests to check YP statements
This commit is contained in:
parent
ba257db2f3
commit
5d881b555d
@ -139,27 +139,35 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImportTest::importTransaction(json_spirit::mObject& _o)
|
void ImportTest::importTransaction(json_spirit::mObject& _o)
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(_o.count("nonce")> 0);
|
if (_o.count("secretKey")> 0)
|
||||||
BOOST_REQUIRE(_o.count("gasPrice") > 0);
|
{
|
||||||
BOOST_REQUIRE(_o.count("gasLimit") > 0);
|
BOOST_REQUIRE(_o.count("nonce")> 0);
|
||||||
BOOST_REQUIRE(_o.count("to") > 0);
|
BOOST_REQUIRE(_o.count("gasPrice") > 0);
|
||||||
BOOST_REQUIRE(_o.count("value") > 0);
|
BOOST_REQUIRE(_o.count("gasLimit") > 0);
|
||||||
BOOST_REQUIRE(_o.count("secretKey") > 0);
|
BOOST_REQUIRE(_o.count("to") > 0);
|
||||||
BOOST_REQUIRE(_o.count("data") > 0);
|
BOOST_REQUIRE(_o.count("value") > 0);
|
||||||
|
BOOST_REQUIRE(_o.count("data") > 0);
|
||||||
|
|
||||||
if (bigint(_o["nonce"].get_str()) >= c_max256plus1)
|
if (bigint(_o["nonce"].get_str()) >= c_max256plus1)
|
||||||
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") );
|
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") );
|
||||||
if (bigint(_o["gasPrice"].get_str()) >= c_max256plus1)
|
if (bigint(_o["gasPrice"].get_str()) >= c_max256plus1)
|
||||||
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") );
|
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") );
|
||||||
if (bigint(_o["gasLimit"].get_str()) >= c_max256plus1)
|
if (bigint(_o["gasLimit"].get_str()) >= c_max256plus1)
|
||||||
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") );
|
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") );
|
||||||
if (bigint(_o["value"].get_str()) >= c_max256plus1)
|
if (bigint(_o["value"].get_str()) >= c_max256plus1)
|
||||||
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") );
|
BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") );
|
||||||
|
|
||||||
m_transaction = _o["to"].get_str().empty() ?
|
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"]), 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()));
|
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)
|
void ImportTest::exportTest(bytes _output, State& _statePost)
|
||||||
|
@ -90,8 +90,9 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
|||||||
|
|
||||||
o["sender"] = toString(txFromFields.sender());
|
o["sender"] = toString(txFromFields.sender());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(Exception const& _e)
|
||||||
{
|
{
|
||||||
|
cnote << "Transaction Exception: " << diagnostic_information(_e);
|
||||||
o.erase(o.find("transaction"));
|
o.erase(o.find("transaction"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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" :
|
"transaction" :
|
||||||
{
|
{
|
||||||
"data" : "",
|
"data" : "",
|
||||||
@ -151,7 +166,52 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"TransactionWithSvalueOverflow" : {
|
||||||
|
"transaction" :
|
||||||
|
{
|
||||||
|
"data" : "",
|
||||||
|
"gasLimit" : "850",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"nonce" : "0",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "11",
|
||||||
|
"v" : "27",
|
||||||
|
"r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353",
|
||||||
|
"s" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"TransactionWithRvalueOverflow" : {
|
"TransactionWithRvalueOverflow" : {
|
||||||
|
"transaction" :
|
||||||
|
{
|
||||||
|
"data" : "",
|
||||||
|
"gasLimit" : "850",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"nonce" : "0",
|
||||||
|
"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" :
|
"transaction" :
|
||||||
{
|
{
|
||||||
"data" : "",
|
"data" : "",
|
||||||
@ -166,6 +226,51 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"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" : {
|
"TransactionWithNonceOverflow" : {
|
||||||
"transaction" :
|
"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" : {
|
"TransactionWithGasPriceOverflow" : {
|
||||||
"transaction" :
|
"transaction" :
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user