Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Add relay unit tests and e2e #338

Merged
merged 107 commits into from
Apr 16, 2024
Merged

Add relay unit tests and e2e #338

merged 107 commits into from
Apr 16, 2024

Conversation

zhongeric
Copy link
Collaborator

@zhongeric zhongeric commented Jan 23, 2024

This PR wires up relay quotes into the existing handlers and adds e2e tests. I've kept the traditional style of integration tests (fetch quote, execute calldata, check amounts) because we are generating universal router calldata within URA for relay quotes and its important that it's generated correctly. These integration tests require that and should also not be very flaky as they are only between USDC and USDT and check min/max values.

Other changes:

  • Add schema and joi validation for relay quotes
  • Add quote selection logic for relay quotes (relay always better than classic, as it is a wrapper over the same quote), and we use normal comparison logic for relay vs. dutch (better amount out)

Base automatically changed from relay-quotes to main April 4, 2024 19:41
Copy link
Collaborator

@codyborn codyborn left a comment

Choose a reason for hiding this comment

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

Looks good! Minor nits

expect(parseInt(order.info.input.amount.toString())).to.be.greaterThan(90000000);
expect(parseInt(order.info.input.amount.toString())).to.be.lessThan(110000000);

const { tokenInBefore, tokenInAfter, tokenOutBefore, tokenOutAfter } = await baseTest.executeRelaySwap(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We wanted to avoid on-chain integ tests here as they tend to be flaky and slow - can we move these to SDK integ instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah I had that thought too but I think we need tests here to test that the calldata for UR is being built correctly - there's not a great way to test that in the SDK level because the classic quote (which the calldata) is generated from is only available at the quote level within URA. Also, we don't mainnet fork for the SDK integ tests so we'd have to do that.

I kept these e2e tests simple and short - only two cases, and both doing stable to stable with reasonable bounds. I'll remove the checks that the input amounts are within an explicit range so the only remaining checks are relative

Copy link
Collaborator

@marktoda marktoda left a comment

Choose a reason for hiding this comment

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

awesome, logic generally lgtm

@zhongeric zhongeric merged commit ef841e5 into main Apr 16, 2024
6 checks passed
@zhongeric zhongeric deleted the relay-quotes-tests branch April 16, 2024 18:22
jsy1218 pushed a commit that referenced this pull request Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants