|
|
@ -76,12 +76,19 @@ struct WalletManagerTest : public testing::Test
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: add test wallets to the source tree (as they have some balance mined)?
|
|
|
|
// TODO: add test wallets to the source tree (as they have some balance mined)?
|
|
|
|
const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin";
|
|
|
|
const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin";
|
|
|
|
|
|
|
|
const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin";
|
|
|
|
|
|
|
|
const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin";
|
|
|
|
const char * TESTNET_WALLET_PASS = "";
|
|
|
|
const char * TESTNET_WALLET_PASS = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
|
|
|
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
|
|
|
const uint64_t AMOUNT_10XMR = 10000000000000L;
|
|
|
|
const uint64_t AMOUNT_10XMR = 10000000000000L;
|
|
|
|
const uint64_t AMOUNT_5XMR = 50000000000000L;
|
|
|
|
const uint64_t AMOUNT_5XMR = 50000000000000L;
|
|
|
|
|
|
|
|
|
|
|
|
const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3";
|
|
|
|
const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3";
|
|
|
|
|
|
|
|
const char * TESTNET_WALLET3_ADDRESS = "A11cBpRDqpTCneSL3KNBvGWM6PfxG7QrxNVCcMiZeuAD3fQA9Z366DegFLYHKrMnDm8QixPziRn4kVcWPFtn6aCSR1Hp7sg";
|
|
|
|
|
|
|
|
const char * TESTNET_WALLET4_ADDRESS = "A21wicxbhUSKa6twequhKCCG8wYEGZ7viYRLW7mBXtWyheyY8C8XwUJG5PSjULDs1q7hndkihtFgybWjagvchrNg1Y588hM";
|
|
|
|
|
|
|
|
|
|
|
|
WalletManagerTest()
|
|
|
|
WalletManagerTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -97,6 +104,20 @@ struct WalletManagerTest : public testing::Test
|
|
|
|
std::cout << __FUNCTION__ << std::endl;
|
|
|
|
std::cout << __FUNCTION__ << std::endl;
|
|
|
|
//deleteWallet(WALLET_NAME);
|
|
|
|
//deleteWallet(WALLET_NAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void print_transaction(Bitmonero::TransactionInfo * t)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << "d: "
|
|
|
|
|
|
|
|
<< (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out")
|
|
|
|
|
|
|
|
<< ", pe: " << (t->isPending() ? "true" : "false")
|
|
|
|
|
|
|
|
<< ", bh: " << t->blockHeight()
|
|
|
|
|
|
|
|
<< ", a: " << Bitmonero::Wallet::displayAmount(t->amount())
|
|
|
|
|
|
|
|
<< ", f: " << Bitmonero::Wallet::displayAmount(t->fee())
|
|
|
|
|
|
|
|
<< ", h: " << t->hash()
|
|
|
|
|
|
|
|
<< ", pid: " << t->paymentId()
|
|
|
|
|
|
|
|
<< std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -279,6 +300,7 @@ TEST_F(WalletManagerTest, WalletTransaction)
|
|
|
|
RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR);
|
|
|
|
RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR);
|
|
|
|
ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok);
|
|
|
|
ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(wallet1->balance() == balance);
|
|
|
|
ASSERT_TRUE(wallet1->balance() == balance);
|
|
|
|
ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR);
|
|
|
|
ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR);
|
|
|
|
ASSERT_TRUE(transaction->commit());
|
|
|
|
ASSERT_TRUE(transaction->commit());
|
|
|
@ -295,20 +317,42 @@ TEST_F(WalletManagerTest, WalletHistory)
|
|
|
|
Bitmonero::TransactionHistory * history = wallet1->history();
|
|
|
|
Bitmonero::TransactionHistory * history = wallet1->history();
|
|
|
|
history->refresh();
|
|
|
|
history->refresh();
|
|
|
|
ASSERT_TRUE(history->count() > 0);
|
|
|
|
ASSERT_TRUE(history->count() > 0);
|
|
|
|
auto transaction_print = [=] (Bitmonero::TransactionInfo * t) {
|
|
|
|
|
|
|
|
std::cout << "d: "
|
|
|
|
|
|
|
|
<< (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out")
|
|
|
|
|
|
|
|
<< ", bh: " << t->blockHeight()
|
|
|
|
|
|
|
|
<< ", a: " << Bitmonero::Wallet::displayAmount(t->amount())
|
|
|
|
|
|
|
|
<< ", f: " << Bitmonero::Wallet::displayAmount(t->fee())
|
|
|
|
|
|
|
|
<< ", h: " << t->hash()
|
|
|
|
|
|
|
|
<< ", pid: " << t->paymentId()
|
|
|
|
|
|
|
|
<< std::endl;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
|
|
|
|
|
|
|
print_transaction(t);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletTransactionAndHistory)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true);
|
|
|
|
|
|
|
|
// make sure testnet daemon is running
|
|
|
|
|
|
|
|
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
|
|
|
|
ASSERT_TRUE(wallet_src->refresh());
|
|
|
|
|
|
|
|
Bitmonero::TransactionHistory * history = wallet_src->history();
|
|
|
|
|
|
|
|
history->refresh();
|
|
|
|
|
|
|
|
ASSERT_TRUE(history->count() > 0);
|
|
|
|
|
|
|
|
size_t count1 = history->count();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << "**** Transactions before transfer (" << count1 << ")" << std::endl;
|
|
|
|
|
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
|
|
|
|
|
|
|
print_transaction(t);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5);
|
|
|
|
|
|
|
|
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
|
|
|
|
|
|
|
|
ASSERT_TRUE(tx->commit());
|
|
|
|
|
|
|
|
history = wallet_src->history();
|
|
|
|
|
|
|
|
history->refresh();
|
|
|
|
|
|
|
|
ASSERT_TRUE(count1 != history->count());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl;
|
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
|
|
|
transaction_print(t);
|
|
|
|
print_transaction(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|