From b8824ba43dd648b3be02be7e87b0e33a616a99b8 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Mon, 27 May 2024 14:55:16 +0200 Subject: [PATCH] some fixes --- integration_tests/src/chat_ffi.rs | 22 +++++++++++-------- .../tests/steps/chat_ffi_steps.rs | 5 ++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/integration_tests/src/chat_ffi.rs b/integration_tests/src/chat_ffi.rs index 2c569e3531..93f9c8323a 100644 --- a/integration_tests/src/chat_ffi.rs +++ b/integration_tests/src/chat_ffi.rs @@ -70,20 +70,22 @@ extern "C" fn callback_read_confirmation_received(_state: *mut c_void) { extern "C" { pub fn create_chat_client( config: *mut c_void, - error_out: *const c_int, callback_contact_status_change: unsafe extern "C" fn(*mut c_void), callback_message_received: unsafe extern "C" fn(*mut c_void), callback_delivery_confirmation_received: unsafe extern "C" fn(*mut c_void), callback_read_confirmation_received: unsafe extern "C" fn(*mut c_void), + tari_address: *mut c_void, + error_out: *const c_int, ) -> *mut ClientFFI; pub fn sideload_chat_client( config: *mut c_void, contact_handle: *mut c_void, - error_out: *const c_int, callback_contact_status_change: unsafe extern "C" fn(*mut c_void), callback_message_received: unsafe extern "C" fn(*mut c_void), callback_delivery_confirmation_received: unsafe extern "C" fn(*mut c_void), callback_read_confirmation_received: unsafe extern "C" fn(*mut c_void), + tari_address: *mut c_void, + error_out: *const c_int, ) -> *mut ClientFFI; pub fn create_chat_message( receiver: *mut c_void, @@ -310,26 +312,26 @@ pub async fn spawn_ffi_chat_client(name: &str, seed_peers: Vec, base_dir: let client_ptr; let error_out = Box::into_raw(Box::new(0)); - + let address = + TariAddress::new_single_address_with_default_features(identity.public_key().clone(), Network::LocalNet); + let address_ptr = Box::into_raw(Box::new(address.clone())) as *mut c_void; unsafe { *ChatCallback::instance().contact_status_change.lock().unwrap() = 0; client_ptr = create_chat_client( config_ptr, - error_out, callback_contact_status_change, callback_message_received, callback_delivery_confirmation_received, callback_read_confirmation_received, + address_ptr, + error_out, ); } ChatFFI { ptr: Arc::new(Mutex::new(PtrWrapper(client_ptr))), - address: TariAddress::new_single_address_with_default_features( - identity.public_key().clone(), - Network::LocalNet, - ), + address, } } @@ -342,6 +344,7 @@ pub async fn sideload_ffi_chat_client( config.chat_client.set_base_path(base_dir); let config_ptr = Box::into_raw(Box::new(config)) as *mut c_void; + let adress_ptr = Box::into_raw(Box::new(address.clone())) as *mut c_void; let client_ptr; let error_out = Box::into_raw(Box::new(0)); @@ -351,11 +354,12 @@ pub async fn sideload_ffi_chat_client( client_ptr = sideload_chat_client( config_ptr, contacts_handle_ptr, - error_out, callback_contact_status_change, callback_message_received, callback_delivery_confirmation_received, callback_read_confirmation_received, + adress_ptr, + error_out, ); } diff --git a/integration_tests/tests/steps/chat_ffi_steps.rs b/integration_tests/tests/steps/chat_ffi_steps.rs index 35acd32845..7461ebdf2a 100644 --- a/integration_tests/tests/steps/chat_ffi_steps.rs +++ b/integration_tests/tests/steps/chat_ffi_steps.rs @@ -47,9 +47,8 @@ async fn chat_ffi_client_connected_to_base_node(world: &mut TariWorld, name: Str #[when(expr = "I have a sideloaded chat FFI client {word} from {word}")] async fn sideloaded_chat_ffi_client_connected_to_wallet(world: &mut TariWorld, chat_name: String, wallet_name: String) { let wallet = world.get_ffi_wallet(&wallet_name).unwrap(); - let pubkey = world.get_wallet_address(&wallet_name).await.unwrap(); - let address = TariAddress::from_hex(&pubkey).unwrap(); - + let address = world.get_wallet_address(&wallet_name).await.unwrap(); + let address = TariAddress::from_hex(&address).unwrap(); let client = sideload_ffi_chat_client(address, wallet.base_dir.clone(), wallet.contacts_handle()).await; world.chat_clients.insert(chat_name, Box::new(client)); }