Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: performing 2nd swap not working #986

Closed
wants to merge 9 commits into from

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Jun 7, 2024

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)

chadoh and others added 9 commits June 7, 2024 15:51
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.
Adds a toXDR and fromXDR for AssembledTransaction class. 
Also adds a txFromXDR to the Client class. 
Changes the swap test to use this flow.

Limitations: If you use the XDR multi-auth flow, you must re-simulate 
before the final `signAndSend` call. This is due to the fact that we can't 
serialize the XDR of the transaction envelope with the results of the 
simulation. If we want to do this, we would need to add an 
`AssembledTransaction` type to XDR in `stellar-base`.
---------

Co-authored-by: George <[email protected]>
The new test added here shows that you can edit a transaction with
`tx.raw = cloneFrom(tx.build)` and that the `tx.simulationData` will be
updated correctly.
Co-authored-by: Chad Ostrowski <[email protected]>
Co-authored-by: blaineheffron <[email protected]>
Co-authored-by: George <[email protected]>
…ion` (stellar#992)

* add auto restore functionality for contract client
* extract getAccount to utils
* add changelog entry for auto restore functionality

Co-authored-by: Chad Ostrowski <[email protected]>
Co-authored-by: blaineheffron <[email protected]>
* Upgrade dev dependencies
* Upgrade stellar-base to latest version
@BlaineHeffron
Copy link
Contributor

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
Copy link
Contributor Author

chadoh commented Jun 20, 2024

ohhhh 🤦🏼

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

@chadoh chadoh closed this Jun 20, 2024
@chadoh chadoh deleted the fix/swap-twice branch June 20, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants