TEST(TestGetBalance, IncomeAmountBalance)
{
    GetBalance balance;

    // Create Wallet just with initial amount
    DoCreateWallet wallet("main\\tst\\WalletBalance","+200.55");
    wallet.CreateWalletFile();

    //add income
    std::string amountt = "+100";
    std::string choise = "income";
    std::string category1 = "salary";
    std::string wallet5 = "";
    DoCreateWallet wallet1("main\\tst\\WalletBalance",amountt);
    wallet1.AddLineInWalletFile(amountt, choise, category1, wallet5);

    //add income
    amountt = "+700";
    choise = "income";
    category1 = "bonus";
    DoCreateWallet wallet2("main\\tst\\WalletBalance",amountt);
    wallet2.AddLineInWalletFile(amountt, choise, category1, wallet5);

    //convert file content to string
    std::string walletFile = ReturnWalletString(wallet);
    //std :: cout<<walletFile;

    EXPECT_EQ("+1000.55",balance.PrintBalance(walletFile,""));
}
TEST(TestGetBalance, SpendAmountBalance)
{
    GetBalance balance;

    // Create Wallet just with initial amount
    DoCreateWallet wallet("main\\tst\\WalletBalance","+200.55");
    wallet.CreateWalletFile();

    //add income
    std::string amountt = "100";
    std::string choise = "spend";
    std::string category1 = "donation";
    std::string wallet6 = "";
    DoCreateWallet wallet1("main\\tst\\WalletBalance",amountt);
    wallet1.AddLineInWalletFile(amountt, choise, category1, wallet6);

    //add income
    amountt = "700";
    choise = "spend";
    category1 = "food";
    DoCreateWallet wallet2("main\\tst\\WalletBalance",amountt);
    wallet2.AddLineInWalletFile(amountt, choise, category1, wallet6);

    //convert file content to string
    std::string walletFile = ReturnWalletString(wallet);
    //std :: cout<<walletFile;

    EXPECT_EQ("-599.45",balance.PrintBalance(walletFile,""));
}
TEST(TestGetBalanceCategory, IncomeSpendSameCategory)
{
	GetBalance balance;
	
	// Create Wallet just with initial amount
	DoCreateWallet wallet("main\\tst\\WalletBalanceCategory","+200.55");
	wallet.CreateWalletFile();
	
	//add spend
	std::string amount = "10";
	std::string choice = "spend";
	std::string category1 = "bcategory";
	std::string wallet7 = "";
	DoCreateWallet wallet1("main\\tst\\WalletBalanceCategory",amount);
	wallet1.AddLineInWalletFile(amount, choice, category1, wallet7);
	
	//add income
	amount = "9";
	choice = "income";
	category1 = "bcategory";
	DoCreateWallet wallet2("main\\tst\\WalletBalanceCategory",amount);
	wallet2.AddLineInWalletFile(amount, choice, category1, wallet7);
	
	//convert file content to string
	std::string walletFile = ReturnWalletString77(wallet);
	//std :: cout<<walletFile;
	
	EXPECT_EQ("-1",balance.PrintBalance(walletFile,"bcategory"));
}
/**
 * This test covers methods on CWalletDB to load/save crypted z keys.
 */
TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) {
    ECC_Start();

    SelectParams(CBaseChainParams::TESTNET);

    // Get temporary and unique path for file.
    // Note: / operator to append paths
    boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
    boost::filesystem::create_directories(pathTemp);
    mapArgs["-datadir"] = pathTemp.string();

    bool fFirstRun;
    CWallet wallet("wallet_crypted.dat");
    ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun));

    // No default CPubKey set
    ASSERT_TRUE(fFirstRun);

    // wallet should be empty
    std::set<libzcash::PaymentAddress> addrs;
    wallet.GetPaymentAddresses(addrs);
    ASSERT_EQ(0, addrs.size());

    // Add random key to the wallet
    auto paymentAddress = wallet.GenerateNewZKey();

    // wallet should have one key
    wallet.GetPaymentAddresses(addrs);
    ASSERT_EQ(1, addrs.size());

    // encrypt wallet
    SecureString strWalletPass;
    strWalletPass.reserve(100);
    strWalletPass = "******";
    ASSERT_TRUE(wallet.EncryptWallet(strWalletPass));

    // adding a new key will fail as the wallet is locked
    EXPECT_ANY_THROW(wallet.GenerateNewZKey());

    // unlock wallet and then add
    wallet.Unlock(strWalletPass);
    auto paymentAddress2 = wallet.GenerateNewZKey();

    // Create a new wallet from the existing wallet path
    CWallet wallet2("wallet_crypted.dat");
    ASSERT_EQ(DB_LOAD_OK, wallet2.LoadWallet(fFirstRun));

    // Confirm it's not the same as the other wallet
    ASSERT_TRUE(&wallet != &wallet2);

    // wallet should have two keys
    wallet2.GetPaymentAddresses(addrs);
    ASSERT_EQ(2, addrs.size());

    // check we have entries for our payment addresses
    ASSERT_TRUE(addrs.count(paymentAddress.Get()));
    ASSERT_TRUE(addrs.count(paymentAddress2.Get()));

    // spending key is crypted, so we can't extract valid payment address
    libzcash::SpendingKey keyOut;
    wallet2.GetSpendingKey(paymentAddress.Get(), keyOut);
    ASSERT_FALSE(paymentAddress.Get() == keyOut.address());

    // unlock wallet to get spending keys and verify payment addresses
    wallet2.Unlock(strWalletPass);

    wallet2.GetSpendingKey(paymentAddress.Get(), keyOut);
    ASSERT_EQ(paymentAddress.Get(), keyOut.address());

    wallet2.GetSpendingKey(paymentAddress2.Get(), keyOut);
    ASSERT_EQ(paymentAddress2.Get(), keyOut.address());
}