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

SEP-38: update SEP-38 tests based on stellar/stellar-protocol#1204 #86

Merged
merged 7 commits into from
Jun 3, 2022

Conversation

marcelosalloum
Copy link
Contributor

@marcelosalloum marcelosalloum commented May 26, 2022

What

Update SEP-38 tests based on stellar/stellar-protocol#1204. The changes include:

  • SEP-38 GET /price and POST /quote now require the mandatory context request parameter.
  • SEP-38 GET /price and GET|POST /quote now return the mandatory response parameters total_price and fee.
  • The updated formulas from SEP38#price-formulas are now being validated.

@stellar-jenkins
Copy link

1 similar comment
@stellar-jenkins
Copy link

@stellar-jenkins
Copy link

Comment on lines +124 to +128

const notValidFiat = parts.length === 2 && parts[0] !== "iso4217";
const notValidStellar = parts.length === 3 && parts[0] !== "stellar";
const notValidAtAll = parts.length < 2 || parts.length > 3;
if (notValidFiat || notValidStellar || notValidAtAll) {
Copy link
Contributor Author

@marcelosalloum marcelosalloum May 27, 2022

Choose a reason for hiding this comment

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

I made this change because since stellar/stellar-protocol#1149, SEP-31 accepts delivering on-chain access as well.

@marcelosalloum marcelosalloum marked this pull request as ready for review May 27, 2022 19:53
@marcelosalloum marcelosalloum changed the title [WIP] Update SEP-38 tests based on stellar/stellar-protocol#1204 SEP-38: update SEP-38 tests based on stellar/stellar-protocol#1204 May 27, 2022
Copy link
Contributor

@lijamie98 lijamie98 left a comment

Choose a reason for hiding this comment

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

I am not a expert in TS. But LGTM.

Copy link
Contributor

@JakeUrban JakeUrban left a comment

Choose a reason for hiding this comment

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

A couple questions, but everything else looks good to me.

@@ -78,6 +81,7 @@ export const returnsValidResponse: Test = {
sell_asset: this.context.expects.sep38StellarAsset,
buy_asset: this.context.expects.sep38OffChainAsset,
sell_amount: "100",
context: "sep31",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is tough, because an anchor could support SEP-38 for SEP-6, and we'd be sending an invalid context value. Maybe we should add a config attribute that allows the user to indicate which context value should be used? Or maybe we can infer which value to use based on the tests being run?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, did we update the config file info displayed in the UI after adding SEP-38 support? Or does SEP-38 not require any config currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sep38 doesn't require any context at the moment. I'll add the context in the next PR and make it configurable in the sep config.

@marcelosalloum marcelosalloum merged commit faec7ae into master Jun 3, 2022
@marcelosalloum marcelosalloum deleted the sep38-fee-details branch June 3, 2022 00:55
marcelosalloum added a commit that referenced this pull request Jun 10, 2022
…e tested (#87)

### What
SEP-38 now requires a config file to indicate which contexts should be tested.

Also, update some SEP-38 tests to execute the request once for each context.

### Why
The SEP-38 `GET /price` and `POST /quote` request parameters have a new mandatory field called `context`, that can be set to "sep6" or "sep31". With the new configuration file, Anchors can choose which context(s) should be used in the tests.

Addresses #86 (comment).

### Pending
* Update documentation. I'll do that in another PR so it's easier to review.
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.

4 participants