From b41d87a05159f58d61dfc12ec9eba376158a0fde Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 27 May 2021 13:19:20 +0200 Subject: [PATCH] fixed errors reporting for mobile wallet --- src/wallet/wallet_errors.h | 32 ++++++++++++------- tests/functional_tests/plain_wallet_tests.cpp | 13 ++++++-- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index efafaf97..c2636d70 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -385,14 +385,20 @@ namespace tools std::string to_string() const { std::ostringstream ss; - ss << transfer_error::to_string() << ", mixin_count = " << m_mixin_count << ", scanty_outs:"; - for (const auto& outs_for_amount : m_scanty_outs) - { - ss << '\n' << currency::print_money(outs_for_amount.amount) << " - " << outs_for_amount.outs.size(); - } + ss << API_RETURN_CODE_NOT_ENOUGH_OUTPUTS_FOR_MIXING; + //ss << transfer_error::to_string() << ", mixin_count = " << m_mixin_count << ", scanty_outs:"; + //for (const auto& outs_for_amount : m_scanty_outs) + //{ + // ss << '\n' << currency::print_money(outs_for_amount.amount) << " - " << outs_for_amount.outs.size(); + //} return ss.str(); } + virtual const char* what() const noexcept + { + return API_RETURN_CODE_NOT_ENOUGH_OUTPUTS_FOR_MIXING; + } + private: scanty_outs_t m_scanty_outs; size_t m_mixin_count; @@ -534,14 +540,18 @@ namespace tools std::string to_string() const { std::ostringstream ss; - currency::transaction tx = m_tx; - ss << transfer_error::to_string() << - ", tx_size_limit = " << m_tx_size_limit << - ", tx size = " << get_object_blobsize(m_tx) << - ", tx:\n" << currency::obj_to_json_str(tx); + ss << API_RETURN_CODE_TX_IS_TOO_BIG; + //currency::transaction tx = m_tx; + //ss << transfer_error::to_string() << + // ", tx_size_limit = " << m_tx_size_limit << + // ", tx size = " << get_object_blobsize(m_tx) << + // ", tx:\n" << currency::obj_to_json_str(tx); return ss.str(); } - + virtual const char* what() const noexcept + { + return API_RETURN_CODE_TX_IS_TOO_BIG; + } private: currency::transaction m_tx; uint64_t m_tx_size_limit; diff --git a/tests/functional_tests/plain_wallet_tests.cpp b/tests/functional_tests/plain_wallet_tests.cpp index f6efe29f..e92084fb 100644 --- a/tests/functional_tests/plain_wallet_tests.cpp +++ b/tests/functional_tests/plain_wallet_tests.cpp @@ -40,11 +40,18 @@ void run_plain_wallet_api_test() std::string res = plain_wallet::sync_call("get_seed_phrase_info", 0, "{\"seed_phrase\":\"aZxat4HAWriVQ3enkGcVsrZRdMseAJswG3CSEwTqZS246VsFQ53w26eZstYsu1jWE74Atz9ajLxFnBsVTafncWNH5SMv4zHFaTS:1780c4d5dd7e97cc4a75ea8baa7977d12ef948b9a6dddc2a9a37e5e22ac7180e:1599495055\"}"); - res = plain_wallet::restore("footstep knowledge fur capture honey minute carefully peaceful lovely crawl lunch government nightmare friendship myself sign possibly plan flower depression bread rainbow wrong hardly dark chest", - "test_wall2.zan", "111", ""); +// res = plain_wallet::restore("footstep knowledge fur capture honey minute carefully peaceful lovely crawl lunch government nightmare friendship myself sign possibly plan flower depression bread rainbow wrong hardly dark chest", +// "test_wall2.zan", "111", ""); + +// epee::misc_utils::sleep_no_w(30000); + +// plain_wallet::close_wallet(0); + res = plain_wallet::open("test_wall2.zan", "111"); - epee::misc_utils::sleep_no_w(10000000); + res = plain_wallet::invoke(0, "{\"method\":\"transfer\",\"params\":{\"destinations\":[{\"amount\":10000000000,\"address\":\"aZxat4HAWriVQ3enkGcVsrZRdMseAJswG3CSEwTqZS246VsFQ53w26eZstYsu1jWE74Atz9ajLxFnBsVTafncWNH5SMv4zHFaTS\"}],\"fee\":10000000000,\"mixin\":1011111,\"payment_id\":\"\",\"push_payer\":true,\"hide_receiver\":false}}"); + + //epee::misc_utils::sleep_no_w(10000000); //std::string key = plain_wallet::generate_random_key(10); //std::string test_data = "1234567890 test test ";