Wallet::refresh + tests
This commit is contained in:
parent
1ae9cdc6bf
commit
830c19c934
|
@ -76,6 +76,7 @@ public:
|
||||||
uint64_t balance() const;
|
uint64_t balance() const;
|
||||||
uint64_t unlockedBalance() const;
|
uint64_t unlockedBalance() const;
|
||||||
std::string displayAmount(uint64_t amount) const;
|
std::string displayAmount(uint64_t amount) const;
|
||||||
|
bool refresh();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -293,6 +294,18 @@ std::string WalletImpl::displayAmount(uint64_t amount) const
|
||||||
return cryptonote::print_money(amount);
|
return cryptonote::print_money(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WalletImpl::refresh()
|
||||||
|
{
|
||||||
|
clearStatus();
|
||||||
|
try {
|
||||||
|
m_wallet->refresh();
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
m_status = Status_Error;
|
||||||
|
m_errorString = e.what();
|
||||||
|
}
|
||||||
|
return m_status == Status_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletImpl::connectToDaemon()
|
bool WalletImpl::connectToDaemon()
|
||||||
{
|
{
|
||||||
bool result = m_wallet->check_connection();
|
bool result = m_wallet->check_connection();
|
||||||
|
|
|
@ -74,6 +74,9 @@ struct Wallet
|
||||||
virtual std::string displayAmount(uint64_t amount) const = 0;
|
virtual std::string displayAmount(uint64_t amount) const = 0;
|
||||||
// TODO?
|
// TODO?
|
||||||
// virtual uint64_t unlockedDustBalance() const = 0;
|
// virtual uint64_t unlockedDustBalance() const = 0;
|
||||||
|
// TODO refresh
|
||||||
|
virtual bool refresh() = 0;
|
||||||
|
// TODO transfer
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,10 +71,13 @@ struct WalletManagerTest : public testing::Test
|
||||||
const char * WALLET_PASS2 = "password22";
|
const char * WALLET_PASS2 = "password22";
|
||||||
const char * WALLET_LANG = "English";
|
const char * WALLET_LANG = "English";
|
||||||
|
|
||||||
|
|
||||||
// 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_WALLET_PASS = "";
|
const char * TESTNET_WALLET_PASS = "";
|
||||||
|
|
||||||
|
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
||||||
|
|
||||||
WalletManagerTest()
|
WalletManagerTest()
|
||||||
{
|
{
|
||||||
std::cout << __FUNCTION__ << std::endl;
|
std::cout << __FUNCTION__ << std::endl;
|
||||||
|
@ -249,6 +252,15 @@ TEST_F(WalletManagerTest, WalletShowsBalance)
|
||||||
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WalletManagerTest, WalletRefresh)
|
||||||
|
{
|
||||||
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true);
|
||||||
|
// make sure testnet daemon is running
|
||||||
|
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
|
||||||
|
ASSERT_TRUE(wallet1->refresh());
|
||||||
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue