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

Add integration tests against the real mock API server #697

Merged
merged 7 commits into from
Sep 2, 2021
Merged

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Sep 1, 2021

I realized that by copy-pasting responses from the mock server and hardcoding URLs, we weren't exactly testing things properly end-to-end. I added some "true" integration tests to hit the APIary server.

@Shaptic Shaptic added the amm label Sep 1, 2021
@Shaptic Shaptic self-assigned this Sep 1, 2021
@Shaptic
Copy link
Contributor Author

Shaptic commented Sep 1, 2021

I'm not 100% sure we should include this in the final release, but I think it's a great, reliable way to sanity-check that we're fulfilling API contracts for the mock endpoints.

@marcelosalloum
Copy link
Contributor

marcelosalloum commented Sep 2, 2021

I'm not 100% sure we should include this in the final release, but I think it's a great, reliable way to sanity-check that we're fulfilling API contracts for the mock endpoints.

We should add a ticket to update these tests to point to testnet (or futurenet) when we have a live version of Horizon running protocol 18.

This means the tests would probably need to create some of the content (accounts, assets and liquidity pools) if it doesn't exist.

Copy link
Contributor

@marcelosalloum marcelosalloum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I've left a few comments below, nothing critical.

Comment on lines 85 to 88
expect(isSubsetOf(
Object.keys(record),
Object.keys(res.body._embedded.records[i])
)).to.be.true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Sorry if I didn't understand the comment very well but why are we only testing the keys and ignoring the values? Lodash has a method that does that for you (if that is an option) (ref)

Copy link
Contributor Author

@Shaptic Shaptic Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the lodash reference! Because the values won't always be equal due to the fact that responses aren't a 1-to-1 mapping. For example, TransactionRecord.ledger -> a LedgerCallBuilder, while the JSON's .ledger is an integer. This is only true for transactions, though, so I've updated the tests to work around that in f9330af.

@Shaptic Shaptic merged commit 34e8752 into v9.0.0 Sep 2, 2021
@Shaptic Shaptic deleted the integration branch September 2, 2021 16:34
Shaptic added a commit that referenced this pull request Sep 2, 2021
* Use stellar-base 6.0.1 from the npm registry.
* Correctly process transaction response for offers based on XDR changes (#681)
* Adds a basic call builder for the `/liquidity_pools` endpoint. (#682)
* Add call builder for liquidity pools, w/ filters by reserve asset
* Update TradesCallBuilder to accept the trade_type filter and support Liquidity Pool trades (#685)
* [CD/CI] Add GitHub Actions to run tests on PRs (#686)
* Support filtering accounts participating in a given LP and update accounts balance response (#688)
* Allow querying a single liquidity pool by its specific ID. (#687)
* Allow querying actions (ops, txs, fx) related to a specific liquidity pool. (#689)
* Add new effect types (#690)
* Refactors call builders to simplify referencing 'neighbor' endpoints (#691)
* Update with CAP-38 operations (#692)
* Simplifies an expression to be more readable (#695)
* Updates the CHANGELOG to be more uniform and specific. (#694)
* Fix how the ?reserves filter works on the /accounts endpoint (#698)
* Update more call builders to use the new helper API. (#699)
* Add integration tests against the real mock API server (#697)
* Prepares the v9.0.0 branch for merging into master (#701)
* Update Horizon API fields to reflect the coming post-AMM API (#702)

Co-authored-by: Marcelo Salloum dos Santos <[email protected]>
Co-authored-by: George <[email protected]>
Co-authored-by: George Kudrayvtsev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants