host/test_wallet.c
/** Call all wallet functions which accept a wallet number and check
  * that they fail or succeed for a given wallet number.
  * \param wallet_spec The wallet number to check.
  * \param should_succeed true if the wallet number is valid (and thus the
  *                       wallet functions should succeed), false if the wallet
  *                       number is not valid (and thus the wallet functions
  *                       should fail).
  */
Call all wallet functions which accept a wallet number and check
that they fail or succeed for a given wallet number.
\param wallet_spec The wallet number to check.
\param should_succeed true if the wallet number is valid (and thus the
wallet functions should succeed), false if the wallet
number is not valid (and thus the wallet functions
should fail).
Call all wallet functions which accept a wallet number and check that they fail or succeed for a given wallet number . \ param wallet_spec The wallet number to check . \ param should_succeed true if the wallet number is valid ( and thus the wallet functions should succeed ) false if the wallet number is not valid ( and thus the wallet functions should fail ) .
static void checkWalletSpecFunctions(uint32_t wallet_spec, bool should_succeed)
{
	uint8_t wallet_uuid[UUID_LENGTH];
	uint8_t name[NAME_LENGTH];
	uint32_t version;
	WalletErrors wallet_return;
	memset(name, ' ', NAME_LENGTH);
	uninitWallet();
	wallet_return = newWallet(wallet_spec, name, false, NULL, false, NULL, 0);
	if (should_succeed && (wallet_return != WALLET_NO_ERROR))
	{
		printf("newWallet() failed with wallet number %u when it should have succeeded\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
	if (!should_succeed && (wallet_return != WALLET_INVALID_WALLET_NUM))
	{
		printf("newWallet() did not return WALLET_INVALID_WALLET_NUM with wallet number %u when it should have\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
	uninitWallet();
	wallet_return = initWallet(wallet_spec, NULL, 0);
	if (should_succeed && (wallet_return != WALLET_NO_ERROR))
	{
		printf("initWallet() failed with wallet number %u when it should have succeeded\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
	if (!should_succeed && (wallet_return != WALLET_INVALID_WALLET_NUM))
	{
		printf("initWallet() did not return WALLET_INVALID_WALLET_NUM with wallet number %u when it should have\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
	uninitWallet();
	wallet_return = getWalletInfo(&version, name, wallet_uuid, wallet_spec);
	if (should_succeed && (wallet_return != WALLET_NO_ERROR))
	{
		printf("getWalletInfo() failed with wallet number %u when it should have succeeded\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
	if (!should_succeed && (wallet_return != WALLET_INVALID_WALLET_NUM))
	{
		printf("getWalletInfo() did not return WALLET_INVALID_WALLET_NUM with wallet number %u when it should have\n", wallet_spec);
		reportFailureWallet();
	}
	else
		reportSuccessWallet();
}
static void checkWalletSpecFunctions ( uint32_t wallet_spec , bool should_succeed ) { uint8_t wallet_uuid [ UUID_LENGTH ] ; uint8_t name [ NAME_LENGTH ] ; uint32_t version ; WalletErrors wallet_return ; memset ( name , ' ' , NAME_LENGTH ) ; uninitWallet ( ) ; wallet_return = newWallet ( wallet_spec , name , false , NULL , false , NULL , 0 ) ; if ( should_succeed && ( wallet_return != WALLET_NO_ERROR ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; if ( ! should_succeed && ( wallet_return != WALLET_INVALID_WALLET_NUM ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; uninitWallet ( ) ; wallet_return = initWallet ( wallet_spec , NULL , 0 ) ; if ( should_succeed && ( wallet_return != WALLET_NO_ERROR ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; if ( ! should_succeed && ( wallet_return != WALLET_INVALID_WALLET_NUM ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; uninitWallet ( ) ; wallet_return = getWalletInfo ( & version , name , wallet_uuid , wallet_spec ) ; if ( should_succeed && ( wallet_return != WALLET_NO_ERROR ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; if ( ! should_succeed && ( wallet_return != WALLET_INVALID_WALLET_NUM ) ) { printf ( " \n " , wallet_spec ) ; reportFailureWallet ( ) ; } else reportSuccessWallet ( ) ; }
Call all wallet functions which accept a wallet number and check
 that they fail or succeed for a given wallet number.
Call all wallet functions which accept a wallet number and check that they fail or succeed for a given wallet number .
/*
	 * This call to initWallet() must be placed after the call to newWallet()
	 * so that if should_succeed is true, there's a valid wallet in the
	 * specified place.
	 */