122 LOG_PRINT_L0(
"-----------------------STARTING TRANSACTIONS FLOW TEST-----------------------");
124 if(path_source_wallet.empty())
127 if(path_target_wallet.empty())
133 w1.
generate(working_folder +
"/" + path_source_wallet,
"");
134 w2.
generate(working_folder +
"/" + path_target_wallet,
"");
136 catch (
const std::exception& e)
138 LOG_ERROR(
"failed to generate wallet: " << e.what());
142 w1.
init(daemon_addr_a);
147 if(!w1.
refresh(
true, blocks_fetched, received_etn, ok))
149 LOG_ERROR(
"failed to refresh source wallet from " << daemon_addr_a );
153 w2.
init(daemon_addr_b);
163 bool r = http_client.set_server(daemon_addr_a, boost::none) &&
net_utils::invoke_http_json(
"/stop_mine", daemon1_req, daemon1_rsp, http_client, std::chrono::seconds(10));
169 daemon_req.threads_count = 9;
175 w1.
refresh(
true, blocks_fetched, received_etn, ok);
179 w1.
refresh(
true, blocks_fetched, received_etn, ok);
206 w1.
refresh(
true, blocks_fetched, received_etn, ok);
211 uint64_t transfer_size = amount_to_transfer/transactions_count;
216 size_t m_received_count;
220 std::unordered_map<crypto::hash, tx_test_entry> txs;
221 for(i = 0; i != transactions_count; i++)
223 uint64_t amount_to_tx = (amount_to_transfer - transfered_etn) > transfer_size ? transfer_size: (amount_to_transfer - transfered_etn);
227 LOG_PRINT_L0(
"not enough ETN, waiting for cashback or mining");
228 w1.
refresh(
true, blocks_fetched, received_etn, ok);
240 if(!
do_send_etn(w1, w2, mix_in_factor, amount_to_tx, tx))
243 w1.
refresh(
true, blocks_fetched, received_etn, ok);
244 if(!
do_send_etn(w1, w2, mix_in_factor, amount_to_tx, tx))
251 lst_sent_ki = boost::get<txin_to_key>(tx.
vin[0]).k_image;
253 transfered_etn += amount_to_tx;
255 LOG_PRINT_L0(
"transferred " << amount_to_tx <<
", i=" << i );
257 ent.amount_transfered = amount_to_tx;
267 bool recvd_etn =
false;
268 while(w2.
refresh(
true, blocks_fetched, recvd_etn, ok) && ( (blocks_fetched && recvd_etn) || !blocks_fetched ) )
274 if(etn_2 == transfered_etn)
276 MGINFO_GREEN(
"-----------------------FINISHING TRANSACTIONS FLOW TEST OK-----------------------");
285 auto it = txs.find(td.
m_txid);
287 it->second.m_received_count += 1;
290 BOOST_FOREACH(
auto& tx_pair, txs)
292 if(tx_pair.second.m_received_count != 1)
299 MERROR(
"-----------------------FINISHING TRANSACTIONS FLOW TEST FAILED-----------------------" );
300 MERROR(
"income " <<
print_etn(etn_2) <<
" via " << i <<
" transactions, expected ETN = " <<
print_etn(transfered_etn) );
#define LOCAL_ASSERT(expr)
std::string print_etn(uint64_t amount, unsigned int decimal_point)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
std::string get_public_address_str(network_type nettype) const
#define FIRST_N_TRANSFERS
#define CORE_RPC_STATUS_OK
std::vector< tx_out > vout
std::vector< txin_v > vin
mdb_size_t count(MDB_cursor *cur)
unsigned __int64 uint64_t
std::string generate_random_wallet_name()
crypto::hash get_transaction_hash(const transaction &t)
uint64_t get_etn_in_first_transfers(const tools::wallet2::transfer_container &incoming_transfers, size_t n_transfers)
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN
bool do_send_etn(tools::wallet2 &w1, tools::wallet2 &w2, size_t mix_in_factor, uint64_t amount_to_transfer, transaction &tx, size_t parts=1)