Skip to content

Commit

Permalink
Merge branch 'KomodoPlatform:dev' into initial_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Weblet-dex authored Aug 17, 2023
2 parents 0067253 + beaa7ec commit 3bf6e69
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 34 deletions.
6 changes: 3 additions & 3 deletions ci_tools_atomic_dex/ci_scripts/linux_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

sudo apt-get update # prevents repo404 errors on apt-remove below
sudo apt-get remove php* msodbcsql17 mysql*
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get upgrade -y
#sudo apt-get update
#sudo ACCEPT_EULA=Y apt-get upgrade -y
# base deps
sudo apt-get install build-essential \
libgl1-mesa-dev \
Expand Down Expand Up @@ -54,7 +54,7 @@ sudo cp -r * /usr/local/
cmake --version

# get libwally
git clone https://github.com/KomodoPlatform/libwally-core.git
git clone https://github.com/KomodoPlatform/libwally-core.git --recurse-submodules
cd libwally-core
./tools/autogen.sh
./configure --disable-shared
Expand Down
2 changes: 1 addition & 1 deletion ci_tools_atomic_dex/ci_scripts/osx_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export MACOSX_DEPLOYMENT_TARGET=12.1
#make -j3 install
#cd ../

git clone https://github.com/KomodoPlatform/libwally-core.git
git clone https://github.com/KomodoPlatform/libwally-core.git --recurse-submodules
cd libwally-core
./tools/autogen.sh
./configure --disable-shared
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/komodo_prices/komodo.prices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace
{
constexpr const char* g_komodo_prices_endpoint = "https://prices.komodo.earth:1313";
constexpr const char* g_komodo_prices_endpoint = "https://prices.komodo.earth";
constexpr const char* g_komodo_prices_endpoint_fallback = "https://prices.cipig.net:1717";

web::http::client::http_client_config g_komodo_prices_cfg{[]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <optional>
#include <string>

#include <nlohmann/json_fwd.hpp> //> nlohmann::json
Expand Down
10 changes: 7 additions & 3 deletions src/core/atomicdex/services/mm2/mm2.service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ namespace atomic_dex

std::string status = z_answers[0].at("result").at("status").get<std::string>();
SPDLOG_DEBUG("{} status : {}", tickers[idx], status);
SPDLOG_DEBUG("{} activation status response [{}]", tickers[idx], z_answers[0].dump());
SPDLOG_DEBUG("{} Activation Status: {}", tickers[idx], z_answers[0].dump());

if (status == "Ok")
{
Expand All @@ -1510,6 +1510,11 @@ namespace atomic_dex
this->m_nb_update_required += 1;
break;
}
else if (status == "Error")
{
event = z_answers[0].at("result").at("details").at("error_data").at("error").get<std::string>();
break;
}
else
{
// todo(syl): many unused variables.
Expand Down Expand Up @@ -1553,8 +1558,7 @@ namespace atomic_dex
try {
if (z_error[0].at("result").at("details").contains("error"))
{
std::string zhtlc_error = z_error[0].at("result").at("details").at("error").get<std::string>();
SPDLOG_DEBUG("Error enabling {}: {} ", tickers[idx], zhtlc_error);
SPDLOG_DEBUG("Error enabling {}: {} ", tickers[idx], event);
SPDLOG_DEBUG(
"Removing zhtlc from enabling, idx: {}, tickers size: {}, answers size: {}",
tickers[idx], idx, tickers.size(), answers.size()
Expand Down
50 changes: 25 additions & 25 deletions src/tests/api/mm2/mm2.rpc.trade.preimage.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace
"numer":"1"
},
"amount_rat":[[1,[1]],[1,[10000]]],
"coin":"RICK"
"coin":"DOC"
},
"taker_fee": {
"coin": "MYCOIN1",
Expand All @@ -72,7 +72,7 @@ namespace
"numer":"1"
},
"amount_rat":[[1,[1]],[1,[10000]]],
"coin":"RICK"
"coin":"DOC"
}
}
)"_json;
Expand All @@ -95,7 +95,7 @@ namespace
"numer":"0"
},
"amount_rat":[[0,[]],[1,[1]]],
"coin":"RICK"
"coin":"DOC"
}
}
}
Expand All @@ -119,7 +119,7 @@ namespace
"numer":"1"
},
"amount_rat":[[1,[1]],[1,[10000]]],
"coin":"RICK"
"coin":"DOC"
},
"taker_fee": {
"amount":"0.0001",
Expand All @@ -128,7 +128,7 @@ namespace
"numer":"1"
},
"amount_rat":[[1,[1]],[1,[10000]]],
"coin":"RICK"
"coin":"DOC"
},
"fee_to_send_taker_fee":{
Expand All @@ -138,7 +138,7 @@ namespace
"numer":"1"
},
"amount_rat":[[1,[1]],[1,[10000]]],
"coin":"RICK"
"coin":"DOC"
}
}
}
Expand All @@ -162,7 +162,7 @@ namespace
"numer":"0"
},
"amount_rat":[[0,[]],[1,[1]]],
"coin":"RICK"
"coin":"DOC"
},
"volume":"2.21363478",
"volume_fraction":{
Expand All @@ -176,7 +176,7 @@ namespace
"numer":"0"
},
"amount_rat":[[0,[]],[1,[1]]],
"coin":"RICK"
"coin":"DOC"
},
"fee_to_send_taker_fee":{
"amount":"0.00033219",
Expand Down Expand Up @@ -209,23 +209,23 @@ namespace
"numer":"0"
},
"amount_rat":[[0,[]],[1,[1]]],
"coin":"RICK"
"coin":"DOC"
}
}
})"_json;
const nlohmann::json g_preimage_request_buy_rick_morty_real = R"(
const nlohmann::json g_preimage_request_buy_DOC_MARTY_real = R"(
{
"base": "RICK",
"base": "DOC",
"method": "trade_preimage",
"rel": "MORTY",
"rel": "MARTY",
"swap_method": "buy",
"userpass": "",
"volume": "1",
"price": "1"
})"_json;
const nlohmann::json g_preimage_request_buy_rick_nonexistent_real = R"(
const nlohmann::json g_preimage_request_buy_DOC_nonexistent_real = R"(
{
"base": "RICK",
"base": "DOC",
"method": "trade_preimage",
"rel": "NONEXISTENT",
"swap_method": "buy",
Expand Down Expand Up @@ -261,7 +261,7 @@ TEST_CASE("atomic_dex::mm2::preimage_answer_success deserialization from buy")

TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites")
{
TEST_CASE("setprice BTC/RICK")
TEST_CASE("setprice BTC/DOC")
{
atomic_dex::t_trade_preimage_answer answer;
atomic_dex::mm2::from_json(g_preimage_answer_setprice, answer);
Expand All @@ -270,7 +270,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites")
CHECK_FALSE(answer.result.value().fee_to_send_taker_fee.has_value());
}

TEST_CASE("buy BTC/RICK")
TEST_CASE("buy BTC/DOC")
{
atomic_dex::t_trade_preimage_answer answer;
atomic_dex::mm2::from_json(g_preimage_answer_buy, answer);
Expand All @@ -279,7 +279,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites")
CHECK(answer.result.value().fee_to_send_taker_fee.has_value());
}

TEST_CASE("sell max BTC/RICK")
TEST_CASE("sell max BTC/DOC")
{
atomic_dex::t_trade_preimage_answer answer;
atomic_dex::mm2::from_json(g_preimage_answer_sell_max, answer);
Expand All @@ -288,7 +288,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites")
CHECK(answer.result.value().fee_to_send_taker_fee.has_value());
}

TEST_CASE("setprice ERC20 BAT/RICK")
TEST_CASE("setprice ERC20 BAT/DOC")
{
atomic_dex::t_trade_preimage_answer answer;
atomic_dex::mm2::from_json(g_preimage_answer_setprice_erc, answer);
Expand Down Expand Up @@ -371,11 +371,11 @@ SCENARIO("atomic_dex::mm2::preimage scenario")
return atomic_dex::mm2::rpc_process_answer_batch<atomic_dex::t_trade_preimage_answer>(answers[0], "trade_preimage");
};

//! A test with RICK/MORTY
GIVEN("Preparing a simple buy request RICK/MORTY")
//! A test with DOC/MARTY
GIVEN("Preparing a simple buy request DOC/MARTY")
{
//! Request values
atomic_dex::t_trade_preimage_request request{.base_coin = "RICK", .rel_coin = "MORTY", .swap_method = "buy", .volume = "1", .price = "1"};
atomic_dex::t_trade_preimage_request request{.base_coin = "DOC", .rel_coin = "MARTY", .swap_method = "buy", .volume = "1", .price = "1"};

//! Transform request into json
atomic_dex::mm2::to_json(request_json, request);
Expand All @@ -386,7 +386,7 @@ SCENARIO("atomic_dex::mm2::preimage scenario")
//! Check request without userpass against a constants at the top of the file
auto copy_request = request_json;
copy_request["userpass"] = "";
CHECK_EQ(copy_request, g_preimage_request_buy_rick_morty_real);
CHECK_EQ(copy_request, g_preimage_request_buy_DOC_MARTY_real);

//! A Test Case
WHEN("I execute the request")
Expand All @@ -403,14 +403,14 @@ SCENARIO("atomic_dex::mm2::preimage scenario")
}

//! See above
GIVEN("Preparing a wrong request RICK/NONEXISTENT coin")
GIVEN("Preparing a wrong request DOC/NONEXISTENT coin")
{
atomic_dex::t_trade_preimage_request request{.base_coin = "RICK", .rel_coin = "NONEXISTENT", .swap_method = "buy", .volume = "1"};
atomic_dex::t_trade_preimage_request request{.base_coin = "DOC", .rel_coin = "NONEXISTENT", .swap_method = "buy", .volume = "1"};
atomic_dex::mm2::to_json(request_json, request);
batch.push_back(request_json);
auto copy_request = request_json;
copy_request["userpass"] = "";
CHECK_EQ(copy_request, g_preimage_request_buy_rick_nonexistent_real);
CHECK_EQ(copy_request, g_preimage_request_buy_DOC_nonexistent_real);
WHEN("I execute the request")
{
const atomic_dex::t_trade_preimage_answer answer = generic_resp_process();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/atomic.dex.tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct tests_context : public antara::gaming::world::app
private:
std::atomic_bool m_test_context_ready{false};
std::atomic_bool m_extra_coins_ready{false};
std::vector<std::string> m_extra_coins{"RICK", "MORTY"};
std::vector<std::string> m_extra_coins{"DOC", "MARTY"};

public:
void
Expand Down

0 comments on commit 3bf6e69

Please sign in to comment.