39 const u256 gasCost = 10 * szabo;
40 const u256 gas = 25000;
41 Address dest =
Address(
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87");
42 Address to =
Address(
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
43 Secret sec =
Secret(
"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8");
69 const u256 gasCostCheap = 10 * szabo;
70 const u256 gasCostMed = 20 * szabo;
71 const u256 gasCostHigh = 30 * szabo;
72 const u256 gas = 25000;
73 Address dest =
Address(
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87");
74 Secret sender1 =
Secret(
"0x3333333333333333333333333333333333333333333333333333333333333333");
75 Secret sender2 =
Secret(
"0x4444444444444444444444444444444444444444444444444444444444444444");
124 const u256 gasCostMed = 20 * szabo;
125 const u256 gas = 25000;
126 Address dest =
Address(
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87");
127 Secret sender =
Secret(
"0x3333333333333333333333333333333333333333333333333333333333333333");
153 const u256 gasCostMed = 20 * szabo;
154 const u256 gas = 25000;
155 Address dest =
Address(
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87");
156 Secret sender =
Secret(
"0x3333333333333333333333333333333333333333333333333333333333333333");
157 Secret sender2 =
Secret(
"0x4444444444444444444444444444444444444444444444444444444444444444");
182 TestTransaction testTransaction = TestTransaction::defaultTransaction();
185 BOOST_REQUIRE(known.size() == 0);
188 BOOST_REQUIRE(ir == ImportResult::Success);
190 BOOST_REQUIRE(known.size() == 1);
193 BOOST_REQUIRE(ir == ImportResult::AlreadyKnown);
198 BOOST_REQUIRE(ir == ImportResult::Malformed);
201 BOOST_REQUIRE(known.size() == 1);
203 TestTransaction testTransaction2 = TestTransaction::defaultTransaction(1, 2);
204 TestTransaction testTransaction3 = TestTransaction::defaultTransaction(1, 1);
205 TestTransaction testTransaction4 = TestTransaction::defaultTransaction(1, 4);
206 ir = tq.
import(testTransaction2.transaction().rlp());
208 BOOST_REQUIRE(ir == ImportResult::OverbidGasPrice);
211 BOOST_REQUIRE(known.size() == 1);
213 BOOST_REQUIRE(ts.size() == 1);
214 BOOST_REQUIRE(
Transaction(ts.at(0)).gasPrice() == 4);
219 BOOST_REQUIRE(ts.size() == 0);
220 BOOST_REQUIRE(tq.
waiting(from) == 1);
226 TestTransaction testTransaction = TestTransaction::defaultTransaction();
238 for (
size_t i = 1; i < 7; i++)
240 TestTransaction testTransaction = TestTransaction::defaultTransaction(i);
243 BOOST_REQUIRE(res == ImportResult::Success);
247 BOOST_REQUIRE(tq.
waiting(from) == 5);
250 BOOST_REQUIRE(topTr.size() == 5);
252 for (
int i = topTr.size() - 1; i >= 0 ; i--)
256 BOOST_REQUIRE(topTr.size() == 0);
258 TestTransaction testTransaction = TestTransaction::defaultTransaction(7);
259 BOOST_REQUIRE(tq.
waiting(from) == 5);
263 BOOST_REQUIRE(res == ImportResult::Success);
266 BOOST_REQUIRE(tq.
waiting(testTransaction.transaction().from()) == 4);
269 BOOST_REQUIRE(topTr.size() == 1);
275 TestTransaction testTransaction = TestTransaction::defaultTransaction();
283 RLP tRlp(rlpStream.
out());
286 Transaction tRlpTransaction(payloadToDecode, CheckTransaction::Cheap);
287 BOOST_REQUIRE(tRlpTransaction.data() == testTransaction.
transaction().
data());
290 string hashStr =
"01020304050607080910111213141516171819202122232425262728293031320102030405060708091011121314151617181920212223242526272829303132";
293 this_thread::sleep_for(chrono::seconds(1));
297 BOOST_REQUIRE(topTr.size() == 1);
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Address from() const
Synonym for safeSender().
A queue of Transactions, each stored as RLP.
void enqueue(RLP const &_data, h512 const &_nodeId)
Add transaction to the queue to be verified and imported.
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
bytes const & out() const
Read the byte stream.
h160 Address
An Ethereum address: 20 bytes.
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
void drop(h256 const &_txHash)
Remove transaction from the queue.
SecureFixedHash< 32 > Secret
std::hash for asio::adress
BOOST_AUTO_TEST_CASE(tqMaxNonce)
bytes rlp(IncludeSignature _sig=WithSignature) const
Transactions topTransactions(unsigned _limit, h256Hash const &_avoid=h256Hash()) const
Get top transactions from the queue.
std::vector< byte > bytes
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
bytes const & data() const
h256 sha3(IncludeSignature _sig=WithSignature) const
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
ImportResult import(bytes const &_tx, IfDropped _ik=IfDropped::Ignore)
Verify and add transaction to the queue synchronously.
Encodes a transaction, ready to be exported to or freshly imported from RLP.
void setFuture(h256 const &_t)
Mark transaction as future.
void dropGood(Transaction const &_t)
Drop a trasnaction from the list if exists and move following future trasnactions to current (if any)...
#define BOOST_FIXTURE_TEST_SUITE(a, b)
u256 maxNonce(Address const &_a) const
Get max nonce for an account.
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
#define BOOST_AUTO_TEST_SUITE_END()
std::unordered_set< h256 > h256Hash
Transaction const & transaction() const
Class for writing to an RLP bytestream.
RLPStream & appendRaw(bytesConstRef _rlp, size_t _itemCount=1)
Appends raw (pre-serialised) RLP data. Use with caution.
h256Hash knownTransactions() const
Get a hash set of transactions in the queue.
unsigned waiting(Address const &_a) const
Get number of pending transactions for account.
Class for interpreting Recursive Linear-Prefix Data.
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)