forked from townforge/townforge
unit_tests: fix warnings and remove obsolete code
This commit is contained in:
parent
2fb9183518
commit
163f2864a9
@ -1034,6 +1034,7 @@ TEST(cc_command, rename)
|
||||
{
|
||||
cryptonote::cc_command_rename_t cmd;
|
||||
cmd.flag = 1;
|
||||
cmd.name_cutoff = 0;
|
||||
uint64_t cc_in = (uint64_t)-1, cc_out = (uint64_t)-1;
|
||||
cc::get_cc_command_in_out(cmd, cc_in, cc_out);
|
||||
ASSERT_EQ(cc_in, 0);
|
||||
@ -1146,7 +1147,7 @@ static void test_commands(bool good, const std::vector<cryptonote::cc_command_t>
|
||||
{
|
||||
cryptonote::tx_verification_context tvc{};
|
||||
const cryptonote::cc_command_base_t *base = cryptonote::get_cc_command_base(s);
|
||||
uint64_t balance, cost = cc::get_cc_command_cost(s);
|
||||
uint64_t balance = 0, cost = cc::get_cc_command_cost(s);
|
||||
bool r0 = (base && base->cc_account) ? db->get_cc_account_balance(base->cc_account, balance) : true;
|
||||
bool r1 = r0 && cost <= balance;
|
||||
bool r2 = r1 && cc::check_cc_command(*db, s, version, tvc);
|
||||
@ -1158,7 +1159,7 @@ static void test_commands(bool good, const std::vector<cryptonote::cc_command_t>
|
||||
|
||||
cryptonote::tx_verification_context tvc{};
|
||||
const cryptonote::cc_command_base_t *base = cryptonote::get_cc_command_base(cmd);
|
||||
uint64_t balance, cost = cc::get_cc_command_cost(cmd);
|
||||
uint64_t balance = 0, cost = cc::get_cc_command_cost(cmd);
|
||||
bool r0 = (base && base->cc_account) ? db->get_cc_account_balance(base->cc_account, balance) : true;
|
||||
bool r1 = r0 && cost <= balance;
|
||||
bool r2 = r1 && cc::check_cc_command(*db, cmd, version, tvc);
|
||||
@ -2649,44 +2650,6 @@ TEST(cc_magica, 12x36x19_4x8x2_1x1x2)
|
||||
ASSERT_EQ(*i++, m2);
|
||||
}
|
||||
|
||||
static void test_game_command(TestDB *db, bool good, const cryptonote::cc_command_game_update_t &cmd, const char *label)
|
||||
{
|
||||
std::unique_ptr<cryptonote::Blockchain> bc;
|
||||
cryptonote::tx_memory_pool txpool(*bc);
|
||||
bc.reset(new cryptonote::Blockchain(txpool));
|
||||
struct get_test_options {
|
||||
const std::pair<uint8_t, uint64_t> hard_forks[2];
|
||||
const cryptonote::test_options test_options = {
|
||||
hard_forks,
|
||||
0,
|
||||
};
|
||||
get_test_options(): hard_forks{std::make_pair((uint8_t)BASE_TEST_FORK, (uint64_t)0), std::make_pair((uint8_t)0, (uint64_t)0)} {}
|
||||
} opts;
|
||||
cryptonote::Blockchain *blockchain = bc.get();
|
||||
ASSERT_TRUE(blockchain != NULL) << label;
|
||||
bool r = blockchain->init(db, cryptonote::FAKECHAIN, true, &opts.test_options, 0, NULL);
|
||||
ASSERT_TRUE(r) << label;
|
||||
|
||||
uint64_t cost = cc::get_cc_command_cost(cmd);
|
||||
ASSERT_EQ(cost, 0);
|
||||
const uint8_t version = bc->get_current_hard_fork_version();
|
||||
cryptonote::tx_verification_context tvc{};
|
||||
r = cc::check_cc_command(*db, cmd, version, tvc);
|
||||
ASSERT_EQ(r, good) << label;
|
||||
|
||||
if (good)
|
||||
{
|
||||
const TestDB::state_t s0 = db->get_state();
|
||||
cc::game_events_t events;
|
||||
r = cc::execute_cc_command(*db, cmd, version, 0, events);
|
||||
ASSERT_TRUE(r) << label;
|
||||
r = cc::revert_cc_command(*db, cmd, version);
|
||||
ASSERT_TRUE(r) << label;
|
||||
const TestDB::state_t s1 = db->get_state();
|
||||
ASSERT_EQ(s0, s1) << label;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(cc_game, empty)
|
||||
{
|
||||
cryptonote::cc_command_game_update_t cmd;
|
||||
|
Loading…
Reference in New Issue
Block a user