Skip to content

Commit

Permalink
add extract_game_params method
Browse files Browse the repository at this point in the history
  • Loading branch information
alrxy committed Jan 19, 2021
1 parent 7c6ee1f commit 7d3c0f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/casino_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vector<fc::variant>>()) {
params.push_back({pair["first"].as<uint16_t>(), pair["second"].as<uint64_t>()});
}
return params;
}

game_params_type get_game_params(uint64_t game_id, const std::string& token = "BET") {
game_params_type params = {};
vector<char> data = get_row_by_account(casino_account, casino_account, N(gameparams), game_id);
Expand All @@ -192,10 +200,7 @@ class casino_tester : public basic_tester {
const auto token_raw = get_token_pk(token);
for (auto& it : params_raw.as<vector<fc::variant>>()) {
if (it["key"].as<uint64_t>() == token_raw) {
for (auto& pair: it["value"].as<vector<fc::variant>>()) {
params.push_back({pair["first"].as<uint16_t>(), pair["second"].as<uint64_t>()});
}
return params;
return extract_game_params(it["value"]);
}
}
return params;
Expand Down

0 comments on commit 7d3c0f3

Please sign in to comment.