Skip to content

Commit

Permalink
test(e2e): keypair
Browse files Browse the repository at this point in the history
  • Loading branch information
od-hunter committed Dec 27, 2024
1 parent 810e8cf commit a7abadd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions test/e2e/src/test-non-invoker-signing-by-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ describe("cross-contract auth", function () {
async () => await this.context.tx.sign({ force: true }),
).to.not.throw();
});

it("signs transaction using Keypair", async function () {
const result = await this.context.tx.sign({
signTransaction: this.context.keypair,
force: true,
});
expect(result).to.be.undefined;
});


it("signs transaction using basicNodeSigner", async function () {
const signer = contract.basicNodeSigner(this.context.keypair, "Standalone Network ; February 2017");
const result = await this.context.tx.sign({
signTransaction: signer.signTransaction,
force: true,
});
expect(result).to.be.undefined;
});
});

describe("signAuthEntries with custom authorizeEntry", function () {
Expand Down
8 changes: 5 additions & 3 deletions test/e2e/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ module.exports.generateFundedKeypair = generateFundedKeypair;
*/
async function clientFor(name, { keypair, contractId } = {}) {
const internalKeypair = keypair ?? (await generateFundedKeypair());
const signer = contract.basicNodeSigner(internalKeypair, networkPassphrase);

// Pass the Keypair directly instead of using basicNodeSigner
const signer = internalKeypair; // Use Keypair directly

if (contractId) {
return {
Expand All @@ -99,7 +101,7 @@ async function clientFor(name, { keypair, contractId } = {}) {
rpcUrl,
allowHttp: true,
publicKey: internalKeypair.publicKey(),
...signer,
signTransaction: signer, // Pass Keypair here
}),
contractId,
keypair,
Expand All @@ -118,7 +120,7 @@ async function clientFor(name, { keypair, contractId } = {}) {
allowHttp: true,
wasmHash: wasmHash,
publicKey: internalKeypair.publicKey(),
...signer,
signTransaction: signer, // Pass Keypair here
},
);
const { result: client } = await deploy.signAndSend();
Expand Down

0 comments on commit a7abadd

Please sign in to comment.