Skip to content

Commit

Permalink
fix: performing 2nd swap not working
Browse files Browse the repository at this point in the history
The test added here is copying the first few steps of the previous test,
"alice swaps bob 10 A for 1 B". For some reason, the second time you
simulate this transaction, it is calculating that no non-invoker signing
is needed! Haven't figured out why yet.

Note that this is an order-dependent test. The new one only functions as
expected because mocha runs the tests in the same order every time.
  • Loading branch information
chadoh committed Jun 7, 2024
1 parent e5e49dc commit d7fbc00
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/e2e/src/test-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,22 @@ describe("Swap Contract Tests", function () {
expect(bobTokenABalance.result).to.equal(amountAToSwap);
expect(bobTokenBBalance.result).to.equal(0n);
});

it("can swap 2nd time", async function() {
const tx = await this.context.swapContractAsRoot.swap({
a: this.context.alice.publicKey(),
b: this.context.bob.publicKey(),
token_a: this.context.tokenAId,
token_b: this.context.tokenBId,
amount_a: amountAToSwap,
min_a_for_b: amountAToSwap,
amount_b: amountBToSwap,
min_b_for_a: amountBToSwap,
});

const needsNonInvokerSigningBy = await tx.needsNonInvokerSigningBy();
expect(needsNonInvokerSigningBy).to.have.lengthOf(2);
expect(needsNonInvokerSigningBy.indexOf(this.context.alice.publicKey())).to.equal(0, "needsNonInvokerSigningBy does not have alice's public key!");
expect(needsNonInvokerSigningBy.indexOf(this.context.bob.publicKey())).to.equal(1, "needsNonInvokerSigningBy does not have bob's public key!");
});
});

0 comments on commit d7fbc00

Please sign in to comment.