From 7d3c0f30853d9403cae5f08e8c47917dc506bb9d Mon Sep 17 00:00:00 2001 From: allerria Date: Tue, 19 Jan 2021 17:56:54 +0300 Subject: [PATCH] add extract_game_params method --- tests/casino_test.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/casino_test.cpp b/tests/casino_test.cpp index a5035c3..dfdddee 100644 --- a/tests/casino_test.cpp +++ b/tests/casino_test.cpp @@ -182,6 +182,14 @@ class casino_tester : public basic_tester { throw std::runtime_error("symbol not found"); } + game_params_type extract_game_params(const fc::variant& data) { + game_params_type params = {}; + for (auto& pair: data.as>()) { + params.push_back({pair["first"].as(), pair["second"].as()}); + } + return params; + } + game_params_type get_game_params(uint64_t game_id, const std::string& token = "BET") { game_params_type params = {}; vector data = get_row_by_account(casino_account, casino_account, N(gameparams), game_id); @@ -192,10 +200,7 @@ class casino_tester : public basic_tester { const auto token_raw = get_token_pk(token); for (auto& it : params_raw.as>()) { if (it["key"].as() == token_raw) { - for (auto& pair: it["value"].as>()) { - params.push_back({pair["first"].as(), pair["second"].as()}); - } - return params; + return extract_game_params(it["value"]); } } return params;