static void
run_test (void)
{
    Account *act1;
    Account *act2;
    //Split *spl;
    QofSession *session;
    QofBook *book;

    session = qof_session_new ();
    book = qof_session_get_book (session);

    act1 = get_random_account(book);
    do_test(act1 != NULL, "random account created");

    act2 = get_random_account(book);
    do_test(act2 != NULL, "random account created");
#if 0
    spl = get_random_split(book, act1, NULL);
    do_test(spl != NULL, "random split created");

    do_test(act1 == xaccSplitGetAccount(spl), "xaccAccountInsertSplit()");
#endif
    //FIXME
    //xaccSplitSetAccount (spl, NULL);
    //do_test(xaccSplitGetAccount(spl) == NULL, "xaccAccountRemoveSplit()");
}
static void
test_generation ()
{
    int i;

    for (i = 0; i < 20; i++)
    {
        Account* ran_act;

        ran_act = get_random_account (sixbook);

        test_account (i, ran_act);

        delete_random_account (ran_act);
    }

    {
        /* empty some things. */
        Account* act;
        const char* msg =
            "xaccAccountSetCommodity: assertion `GNC_IS_COMMODITY(com)' failed";
        const char* logdomain = "gnc.engine";
        GLogLevelFlags loglevel = static_cast<decltype (loglevel)>
                                  (G_LOG_LEVEL_CRITICAL);
        TestErrorStruct check = { loglevel, const_cast<char*> (logdomain),
                                  const_cast<char*> (msg)
                                };
        g_log_set_handler (logdomain, loglevel,
                           (GLogFunc)test_checked_handler, &check);

        act = get_random_account (sixbook);

        xaccAccountSetCode (act, "");
        xaccAccountSetDescription (act, "");

        xaccAccountSetCommodity (act, NULL);

        test_account (-1, act);

        delete_random_account (act);
    }

    /*     { */
    /*         Account *act1; */
    /*         Account *act2; */

    /*         act1 = get_random_account(); */
    /*         act2 = get_random_account(); */

    /*         gnc_account_append_child(act1, act2); */

    /*         test_account(-1, act2); */
    /*         test_account(-1, act1); */

    /*         delete_random_account(act2); */
    /*         delete_random_account(act1); */
    /*     } */

}
Example #3
0
void rai::system::generate_change_known (rai::node & node_a, std::vector<rai::account> & accounts_a)
{
	rai::account source (get_random_account (accounts_a));
	if (!node_a.latest (source).is_zero ())
	{
		rai::account destination (get_random_account (accounts_a));
		auto change_error (wallet (0)->change_sync (source, destination));
		assert (!change_error);
	}
}
Example #4
0
void rai::system::generate_send_existing (rai::node & node_a, std::vector<rai::account> & accounts_a)
{
	rai::uint128_t amount;
	rai::account destination;
	rai::account source;
	{
		rai::account account;
		random_pool.GenerateBlock (account.bytes.data (), sizeof (account.bytes));
		rai::transaction transaction (node_a.store.environment, nullptr, false);
		rai::store_iterator entry (node_a.store.latest_begin (transaction, account));
		if (entry == node_a.store.latest_end ())
		{
			entry = node_a.store.latest_begin (transaction);
		}
		assert (entry != node_a.store.latest_end ());
		destination = rai::account (entry->first.uint256 ());
		source = get_random_account (accounts_a);
		amount = get_random_amount (transaction, node_a, source);
	}
	if (!amount.is_zero ())
	{
		auto hash (wallet (0)->send_sync (source, destination, amount));
		assert (!hash.is_zero ());
	}
}
Example #5
0
void rai::system::generate_send_new (rai::node & node_a, std::vector<rai::account> & accounts_a)
{
	assert (node_a.wallets.items.size () == 1);
	rai::uint128_t amount;
	rai::account source;
	{
		rai::transaction transaction (node_a.store.environment, nullptr, false);
		source = get_random_account (accounts_a);
		amount = get_random_amount (transaction, node_a, source);
	}
	if (!amount.is_zero ())
	{
		auto pub (node_a.wallets.items.begin ()->second->deterministic_insert ());
		accounts_a.push_back (pub);
		auto hash (wallet (0)->send_sync (source, pub, amount));
		assert (!hash.is_zero ());
	}
}