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

Let SEP-31 POST transaction depend on SEP-38 POST quote #90

Merged
merged 2 commits into from
Jun 28, 2022

Conversation

erika-sdf
Copy link
Contributor

Specify quote_id in transaction POST request.

@erika-sdf erika-sdf requested a review from marcelosalloum June 16, 2022 21:37
@stellar-jenkins
Copy link

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.

The code looks great but there are a few edge cases that make your change tricky and not safe for deployment. I'm explaining that in the comment below:

@@ -55,13 +56,15 @@ const canCreateTransaction: Test = {
hasDirectPaymentServer,
hasExpectedAssetEnabled,
differentMemosSameAccount,
canCreateQuote,
Copy link
Contributor

@marcelosalloum marcelosalloum Jun 17, 2022

Choose a reason for hiding this comment

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

The code looks great but there are a few edge cases that make your change tricky and not safe for deployment:

  1. There are Anchors that only implement SEP-31 without implementing SEP-38. In those cases, the dependency canCreateQuote will fail, as well as this whole sep31 test. You'll need to create a new set of tests that covers anchors implementing both SEP-31+SEP-38. You should create a new file for these tests and decide to add it to the list of tests here:
    if (config.seps.includes(31)) {
    tests = tests.concat(sep31Tests);
    }
    if (config.seps.includes(38)) {
    tests = tests.concat(sep38Tests);
    }
  • EDIT: you should check for quotes_supported: true in the SEP-31+SEP-38 tests
  1. Additionally, if you want to support anchors with quotes_required: true, you should update the sep31/transactions#canCreateTransaction test by checking if they are required, and if that's the case, make the same request as the code was doing before and validate if the resulting status code is 400.

@JakeUrban: do you have any other input here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the following changes:

  • Added a set of SEP31+SEP38 tests that execute when quotes_supported: true
  • Added a check for quotes_required in SEP31 tests. If it is false, canCreateTransaction and it's dependencies if are executed. If quotes_required: true, canCreateTransaction expects a 400, and its dependencies don't check for anything.

@stellar-jenkins
Copy link

@stellar-jenkins
Copy link

@stellar-jenkins
Copy link

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.

This looks great, we've been needing these tests for quite a bit now. Left a couple comments but nothing blocking.

Comment on lines +134 to +139
// If quotes are required, ignore this test, this will be addressed in SEP 31+38 tests
if (quotesRequired) {
await makeRequest(postTransactionsCall, 400, result, "application/json");
this.context.provides.transactionId = null;
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is testing that if quotes are required, that the POST /transactions call fails with a 400? Maybe we should add a failure mode that describes this, that way its clear to the user why the test failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you're saying, but I think we also don't want this test to fail when it's being used for validation if a 400 is the expected behavior.

Comment on lines +89 to +90
const splitAsset =
this.context.expects.sep38QuoteResponseObj.sell_asset.split(":", 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we verifying the format of this is correct before using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this has been tested.

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!


let assetCode = config.assetCode;
if (assetCode === undefined) {
throw "asset not configured";
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know you could just throw a string like this in javascript. TIL!

@marcelosalloum
Copy link
Contributor

Please don't forget to prepare for a new version shipment by:

  1. Updating the project version, like in https://github.com/stellar/stellar-anchor-tests/pull/85/files
  2. Updating the Changelog, like in https://github.com/stellar/stellar-anchor-tests/pull/80/files

You can do these changes in this same pull request, so you can ship things faster.

After you do that and merge this PR, you just need to create a new release with the. same version number you used in package.json and the same text you used in the changelog.

@stellar-jenkins
Copy link

@erika-sdf erika-sdf merged commit 4bdf48e into master Jun 28, 2022
@erika-sdf erika-sdf deleted the sep31-quotes branch June 28, 2022 21:25
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