Wallet::filename, Wallet::keysFilename, tests for move wallet
This commit is contained in:
parent
8f9d98b3e0
commit
c554055ce4
|
@ -303,6 +303,16 @@ bool WalletImpl::store(const std::string &path)
|
|||
return m_status == Status_Ok;
|
||||
}
|
||||
|
||||
string WalletImpl::filename() const
|
||||
{
|
||||
return m_wallet->get_wallet_file();
|
||||
}
|
||||
|
||||
string WalletImpl::keysFilename() const
|
||||
{
|
||||
return m_wallet->get_keys_file();
|
||||
}
|
||||
|
||||
bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transaction_size_limit)
|
||||
{
|
||||
clearStatus();
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
bool setPassword(const std::string &password);
|
||||
std::string address() const;
|
||||
bool store(const std::string &path);
|
||||
std::string filename() const;
|
||||
std::string keysFilename() const;
|
||||
bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit);
|
||||
bool connectToDaemon();
|
||||
void setTrustedDaemon(bool arg);
|
||||
|
|
|
@ -135,7 +135,24 @@ struct Wallet
|
|||
virtual std::string errorString() const = 0;
|
||||
virtual bool setPassword(const std::string &password) = 0;
|
||||
virtual std::string address() const = 0;
|
||||
/*!
|
||||
* \brief store - stores wallet to file.
|
||||
* \param path - main filename to store wallet to. additionally stores address file and keys file.
|
||||
* to store to the same file - just pass empty string;
|
||||
* \return
|
||||
*/
|
||||
virtual bool store(const std::string &path) = 0;
|
||||
/*!
|
||||
* \brief filename - returns wallet filename
|
||||
* \return
|
||||
*/
|
||||
virtual std::string filename() const = 0;
|
||||
/*!
|
||||
* \brief keysFilename - returns keys filename. usually this formed as "wallet_filename".keys
|
||||
* \return
|
||||
*/
|
||||
virtual std::string keysFilename() const = 0;
|
||||
|
||||
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit) = 0;
|
||||
virtual bool connectToDaemon() = 0;
|
||||
virtual void setTrustedDaemon(bool arg) = 0;
|
||||
|
|
|
@ -210,6 +210,35 @@ TEST_F(WalletManagerTest, WalletManagerOpensWallet)
|
|||
std::cout << "** seed: " << wallet2->seed() << std::endl;
|
||||
}
|
||||
|
||||
TEST_F(WalletManagerTest, WalletManagerStoresWallet)
|
||||
{
|
||||
|
||||
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
||||
std::string seed1 = wallet1->seed();
|
||||
wallet1->store("");
|
||||
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
||||
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
||||
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
||||
ASSERT_TRUE(wallet2->seed() == seed1);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(WalletManagerTest, WalletManagerMovesWallet)
|
||||
{
|
||||
|
||||
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
||||
std::string WALLET_NAME_MOVED = std::string("/tmp/") + WALLET_NAME + ".moved";
|
||||
std::string seed1 = wallet1->seed();
|
||||
ASSERT_TRUE(wallet1->store(WALLET_NAME_MOVED));
|
||||
|
||||
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_MOVED, WALLET_PASS);
|
||||
ASSERT_TRUE(wallet2->filename() == WALLET_NAME_MOVED);
|
||||
ASSERT_TRUE(wallet2->keysFilename() == WALLET_NAME_MOVED + ".keys");
|
||||
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
||||
ASSERT_TRUE(wallet2->seed() == seed1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST_F(WalletManagerTest, WalletManagerChangesPassword)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue