|
|
|
@ -283,7 +283,8 @@ TEST_F(MYSQL_TEST, UpdateAccount)
|
|
|
|
|
auto updated_account = acc;
|
|
|
|
|
|
|
|
|
|
updated_account.scanned_block_height = 555;
|
|
|
|
|
updated_account.scanned_block_timestamp = DateTime(static_cast<time_t>(5555555));
|
|
|
|
|
updated_account.scanned_block_timestamp
|
|
|
|
|
= DateTime(static_cast<time_t>(5555555));
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(xmr_accounts->update(acc, updated_account));
|
|
|
|
|
|
|
|
|
@ -308,7 +309,8 @@ TEST_F(MYSQL_TEST, InsertAndGetAccount)
|
|
|
|
|
uint64_t mock_current_blockchain_timestamp = 1529302789;
|
|
|
|
|
|
|
|
|
|
DateTime blk_timestamp_mysql_format
|
|
|
|
|
= mysqlpp::DateTime(static_cast<time_t>(mock_current_blockchain_timestamp));
|
|
|
|
|
= mysqlpp::DateTime(static_cast<time_t>(
|
|
|
|
|
mock_current_blockchain_timestamp));
|
|
|
|
|
|
|
|
|
|
// address to insert
|
|
|
|
|
string xmr_addr {"4AKNvHrLG6KKtKYRaSPWtSZSnAcaBZ2UzeJg7guFNFK46EN93FnBDS5eiFgxH87Sb7ZcSFxMyBhhgKBJiG5kKBBmCY5tbgw"};
|
|
|
|
@ -316,7 +318,8 @@ TEST_F(MYSQL_TEST, InsertAndGetAccount)
|
|
|
|
|
string view_key_hash {"cdd3ae89cbdae1d14b178c7e7c6ba380630556cb9892bd24eb61a9a517e478cd"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t expected_primary_id = xmr_accounts->get_next_primary_id(xmreg::XmrAccount());
|
|
|
|
|
uint64_t expected_primary_id
|
|
|
|
|
= xmr_accounts->get_next_primary_id(xmreg::XmrAccount());
|
|
|
|
|
|
|
|
|
|
xmreg::XmrAccount new_account(mysqlpp::null,
|
|
|
|
|
xmr_addr,
|
|
|
|
@ -569,7 +572,8 @@ TEST_F(MYSQL_TEST, DeleteNoNExistingTx)
|
|
|
|
|
{
|
|
|
|
|
uint64_t some_non_existing_tx_id = 7774748483;
|
|
|
|
|
|
|
|
|
|
uint64_t no_of_deleted_rows = xmr_accounts->delete_tx(some_non_existing_tx_id);
|
|
|
|
|
uint64_t no_of_deleted_rows
|
|
|
|
|
= xmr_accounts->delete_tx(some_non_existing_tx_id);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(no_of_deleted_rows, 0);
|
|
|
|
|
}
|
|
|
|
@ -587,7 +591,8 @@ TEST_F(MYSQL_TEST, MarkTxSpendableAndNonSpendable)
|
|
|
|
|
// this particular tx is marked as spendable in mysql
|
|
|
|
|
EXPECT_TRUE(static_cast<bool>(tx_data.spendable));
|
|
|
|
|
|
|
|
|
|
uint64_t no_of_changed_rows = xmr_accounts->mark_tx_nonspendable(tx_data.id.data);
|
|
|
|
|
uint64_t no_of_changed_rows
|
|
|
|
|
= xmr_accounts->mark_tx_nonspendable(tx_data.id.data);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(no_of_changed_rows, 1);
|
|
|
|
|
|
|
|
|
@ -742,7 +747,8 @@ TEST_F(MYSQL_TEST, InsertOneOutput)
|
|
|
|
|
|
|
|
|
|
mock_output_data.account_id = acc.id.data;
|
|
|
|
|
|
|
|
|
|
uint64_t expected_primary_id = xmr_accounts->get_next_primary_id(mock_output_data);
|
|
|
|
|
uint64_t expected_primary_id
|
|
|
|
|
= xmr_accounts->get_next_primary_id(mock_output_data);
|
|
|
|
|
uint64_t inserted_output_id = xmr_accounts->insert(mock_output_data);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(inserted_output_id, expected_primary_id);
|
|
|
|
@ -751,7 +757,8 @@ TEST_F(MYSQL_TEST, InsertOneOutput)
|
|
|
|
|
|
|
|
|
|
xmreg::XmrOutput out_data2;
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(xmr_accounts->select_by_primary_id(inserted_output_id, out_data2));
|
|
|
|
|
EXPECT_TRUE(xmr_accounts
|
|
|
|
|
->select_by_primary_id(inserted_output_id, out_data2));
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(out_data2.tx_id, mock_output_data.tx_id);
|
|
|
|
|
EXPECT_EQ(out_data2.out_pub_key, mock_output_data.out_pub_key);
|
|
|
|
@ -826,7 +833,8 @@ TEST_F(MYSQL_TEST, InsertSeverlOutputsAtOnce)
|
|
|
|
|
mock_outputs_data.back().account_id = acc.id.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t expected_primary_id = xmr_accounts->get_next_primary_id(xmreg::XmrOutput());
|
|
|
|
|
uint64_t expected_primary_id
|
|
|
|
|
= xmr_accounts->get_next_primary_id(xmreg::XmrOutput());
|
|
|
|
|
|
|
|
|
|
// first time insert should be fine
|
|
|
|
|
uint64_t no_inserted_rows = xmr_accounts->insert(mock_outputs_data);
|
|
|
|
@ -834,7 +842,8 @@ TEST_F(MYSQL_TEST, InsertSeverlOutputsAtOnce)
|
|
|
|
|
EXPECT_EQ(no_inserted_rows, mock_outputs_data.size());
|
|
|
|
|
|
|
|
|
|
// after inserting 10 rows, the expected ID should be before + 11
|
|
|
|
|
uint64_t expected_primary_id2 = xmr_accounts->get_next_primary_id(xmreg::XmrOutput());
|
|
|
|
|
uint64_t expected_primary_id2
|
|
|
|
|
= xmr_accounts->get_next_primary_id(xmreg::XmrOutput());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(expected_primary_id2, expected_primary_id + mock_outputs_data.size());
|
|
|
|
|
|
|
|
|
@ -957,7 +966,8 @@ TEST_F(MYSQL_TEST, InsertOneInput)
|
|
|
|
|
|
|
|
|
|
mock_input_data.account_id = acc.id.data;
|
|
|
|
|
|
|
|
|
|
uint64_t expected_primary_id = xmr_accounts->get_next_primary_id(mock_input_data);
|
|
|
|
|
uint64_t expected_primary_id
|
|
|
|
|
= xmr_accounts->get_next_primary_id(mock_input_data);
|
|
|
|
|
uint64_t inserted_id = xmr_accounts->insert(mock_input_data);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(expected_primary_id, inserted_id);
|
|
|
|
@ -991,7 +1001,8 @@ TEST_F(MYSQL_TEST, InsertSeverlInputsAtOnce)
|
|
|
|
|
mock_data.back().account_id = acc.id.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t expected_primary_id = xmr_accounts->get_next_primary_id(xmreg::XmrInput());
|
|
|
|
|
uint64_t expected_primary_id
|
|
|
|
|
= xmr_accounts->get_next_primary_id(xmreg::XmrInput());
|
|
|
|
|
|
|
|
|
|
// first time insert should be fine
|
|
|
|
|
uint64_t no_inserted_rows = xmr_accounts->insert(mock_data);
|
|
|
|
@ -999,7 +1010,8 @@ TEST_F(MYSQL_TEST, InsertSeverlInputsAtOnce)
|
|
|
|
|
EXPECT_EQ(no_inserted_rows, mock_data.size());
|
|
|
|
|
|
|
|
|
|
// after inserting 10 rows, the expected ID should be before + 11
|
|
|
|
|
uint64_t expected_primary_id2 = xmr_accounts->get_next_primary_id(xmreg::XmrInput());
|
|
|
|
|
uint64_t expected_primary_id2
|
|
|
|
|
= xmr_accounts->get_next_primary_id(xmreg::XmrInput());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(expected_primary_id2, expected_primary_id + mock_data.size());
|
|
|
|
|
|
|
|
|
@ -1245,7 +1257,8 @@ TEST_F(MYSQL_TEST, SelectTxsIfAllAreSpendableAndExist)
|
|
|
|
|
txs.clear();
|
|
|
|
|
ASSERT_TRUE(this->xmr_accounts->select(acc.id.data, txs));
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts
|
|
|
|
|
->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
|
|
|
|
|
// we check if non of the input txs got filtere out
|
|
|
|
|
EXPECT_EQ(txs.size(), no_of_original_txs);
|
|
|
|
@ -1293,7 +1306,8 @@ TEST_F(MYSQL_TEST, SelectTxsIfAllAreNonspendableButUnlockedAndExist)
|
|
|
|
|
for (auto const& tx: txs)
|
|
|
|
|
ASSERT_FALSE(bool {tx.spendable});
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts
|
|
|
|
|
->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
|
|
|
|
|
// we check if non of the input txs got filtere out
|
|
|
|
|
EXPECT_EQ(txs.size(), no_of_original_txs);
|
|
|
|
@ -1364,7 +1378,8 @@ TEST_F(MYSQL_TEST, SelectTxsIfAllAreNonspendableLockedButExist)
|
|
|
|
|
ASSERT_EQ(tx.unlock_time, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
EXPECT_TRUE(this->xmr_accounts
|
|
|
|
|
->select_txs_for_account_spendability_check(acc.id.data, txs));
|
|
|
|
|
|
|
|
|
|
// we check if non of the input txs got filtere out
|
|
|
|
|
EXPECT_EQ(txs.size(), no_of_original_txs);
|
|
|
|
@ -1375,7 +1390,8 @@ TEST_F(MYSQL_TEST, SelectTxsIfAllAreNonspendableLockedButExist)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_FALSE(bool {tx.spendable});
|
|
|
|
|
if (!bool {tx.coinbase})
|
|
|
|
|
ASSERT_EQ(tx.unlock_time, tx.height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
|
|
|
|
ASSERT_EQ(tx.unlock_time,
|
|
|
|
|
tx.height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1404,8 +1420,6 @@ TEST_F(MYSQL_TEST, SelectTxsIfAllAreNonspendableUnlockedAndDontExist)
|
|
|
|
|
// so that we have something to work with in this test
|
|
|
|
|
ASSERT_TRUE(this->xmr_accounts->select(acc.id.data, txs));
|
|
|
|
|
|
|
|
|
|
auto no_of_original_txs = txs.size();
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < txs.size(); ++i)
|
|
|
|
|
this->xmr_accounts->mark_tx_nonspendable(txs[i].id.data);
|
|
|
|
|
|
|
|
|
@ -1508,7 +1522,8 @@ TEST_F(MYSQL_TEST, MysqlPingThreadStopsOnPingFailure)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// since we waiting 4s, we expect that there were at about 3-4 pings
|
|
|
|
|
EXPECT_EQ(mysql_ping.get_stop_reason(), xmreg::MysqlPing::StopReason::PingFailed);
|
|
|
|
|
EXPECT_EQ(mysql_ping.get_stop_reason(),
|
|
|
|
|
xmreg::MysqlPing::StopReason::PingFailed);
|
|
|
|
|
EXPECT_THAT(mysql_ping.get_counter(), AllOf(Ge(3), Le(5)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1549,7 +1564,8 @@ TEST_F(MYSQL_TEST, MysqlPingThreadStopsOnPointerExpiry)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// since we waiting 4s, we expect that there were at about 3-4 pings
|
|
|
|
|
EXPECT_EQ(mysql_ping.get_stop_reason(), xmreg::MysqlPing::StopReason::PointerExpired);
|
|
|
|
|
EXPECT_EQ(mysql_ping.get_stop_reason(),
|
|
|
|
|
xmreg::MysqlPing::StopReason::PointerExpired);
|
|
|
|
|
EXPECT_THAT(mysql_ping.get_counter(), AllOf(Ge(3), Le(5)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|