stellar / js-stellar-sdk

Main Stellar client library for the JavaScript language.
https://stellar.github.io/js-stellar-sdk/
Apache License 2.0
628 stars 311 forks source link

fix: performing 2nd swap not working #986

Closed chadoh closed 3 months ago

chadoh commented 3 months ago

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.

See the failing test here on CI:

  1) Swap Contract Tests
       can swap 2nd time:

      AssertionError: expected [] to have a length of 2 but got +0
      + expected - actual

      -0
      +2

      at Context.<anonymous> (test/e2e/src/test-swap.js:160:46)
BlaineHeffron commented 3 months ago

Fixed by increasing the starting token balance. The issue was that when the swap was constructed, it would simulate and the simulation would fail so the auth entries never got added to the transaction. Simulation would fail when it tried to simulate a transfer of tokens but the balance was not enough.

chadoh commented 3 months ago

ohhhh 🤦🏼

ok, good to know that there's no order dependency. Should have checked for a simulation error right away.