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

Added unit test for replacement with an empty order #474

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/perennial-order/test/unit/Manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ describe('Manager', () => {
compareOrders(order, replacement)
})

it('prevents user from replacing with an empty order', async () => {
// submit the original order
await manager.connect(userA).placeOrder(market.address, nextOrderId, MAKER_ORDER)

// user cannot overwrite an order with an empty order (should use cancelOrder instead)
const replacement = {
...DEFAULT_TRIGGER_ORDER,
side: 0,
comparison: 0,
price: 0,
delta: 0,
maxFee: MAX_FEE,
}
await expect(
manager.connect(userA).placeOrder(market.address, nextOrderId, replacement),
).to.be.revertedWithCustomError(manager, 'TriggerOrderInvalidError')
})

it('prevents user from reducing maxFee', async () => {
// submit the original order
await manager.connect(userA).placeOrder(market.address, nextOrderId, MAKER_ORDER)
Expand Down
Loading