From d0bad4213ae8c8deabd0c18e3acc8d6abcd5367c Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 25 May 2024 01:11:01 +0400 Subject: [PATCH] fixed bug in rpc asset deploy function --- src/wallet/wallet_rpc_server.cpp | 2 +- tests/performance_tests/main.cpp | 42 +++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 10d2a399..e9f769f9 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1246,7 +1246,7 @@ namespace tools std::string embedded_payment_id; //check if address looks like wrapped address WLT_THROW_IF_FALSE_WITH_CODE(!currency::is_address_like_wrapped(it->address), "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); - WLT_THROW_IF_FALSE_WITH_CODE(!w.get_wallet()->get_transfer_address(it->address, de.addr.back(), embedded_payment_id), "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); + WLT_THROW_IF_FALSE_WITH_CODE(w.get_wallet()->get_transfer_address(it->address, de.addr.back(), embedded_payment_id), "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); WLT_THROW_IF_FALSE_WITH_CODE(embedded_payment_id.size() == 0, "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); de.amount = it->amount; de.asset_id = it->asset_id; diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 58fbd85f..1055bfca 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -34,8 +34,8 @@ POP_VS_WARNINGS void test_plain_wallet() { - //std::string res = plain_wallet::init("195.201.107.230", "33336", "E:\\tmp\\", 0); - std::string res = plain_wallet::init("127.0.0.1", "12111", "C:\\Users\\roky\\home22\\", 0); + std::string res = plain_wallet::init("195.201.107.230", "33340", "C:\\Users\\roky\\home\\", 0); + //std::string res = plain_wallet::init("127.0.0.1", "12111", "C:\\Users\\roky\\home22\\", 0); std::string res___ = plain_wallet::get_wallet_files(); @@ -60,21 +60,45 @@ void test_plain_wallet() std::string invoke_body = "{\"method\":\"store\",\"params\":{}}"; std::string res1 = plain_wallet::sync_call("invoke", instance_id, invoke_body); - invoke_body = "{\"method\":\"get_recent_txs_and_info\",\"params\":{\"offset\":0,\"count\":30,\"update_provision_info\":true}}"; - std::string res2 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + { + invoke_body = "{\"method\":\"getbalance\",\"params\":{}}"; + std::string res3 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + invoke_body = ""; + } - invoke_body = "{\"method\":\"get_recent_txs_and_info2\",\"params\":{\"offset\":0,\"count\":30,\"update_provision_info\":true}}"; - res2 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + { + invoke_body = "{\"method\":\"assets_whitelist_get\",\"params\":{}}"; + std::string res3 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + invoke_body = ""; + } + + + + { + //invoke_body = "{\"method\":\"assets_whitelist_get\",\"params\":{}}"; + //std::string json_request; + bool r = epee::file_io_utils::load_file_to_string("C:\\Users\\roky\\home\\wallets\\deploy_asset_request.json", invoke_body); + CHECK_AND_ASSERT_MES(r, void(), "wrong bla bla bla"); + std::string res3 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + invoke_body = ""; + } + + + //invoke_body = "{\"method\":\"get_recent_txs_and_info\",\"params\":{\"offset\":0,\"count\":30,\"update_provision_info\":true}}"; + //std::string res2 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + + //invoke_body = "{\"method\":\"get_recent_txs_and_info2\",\"params\":{\"offset\":0,\"count\":30,\"update_provision_info\":true}}"; + //res2 = plain_wallet::sync_call("invoke", instance_id, invoke_body); invoke_body = "{\"method\":\"getbalance\",\"params\":{}}"; std::string res3 = plain_wallet::sync_call("invoke", instance_id, invoke_body); - invoke_body = "{\r\n \"method\": \"transfer\",\r\n \"params\": {\r\n \"destinations\": [\r\n {\r\n \"amount\": \"1000000000000\",\r\n \"address\": \"ZxD9oVwGwW6ULix9Pqttnr7JDpaoLvDVA1KJ9eA9KRxPMRZT5X7WwtU94XH1Z6q6XTMxNbHmbV2xfZ429XxV6fST2DxEg4BQV\",\r\n \"asset_id\": \"cc4e69455e63f4a581257382191de6856c2156630b3fba0db4bdd73ffcfb36b6\"\r\n }\r\n ],\r\n \"fee\": 10000000000,\r\n \"mixin\": 10,\r\n \"payment_id\": \"\",\r\n \"comment\": \"\",\r\n \"push_payer\": false,\r\n \"hide_receiver\": true\r\n }\r\n}"; - std::string res4 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + //invoke_body = "{\r\n \"method\": \"transfer\",\r\n \"params\": {\r\n \"destinations\": [\r\n {\r\n \"amount\": \"1000000000000\",\r\n \"address\": \"ZxD9oVwGwW6ULix9Pqttnr7JDpaoLvDVA1KJ9eA9KRxPMRZT5X7WwtU94XH1Z6q6XTMxNbHmbV2xfZ429XxV6fST2DxEg4BQV\",\r\n \"asset_id\": \"cc4e69455e63f4a581257382191de6856c2156630b3fba0db4bdd73ffcfb36b6\"\r\n }\r\n ],\r\n \"fee\": 10000000000,\r\n \"mixin\": 10,\r\n \"payment_id\": \"\",\r\n \"comment\": \"\",\r\n \"push_payer\": false,\r\n \"hide_receiver\": true\r\n }\r\n}"; + //std::string res4 = plain_wallet::sync_call("invoke", instance_id, invoke_body); - LOG_PRINT_L0(res); + //LOG_PRINT_L0(res); }