host/test_wallet.c
/** Call nearly all wallet functions and make sure they
  * return #WALLET_NOT_LOADED somehow. This should only be called if a wallet
  * is not loaded. */
Call nearly all wallet functions and make sure they
return #WALLET_NOT_LOADED somehow. This should only be called if a wallet
is not loaded.
Call nearly all wallet functions and make sure they return #WALLET_NOT_LOADED somehow . This should only be called if a wallet is not loaded .
static void checkFunctionsReturnWalletNotLoaded(void)
{
	uint8_t temp[128];
	uint32_t check_num_addresses;
	AddressHandle ah;
	PointAffine public_key;
	ah = makeNewAddress(temp, &public_key);
	if ((ah == BAD_ADDRESS_HANDLE) && (walletGetLastError() == WALLET_NOT_LOADED))
		reportSuccessWallet();
	else
	{
		printf("makeNewAddress() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	check_num_addresses = getNumAddresses();
	if ((check_num_addresses == 0) && (walletGetLastError() == WALLET_NOT_LOADED))
		reportSuccessWallet();
	else
	{
		printf("getNumAddresses() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (getAddressAndPublicKey(temp, &public_key, 0) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("getAddressAndPublicKey() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (getPrivateKey(temp, 0) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("getPrivateKey() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (changeEncryptionKey(temp, 0) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("changeEncryptionKey() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (changeWalletName(temp) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("changeWalletName() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (backupWallet(false, 0) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("backupWallet() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
	if (getMasterPublicKey(&public_key, temp) == WALLET_NOT_LOADED)
		reportSuccessWallet();
	else
	{
		printf("getMasterPublicKey() doesn't recognise when wallet isn't loaded\n");
		reportFailureWallet();
	}
}
static void checkFunctionsReturnWalletNotLoaded ( void ) { uint8_t temp [ 128 ] ; uint32_t check_num_addresses ; AddressHandle ah ; PointAffine public_key ; ah = makeNewAddress ( temp , & public_key ) ; if ( ( ah == BAD_ADDRESS_HANDLE ) && ( walletGetLastError ( ) == WALLET_NOT_LOADED ) ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } check_num_addresses = getNumAddresses ( ) ; if ( ( check_num_addresses == 0 ) && ( walletGetLastError ( ) == WALLET_NOT_LOADED ) ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( getAddressAndPublicKey ( temp , & public_key , 0 ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( getPrivateKey ( temp , 0 ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( changeEncryptionKey ( temp , 0 ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( changeWalletName ( temp ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( backupWallet ( false , 0 ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } if ( getMasterPublicKey ( & public_key , temp ) == WALLET_NOT_LOADED ) reportSuccessWallet ( ) ; else { printf ( " \n " ) ; reportFailureWallet ( ) ; } }
Call nearly all wallet functions and make sure they
 return #WALLET_NOT_LOADED somehow.
Call nearly all wallet functions and make sure they return #WALLET_NOT_LOADED somehow .
/* newWallet() not tested because it calls initWallet() when it's done. */