Skip to content

Commit

Permalink
Fix Cucumber FFI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
philipr-za committed Feb 4, 2022
1 parent 103cc94 commit d108939
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion integration_tests/helpers/ffi/ffiInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class InterfaceFFI {
this.ptr,
this.ptr,
this.ptr,
this.ptr,
this.boolPtr,
this.intPtr,
],
Expand Down Expand Up @@ -1165,6 +1166,9 @@ class InterfaceFFI {
fn
);
}
static createCallbackConnectivityStatus(fn) {
return ffi.Callback(this.void, [this.ulonglong], fn);
}
//endregion

static walletCreate(
Expand All @@ -1186,7 +1190,8 @@ class InterfaceFFI {
callback_txo_validation_complete,
callback_balance_updated,
callback_transaction_validation_complete,
callback_saf_message_received
callback_saf_message_received,
callback_connectivity_status
) {
let error = this.initError();
let recovery_in_progress = this.initBool();
Expand Down
13 changes: 12 additions & 1 deletion integration_tests/helpers/ffi/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Wallet {
callback_balance_updated;
callback_transaction_validation_complete;
callback_saf_message_received;
callback_connectivity_status;
recoveryProgressCallback;

getTxoValidationStatus() {
Expand Down Expand Up @@ -141,6 +142,10 @@ class Wallet {
this.recoveryProgressCallback = InterfaceFFI.createRecoveryProgressCallback(
this.onRecoveryProgress
);
this.callback_connectivity_status =
InterfaceFFI.createCallbackConnectivityStatus(
this.onConnectivityStatusChange
);
//endregion

this.receivedTransaction = 0;
Expand Down Expand Up @@ -180,7 +185,8 @@ class Wallet {
this.callback_txo_validation_complete,
this.callback_balance_updated,
this.callback_transaction_validation_complete,
this.callback_saf_message_received
this.callback_saf_message_received,
this.callback_connectivity_status
);
}

Expand Down Expand Up @@ -328,6 +334,10 @@ class Wallet {
return InterfaceFFI.walletIsRecoveryInProgress(this.ptr);
}

onConnectivityStatusChange = (status) => {
console.log("Connectivity Status Changed to ", status);
};

getPublicKey() {
let ptr = InterfaceFFI.walletGetPublicKey(this.ptr);
let pk = new PublicKey();
Expand Down Expand Up @@ -463,6 +473,7 @@ class Wallet {
this.callback_transaction_validation_complete =
this.callback_saf_message_received =
this.recoveryProgressCallback =
this.callback_connectivity_status =
undefined; // clear callback function pointers
}
}
Expand Down

0 comments on commit d108939

Please sign in to comment.