Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Pre-Order Validation #1169

Merged
merged 2 commits into from
Sep 30, 2021
Merged

Pre-Order Validation #1169

merged 2 commits into from
Sep 30, 2021

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Sep 29, 2021

In Preparation for the new Fee and Quote endpoint (cf #1155) we shift some of the order validation into its own file (to be shared among both Orderbook.add_order and the QuoteRequest endpoint). More specifically, we move all order validations pertaining to the buy/sell tokens, order validity, balance sources and destinations, banned users, and transfer eth to contract into their own PreOrderValidator. Any order validations regarding balance or fee sufficiency and signature validity remain in the Orderbook.add_order method.

Test Plan

This is a refactor although I have added some tests to the new method validate_partial_order

@bh2smith bh2smith requested a review from a team September 29, 2021 10:33
@codecov-commenter
Copy link

Codecov Report

Merging #1169 (53bd145) into main (d958a26) will increase coverage by 0.11%.
The diff coverage is 59.81%.

@@            Coverage Diff             @@
##             main    #1169      +/-   ##
==========================================
+ Coverage   66.63%   66.74%   +0.11%     
==========================================
  Files         134      135       +1     
  Lines       26843    27025     +182     
==========================================
+ Hits        17886    18039     +153     
- Misses       8957     8986      +29     

Comment on lines 69 to 75
owner: H160,
sell_token: H160,
buy_token: H160,
receiver: H160,
valid_to: u32,
buy_token_balance: BuyTokenDestination,
sell_token_balance: SellTokenSource,
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want all of these pub too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea good call, I made these all public in the next PR, but I can do it here in favour of less changes in the next one.

}

#[tokio::test]
async fn validate_partial_order_err() {
Copy link
Contributor

Choose a reason for hiding this comment

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

One underrated feature of this refactor is the ability to test order validation better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps in a follow up PR, I can make a similar method for the other parts of order validation.

Copy link
Contributor

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

Love it.

@bh2smith bh2smith merged commit efb7428 into main Sep 30, 2021
@bh2smith bh2smith deleted the orderbook-interface branch September 30, 2021 08:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants