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 generic order type test suite #86

Merged
merged 31 commits into from
Feb 2, 2023
Merged

Add generic order type test suite #86

merged 31 commits into from
Feb 2, 2023

Conversation

zhongeric
Copy link
Collaborator

@zhongeric zhongeric commented Jan 17, 2023

Fix #83

@zhongeric zhongeric changed the title [WIP] Add test for NonceReuse to DLO reactor test [WIP] Add generic order type test suite #83 Jan 17, 2023
@zhongeric zhongeric changed the title [WIP] Add generic order type test suite #83 [WIP] Add generic order type test suite Jan 17, 2023
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.

looks great! just a few thoughts

test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Show resolved Hide resolved

MockERC20 tokenIn;
MockERC20 tokenOut;
MockFillContract fillContract;
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to note, and maybe this can be a different suite but we could test different fillContract strategies in a generic way as well. Would be nice to be sure that the matrix of [reactorType, fillContract] all works properly together

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 that would be cool, I'll look into that - what fillContracts do we have so far? Is it just DirectTaker and UniV3Executor?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yup

Copy link
Collaborator

Choose a reason for hiding this comment

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

but we def need to add a UR executor and maybe like order matching logic?

test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/reactors/DutchLimitOrderReactor.t.sol Outdated Show resolved Hide resolved
test/reactors/DutchLimitOrderReactor.t.sol Outdated Show resolved Hide resolved
@zhongeric zhongeric changed the title [WIP] Add generic order type test suite Add generic order type test suite Jan 30, 2023
@zhongeric zhongeric marked this pull request as ready for review January 30, 2023 21:26
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
vm.expectEmit(false, false, false, true, address(reactor));
emit Fill(orderHash, address(this), maker, orderInfo.nonce);
// execute order
snapStart(string.concat(name(), "BaseExecuteSingle"));
Copy link
Member

Choose a reason for hiding this comment

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

sweet, love the customized name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mark's genius work

test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Show resolved Hide resolved
test/base/BaseReactor.t.sol Outdated Show resolved Hide resolved
test/base/BaseReactor.t.sol Show resolved Hide resolved
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.

looking good to me! agree w/ saras comments tho


MockERC20 tokenIn;
MockERC20 tokenOut;
MockFillContract fillContract;
Copy link
Collaborator

Choose a reason for hiding this comment

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

yup


MockERC20 tokenIn;
MockERC20 tokenOut;
MockFillContract fillContract;
Copy link
Collaborator

Choose a reason for hiding this comment

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

but we def need to add a UR executor and maybe like order matching logic?

Copy link
Member

@snreynolds snreynolds left a comment

Choose a reason for hiding this comment

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

lgtm, not sure about @marktoda's comments though

import {Test} from "forge-std/Test.sol";
import "forge-std/console.sol";
Copy link
Member

Choose a reason for hiding this comment

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

can remove any console imports before merge

zhongeric and others added 18 commits February 2, 2023 13:27
* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* add snapshot

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testTwoOrders

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* comment

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write `testFillerHasInsufficientOutput`

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* fix merge main

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testSingleOrderWithFee

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testThreeOrdersWithFees()

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* remove code duplication

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make permit2 an address that needs to be casted to appropriate interface

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make DIRECT_TAKER_FILL constant

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testFillerLacksApproval()

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make DIRECT_TAKER_FILL and internal variable

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* use SafeCast.toUint160

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* delete DirectTakerExecutor.t.sol

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

---------

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>
@zhongeric zhongeric merged commit 9b6b759 into main Feb 2, 2023
willpote pushed a commit that referenced this pull request Jul 17, 2023
* Add test for NonceReuse to DLO reactor test

* Ok have something, testExecute in baseTest passes, but only limit order specific rn

* remove comment

* Change to createAndSignOrder and use abiEncodedOrder in base tests

* Add signature replay base test

* Add inputAmount, outputAmount to createAndSignOrder

* Add base prefix to BaseReactorTest

* Remove extra createReactor call

* Add test for BaseExecuteBatch, and createAndSignBatchOrders

* Clean up and add comments

* Refactor createSginOrder to return SignedOrder and other resolved comments

* Remove virtual from base tests

* Allow specification of OrderInfo in generic func

* compiles!

* Update gas snaps

* Add NonceReuse base test

* Add comments

* Add comments

* Remove nonceReuse from dutchLimit

* forge fmt

* Revisions, and add ArrayBuilder to create 1d and 2d arays easier

* Add support in LimitOrderReactor.t.sol for batch orders with multiple outputs

* Direct taker macro (#77)

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* add snapshot

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testTwoOrders

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* continue

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* comment

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write `testFillerHasInsufficientOutput`

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* fix merge main

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testSingleOrderWithFee

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testThreeOrdersWithFees()

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* remove code duplication

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make permit2 an address that needs to be casted to appropriate interface

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make DIRECT_TAKER_FILL constant

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* write testFillerLacksApproval()

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* make DIRECT_TAKER_FILL and internal variable

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* use SafeCast.toUint160

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* delete DirectTakerExecutor.t.sol

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

---------

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>

* udpate gas snap

* Remove redundant testExecutebatch

* remove old gas snap

* change func in lib type to internal

* remove unused initNested

* Remove console import and sign

* add .gitignore

---------

Signed-off-by: Allen Lin <allenlin1992@hotmail.com>
Co-authored-by: AzFlin <allenlin1992@hotmail.com>
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.

Add order type generic test suite
4 participants