Skip to content

Commit

Permalink
Merge pull request #67 from DaoCasino/dpm-1002
Browse files Browse the repository at this point in the history
[DPM-1002] ban check on transfer
  • Loading branch information
alrxy authored Feb 3, 2021
2 parents 11be0b6 + 93164be commit 21a6055
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
36 changes: 36 additions & 0 deletions examples/win_raise_lose/tests/win_raise_lose_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,42 @@ BOOST_FIXTURE_TEST_CASE(game_params_test, win_raise_lose_tester) try {
}
FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE(ban_test, win_raise_lose_tester) try {
const name player_name = N(player);

create_player(player_name);
link_game(player_name, game_name);

transfer(N(eosio), player_name, ASSET("15.00000 KEK"));
transfer(N(eosio), casino_name, ASSET("1000.00000 KEK"));

BOOST_REQUIRE_EQUAL(
success(),
transfer(player_name, game_name, ASSET("5.00000 KEK"), "0")
);

BOOST_REQUIRE_EQUAL(
success(),
push_action(platform_name, N(banplayer), platform_name, mvo()("player", player_name))
);

BOOST_REQUIRE_EQUAL(
wasm_assert_msg("player is banned"),
transfer(player_name, game_name, ASSET("5.00000 KEK"), "1")
);

BOOST_REQUIRE_EQUAL(
success(),
push_action(platform_name, N(unbanplayer), platform_name, mvo()("player", player_name))
);

BOOST_REQUIRE_EQUAL(
success(),
transfer(player_name, game_name, ASSET("5.00000 KEK"), "2")
);
}
FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_SUITE_END()

} // namespace testing
8 changes: 8 additions & 0 deletions sdk/include/game-contract-sdk/game_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ class game : public eosio::contract {
return;
}

check_player_not_banned(from);

// token verifying
eosio::check(get_token_contract(quantity) == get_first_receiver(), "transfer from incorrect contract");
const auto& token = quantity.symbol.code().to_string();
Expand Down Expand Up @@ -875,6 +877,12 @@ class game : public eosio::contract {
eosio::check(!it->paused, "token is paused");
}

void check_player_not_banned(const name player) const {
const auto platform = get_platform();
platform::ban_list_table ban_list(platform, platform.value);
eosio::check(ban_list.find(player.value) == ban_list.end(), "player is banned");
}

#ifdef IS_DEBUG
public:
/* debug table */
Expand Down
2 changes: 1 addition & 1 deletion tester/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)

set(DAOBET_CONTRACTS_VERSION "v1.0.7")
set(PLATFORM_CONTRACTS_VERSION "v1.2.1")
set(PLATFORM_CONTRACTS_VERSION "v1.2.2")

find_package(eosio)

Expand Down

0 comments on commit 21a6055

Please sign in to comment.