121{
122 LOG_PRINT_L0(
"-----------------------STARTING TRANSACTIONS FLOW TEST-----------------------");
124 if(path_source_wallet.empty())
126
127 if(path_target_wallet.empty())
129
130
131 try
132 {
133 w1.
generate(working_folder +
"/" + path_source_wallet,
"");
134 w2.
generate(working_folder +
"/" + path_target_wallet,
"");
135 }
136 catch (const std::exception& e)
137 {
138 LOG_ERROR(
"failed to generate wallet: " << e.what());
139 return false;
140 }
141
142 w1.
init(daemon_addr_a);
143
145 bool received_etn;
146 bool ok;
147 if(!w1.
refresh(
true, blocks_fetched, received_etn, ok))
148 {
149 LOG_ERROR(
"failed to refresh source wallet from " << daemon_addr_a );
150 return false;
151 }
152
153 w2.
init(daemon_addr_b);
154
158
159
165
169 daemon_req.threads_count = 9;
173
174
175 w1.
refresh(
true, blocks_fetched, received_etn, ok);
177 {
179 w1.
refresh(
true, blocks_fetched, received_etn, ok);
180 }
181
182
183
184
185 while(true)
186 {
190 {
191
194 {
200 break;
201 }
202 break;
203 }else
204 {
206 w1.
refresh(
true, blocks_fetched, received_etn, ok);
207 }
208 }
209
211 uint64_t transfer_size = amount_to_transfer/transactions_count;
212 size_t i = 0;
213 struct tx_test_entry
214 {
215 transaction tx;
216 size_t m_received_count;
218 };
220 std::unordered_map<crypto::hash, tx_test_entry> txs;
221 for(i = 0; i != transactions_count; i++)
222 {
223 uint64_t amount_to_tx = (amount_to_transfer - transfered_etn) > transfer_size ? transfer_size: (amount_to_transfer - transfered_etn);
225 {
226 misc_utils::sleep_no_w(1000);
227 LOG_PRINT_L0("not enough ETN, waiting for cashback or mining");
228 w1.refresh(true, blocks_fetched, received_etn, ok);
229 }
230
232
233
234
235
236
237
238
239
240 if(!
do_send_etn(w1, w2, mix_in_factor, amount_to_tx, tx))
241 {
243 w1.
refresh(
true, blocks_fetched, received_etn, ok);
244 if(!
do_send_etn(w1, w2, mix_in_factor, amount_to_tx, tx))
245 {
248 return false;
249 }
250 }
251 lst_sent_ki = boost::get<txin_to_key>(tx.vin[0]).k_image;
252
253 transfered_etn += amount_to_tx;
254
255 LOG_PRINT_L0(
"transferred " << amount_to_tx <<
", i=" << i );
257 ent.amount_transfered = amount_to_tx;
258 ent.tx = tx;
259
260
261 }
262
263
267 bool recvd_etn = false;
268 while(w2.
refresh(
true, blocks_fetched, recvd_etn, ok) && ( (blocks_fetched && recvd_etn) || !blocks_fetched ) )
269 {
271 }
272
274 if(etn_2 == transfered_etn)
275 {
276 MGINFO_GREEN(
"-----------------------FINISHING TRANSACTIONS FLOW TEST OK-----------------------");
278 return true;
279 }else
280 {
284 {
285 auto it = txs.find(td.
m_txid);
287 it->second.m_received_count += 1;
288 }
289
290 BOOST_FOREACH(auto& tx_pair, txs)
291 {
292 if(tx_pair.second.m_received_count != 1)
293 {
295 }
296
297 }
298
299 MERROR(
"-----------------------FINISHING TRANSACTIONS FLOW TEST FAILED-----------------------" );
300 MERROR(
"income " <<
print_etn(etn_2) <<
" via " << i <<
" transactions, expected ETN = " <<
print_etn(transfered_etn) );
302 return false;
303 }
304
305 return true;
306}
std::string get_public_address_str(network_type nettype) const
bool set_server(const std::string &address, boost::optional< login > user, ssl_options_t ssl_options=ssl_support_t::e_ssl_support_autodetect)
#define CORE_RPC_STATUS_OK
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN
#define LOCAL_ASSERT(expr)
crypto::hash get_transaction_hash(const transaction &t)
std::string print_etn(uint64_t amount, unsigned int decimal_point)
http_simple_client_template< blocked_mode_client > http_simple_client
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")
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< request_t > request
#define FIRST_N_TRANSFERS
std::string generate_random_wallet_name()
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)
uint64_t get_etn_in_first_transfers(const tools::wallet2::transfer_container &incoming_transfers, size_t n_transfers)