-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: almost complete ffi wallet test (#3220)
<!--- Provide a general summary of your changes in the Title above --> ## Description Almost complete ffi wallet test. - The async base node connection is not there. - The SAF test is broken (the ffi wallet doesn't change the status, but the receiver node has correct status) ## How Has This Been Tested? npm test -- .\features\WalletFFI.feature ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> * [x] I'm merging against the `development` branch. * [x] I have squashed my commits into a single commit.
- Loading branch information
Showing
18 changed files
with
1,131 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const WalletFFI = require("./walletFFI"); | ||
|
||
class ByteVector { | ||
#byte_vector_ptr; | ||
|
||
constructor(byte_vector_ptr) { | ||
this.#byte_vector_ptr = byte_vector_ptr; | ||
} | ||
|
||
static async fromBuffer(buffer) { | ||
let buf = Buffer.from(buffer, "utf-8"); // get the bytes | ||
let len = buf.length; // get the length | ||
return new ByteVector(await WalletFFI.byteVectorCreate(buf, len)); | ||
} | ||
|
||
getLength() { | ||
return WalletFFI.byteVectorGetLength(this.#byte_vector_ptr); | ||
} | ||
|
||
getAt(position) { | ||
return WalletFFI.byteVectorGetAt(this.#byte_vector_ptr, position); | ||
} | ||
|
||
destroy() { | ||
return WalletFFI.byteVectorDestroy(this.#byte_vector_ptr); | ||
} | ||
} | ||
|
||
module.exports = ByteVector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const WalletFFI = require("./walletFFI"); | ||
|
||
class CompletedTransaction { | ||
#tari_completed_transaction_ptr; | ||
|
||
constructor(tari_completed_transaction_ptr) { | ||
this.#tari_completed_transaction_ptr = tari_completed_transaction_ptr; | ||
} | ||
|
||
isOutbound() { | ||
return WalletFFI.completedTransactionIsOutbound( | ||
this.#tari_completed_transaction_ptr | ||
); | ||
} | ||
|
||
destroy() { | ||
return WalletFFI.completedTransactionDestroy( | ||
this.#tari_completed_transaction_ptr | ||
); | ||
} | ||
} | ||
|
||
module.exports = CompletedTransaction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const CompletedTransaction = require("./completedTransaction"); | ||
const WalletFFI = require("./walletFFI"); | ||
|
||
class CompletedTransactions { | ||
#tari_completed_transactions_ptr; | ||
|
||
constructor(tari_completed_transactions_ptr) { | ||
this.#tari_completed_transactions_ptr = tari_completed_transactions_ptr; | ||
} | ||
|
||
static async fromWallet(wallet) { | ||
return new CompletedTransactions( | ||
await WalletFFI.walletGetCompletedTransactions(wallet) | ||
); | ||
} | ||
|
||
getLength() { | ||
return WalletFFI.completedTransactionsGetLength( | ||
this.#tari_completed_transactions_ptr | ||
); | ||
} | ||
|
||
async getAt(position) { | ||
return new CompletedTransaction( | ||
await WalletFFI.completedTransactionsGetAt( | ||
this.#tari_completed_transactions_ptr, | ||
position | ||
) | ||
); | ||
} | ||
|
||
destroy() { | ||
return WalletFFI.completedTransactionsDestroy( | ||
this.#tari_completed_transactions_ptr | ||
); | ||
} | ||
} | ||
|
||
module.exports = CompletedTransactions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const PublicKey = require("./publicKey"); | ||
const WalletFFI = require("./walletFFI"); | ||
|
||
class Contact { | ||
#tari_contact_ptr; | ||
|
||
constructor(tari_contact_ptr) { | ||
this.#tari_contact_ptr = tari_contact_ptr; | ||
} | ||
|
||
getPtr() { | ||
return this.#tari_contact_ptr; | ||
} | ||
|
||
async getAlias() { | ||
const alias = await WalletFFI.contactGetAlias(this.#tari_contact_ptr); | ||
const result = alias.readCString(); | ||
await WalletFFI.stringDestroy(alias); | ||
return result; | ||
} | ||
|
||
async getPubkey() { | ||
return new PublicKey( | ||
await WalletFFI.contactGetPublicKey(this.#tari_contact_ptr) | ||
); | ||
} | ||
|
||
destroy() { | ||
return WalletFFI.contactDestroy(this.#tari_contact_ptr); | ||
} | ||
} | ||
|
||
module.exports = Contact; |
Oops, something went wrong.