MCPcopy Create free account
hub / github.com/LUX-Core/lux / importTransaction

Method importTransaction

src/cpp-ethereum/test/libtesteth/ImportTest.cpp:268–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void ImportTest::importTransaction (json_spirit::mObject const& _o, eth::Transaction& o_tr)
269{
270 if (_o.count("secretKey") > 0)
271 {
272 BOOST_REQUIRE(_o.count("nonce") > 0);
273 BOOST_REQUIRE(_o.count("gasPrice") > 0);
274 BOOST_REQUIRE(_o.count("gasLimit") > 0);
275 BOOST_REQUIRE(_o.count("to") > 0);
276 BOOST_REQUIRE(_o.count("value") > 0);
277 BOOST_REQUIRE(_o.count("data") > 0);
278
279 if (bigint(_o.at("nonce").get_str()) >= c_max256plus1)
280 BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'nonce' is equal or greater than 2**256") );
281 if (bigint(_o.at("gasPrice").get_str()) >= c_max256plus1)
282 BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasPrice' is equal or greater than 2**256") );
283 if (bigint(_o.at("gasLimit").get_str()) >= c_max256plus1)
284 BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'gasLimit' is equal or greater than 2**256") );
285 if (bigint(_o.at("value").get_str()) >= c_max256plus1)
286 BOOST_THROW_EXCEPTION(ValueTooLarge() << errinfo_comment("Transaction 'value' is equal or greater than 2**256") );
287
288 o_tr = _o.at("to").get_str().empty() ?
289 Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), importData(_o), toInt(_o.at("nonce")), Secret(_o.at("secretKey").get_str())) :
290 Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), Address(_o.at("to").get_str()), importData(_o), toInt(_o.at("nonce")), Secret(_o.at("secretKey").get_str()));
291 }
292 else
293 {
294 BOOST_REQUIRE(_o.count("nonce"));
295 BOOST_REQUIRE(_o.count("gasPrice"));
296 BOOST_REQUIRE(_o.count("gasLimit"));
297 BOOST_REQUIRE(_o.count("to"));
298 BOOST_REQUIRE(_o.count("value"));
299 BOOST_REQUIRE(_o.count("data"));
300 BOOST_REQUIRE(_o.count("v"));
301 BOOST_REQUIRE(_o.count("r"));
302 BOOST_REQUIRE(_o.count("s"));
303
304 RLPStream transactionRLPStream = createRLPStreamFromTransactionFields(_o);
305 RLP transactionRLP(transactionRLPStream.out());
306 try
307 {
308 o_tr = Transaction(transactionRLP.data(), CheckTransaction::Everything);
309 }
310 catch (InvalidSignature)
311 {
312 // create unsigned transaction
313 o_tr = _o.at("to").get_str().empty() ?
314 Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), importData(_o), toInt(_o.at("nonce"))) :
315 Transaction(toInt(_o.at("value")), toInt(_o.at("gasPrice")), toInt(_o.at("gasLimit")), Address(_o.at("to").get_str()), importData(_o), toInt(_o.at("nonce")));
316 }
317 catch (Exception& _e)
318 {
319 cnote << "invalid transaction" << boost::diagnostic_information(_e);
320 }
321 }
322}
323
324void ImportTest::importTransaction(json_spirit::mObject const& o_tr)
325{

Callers

nothing calls this directly

Calls 12

ValueTooLargeClass · 0.85
toIntFunction · 0.85
importDataFunction · 0.85
get_strMethod · 0.80
TransactionClass · 0.50
countMethod · 0.45
atMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected