destroy wallet in tests and add variant numbers to the error enum

This commit is contained in:
Sergio Chouhy 2026-02-05 12:25:21 -03:00
parent 709f189aa1
commit e0caa7838d
3 changed files with 25 additions and 6 deletions

View File

@ -27,6 +27,8 @@ unsafe extern "C" {
password: *const c_char,
) -> *mut WalletHandle;
fn wallet_ffi_destroy(handle: *mut WalletHandle);
fn wallet_ffi_create_account_public(
handle: *mut WalletHandle,
out_account_id: *mut FfiBytes32,
@ -191,10 +193,11 @@ fn test_wallet_ffi_create_public_accounts() {
);
account_ids.push(out_account_id.data);
}
wallet_ffi_destroy(wallet_ffi_handle);
account_ids
};
assert_eq!(new_public_account_ids_ffi, new_public_account_ids_rust)
assert_eq!(new_public_account_ids_ffi, new_public_account_ids_rust);
}
#[test]
@ -226,6 +229,7 @@ fn test_wallet_ffi_create_private_accounts() {
);
account_ids.push(out_account_id.data);
}
wallet_ffi_destroy(wallet_ffi_handle);
account_ids
};
@ -315,7 +319,10 @@ fn test_wallet_ffi_list_accounts() {
assert_eq!(entry.is_public, is_public_in_rust_wallet);
}
unsafe { wallet_ffi_free_account_list((&mut wallet_ffi_account_list) as *mut FfiAccountList) };
unsafe {
wallet_ffi_free_account_list((&mut wallet_ffi_account_list) as *mut FfiAccountList);
wallet_ffi_destroy(wallet_ffi_handle);
}
}
#[test]
@ -339,6 +346,10 @@ fn test_wallet_ffi_get_balance_public() -> Result<()> {
info!("Successfully retrieved account balance");
unsafe {
wallet_ffi_destroy(wallet_ffi_handle);
}
Ok(())
}
@ -369,6 +380,7 @@ fn test_wallet_ffi_get_account_public() -> Result<()> {
unsafe {
wallet_ffi_free_account_data((&mut out_account) as *mut FfiAccount);
wallet_ffi_destroy(wallet_ffi_handle);
}
info!("Successfully retrieved account with correct details");
@ -406,6 +418,10 @@ fn test_wallet_ffi_get_public_account_keys() -> Result<()> {
info!("Successfully retrieved account key");
unsafe {
wallet_ffi_destroy(wallet_ffi_handle);
}
Ok(())
}
@ -442,6 +458,7 @@ fn test_wallet_ffi_get_private_account_keys() -> Result<()> {
unsafe {
wallet_ffi_free_private_account_keys((&mut keys) as *mut FfiPrivateAccountKeys);
wallet_ffi_destroy(wallet_ffi_handle);
}
info!("Successfully retrieved account keys");
@ -539,6 +556,7 @@ fn test_wallet_ffi_init_public_account_auth_transfer() -> Result<()> {
unsafe {
wallet_ffi_free_transfer_result((&mut transfer_result) as *mut FfiTransferResult);
wallet_ffi_destroy(wallet_ffi_handle);
}
Ok(())
@ -593,6 +611,7 @@ fn test_wallet_ffi_transfer_public() -> Result<()> {
unsafe {
wallet_ffi_free_transfer_result((&mut transfer_result) as *mut FfiTransferResult);
wallet_ffi_destroy(wallet_ffi_handle);
}
Ok(())

View File

@ -37,9 +37,9 @@ pub enum WalletFfiError {
/// Serialization/deserialization error
SerializationError = 14,
/// Invalid conversion from FFI types to NSSA types
InvalidTypeConversion,
InvalidTypeConversion = 15,
/// Invalid Key value
InvalidKeyValue,
InvalidKeyValue = 16,
/// Internal error (catch-all)
InternalError = 99,
}

View File

@ -98,11 +98,11 @@ typedef enum WalletFfiError {
/**
* Invalid conversion from FFI types to NSSA types
*/
INVALID_TYPE_CONVERSION,
INVALID_TYPE_CONVERSION = 15,
/**
* Invalid Key value
*/
INVALID_KEY_VALUE,
INVALID_KEY_VALUE = 16,
/**
* Internal error (catch-all)
*/