scripts for faster test wallets generation

This commit is contained in:
Ilya Kitaev 2016-06-01 17:06:10 +03:00
parent 2060bfe5ad
commit 44cc0ef147
11 changed files with 121 additions and 20 deletions

View file

@ -44,11 +44,10 @@
using namespace std;
//unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace Consts
{
// TODO: add test wallets to the source tree (as they have some balance mined)?
// TODO: get rid of hardcoded paths
const char * WALLET_NAME = "testwallet";
@ -59,21 +58,32 @@ const char * WALLET_PASS = "password";
const char * WALLET_PASS2 = "password22";
const char * WALLET_LANG = "English";
const char * TESTNET_WALLET1_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";
// change this according your environment
const std::string WALLETS_ROOT_DIR = "/home/mbg033/dev/monero/testnet/";
//const char * TESTNET_WALLET1_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin";
//const char * TESTNET_WALLET2_NAME = "/home/mbg033/dev/monero/testnet/wallet_02.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_WALLET5_NAME = "/home/mbg033/dev/monero/testnet/wallet_05.bin";
const std::string TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "wallet_01.bin";
const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.bin";
const std::string TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "wallet_03.bin";
const std::string TESTNET_WALLET4_NAME = WALLETS_ROOT_DIR + "wallet_04.bin";
const std::string TESTNET_WALLET5_NAME = WALLETS_ROOT_DIR + "wallet_05.bin";
const char * TESTNET_WALLET_PASS = "";
const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME;
const std::string CURRENT_DST_WALLET = TESTNET_WALLET5_NAME;
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
const uint64_t AMOUNT_10XMR = 10000000000000L;
const uint64_t AMOUNT_10XMR = 10000000000000L;
const uint64_t AMOUNT_5XMR = 5000000000000L;
const uint64_t AMOUNT_1XMR = 1000000000000L;
const char * TESTNET_WALLET3_ADDRESS = "A2N8LNKkzH2ddepepgvmz9e4JRe5QXkoPjg9kHW5CLWvH7eQNqEvNWmjJziVSqVLfUXVz7CYe5MZ32qJryVr8eBCLG5yJXP";
const char * TESTNET_WALLET4_ADDRESS = "9yMPpGDhXrPMEFk2AueB9EVP3oJtovj1zRiSKz481xVAFW6tDyft8H6WE9otfBLzzHCUQ98xRogjk3oiPQA2Qy5tKpsNhyE";
const char * RECIPIENT_WALLET_ADDRESS = TESTNET_WALLET4_ADDRESS;
}
@ -109,6 +119,15 @@ struct Utils
<< ", pid: " << t->paymentId()
<< std::endl;
}
static std::string get_wallet_address(const std::string &filename, const std::string &password)
{
Bitmonero::WalletManager *wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
Bitmonero::Wallet * w = wmgr->openWallet(filename, password, true);
std::string result = w->address();
wmgr->closeWallet(w);
return result;
}
};
@ -303,14 +322,16 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4)
TEST_F(WalletTest1, WalletShowsBalance)
{
Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true);
// TODO: temporary disabled;
return;
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
ASSERT_TRUE(wallet1->balance() > 0);
ASSERT_TRUE(wallet1->unlockedBalance() > 0);
uint64_t balance1 = wallet1->balance();
uint64_t unlockedBalance1 = wallet1->unlockedBalance();
ASSERT_TRUE(wmgr->closeWallet(wallet1));
Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true);
Bitmonero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
ASSERT_TRUE(balance1 == wallet2->balance());
std::cout << "wallet balance: " << wallet2->balance() << std::endl;
@ -321,7 +342,7 @@ TEST_F(WalletTest1, WalletShowsBalance)
TEST_F(WalletTest1, WalletRefresh)
{
Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true);
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
@ -330,17 +351,19 @@ TEST_F(WalletTest1, WalletRefresh)
TEST_F(WalletTest1, WalletTransaction)
{
Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true);
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
uint64_t balance = wallet1->balance();
ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok);
Bitmonero::PendingTransaction * transaction = wallet1->createTransaction(
RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR);
ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok);
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
Bitmonero::PendingTransaction * transaction = wallet1->createTransaction(
recepient_address, AMOUNT_10XMR);
ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok);
wallet1->refresh();
ASSERT_TRUE(wallet1->balance() == balance);
ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR);
@ -351,7 +374,7 @@ TEST_F(WalletTest1, WalletTransaction)
TEST_F(WalletTest1, WalletHistory)
{
Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true);
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
// make sure testnet daemon is running
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet1->refresh());
@ -368,7 +391,8 @@ TEST_F(WalletTest1, WalletHistory)
TEST_F(WalletTest1, WalletTransactionAndHistory)
{
Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true);
return;
Bitmonero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
// make sure testnet daemon is running
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src->refresh());
@ -383,7 +407,9 @@ TEST_F(WalletTest1, WalletTransactionAndHistory)
Utils::print_transaction(t);
}
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5);
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, AMOUNT_10XMR * 5);
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
history = wallet_src->history();

View file

@ -0,0 +1,20 @@
#!/bin/bash
function create_wallet {
wallet_name=$1
echo 0 | simplewallet --testnet --trusted-daemon --daemon-address localhost:38081 --generate-new-wallet $wallet_name --password "" --restore-height=1
}
create_wallet wallet_01.bin
create_wallet wallet_02.bin
create_wallet wallet_03.bin
#create_wallet wallet_04.bin
create_wallet wallet_05.bin
create_wallet wallet_06.bin
#create_wallet wallet_m

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log start_mining

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_miner.log stop_mining

View file

@ -0,0 +1,5 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_01.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log

View file

@ -0,0 +1,5 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_02.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_03.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_03.log

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log

View file

@ -0,0 +1,4 @@
#!/bin/bash
rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address 127.0.0.1:38081 --log-file wallet_m.log

View file

@ -0,0 +1,21 @@
#!/bin/bash
function send_funds {
local amount=$1
local dest=$(cat "$2.address.txt")
simplewallet --wallet-file wallet_m --password "" \
--testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log \
--command transfer $dest $amount
}
send_funds 100 wallet_01.bin
send_funds 100 wallet_02.bin
send_funds 100 wallet_03.bin
send_funds 100 wallet_04.bin
send_funds 100 wallet_05.bin