Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Aug 8, 2024
1 parent ff61129 commit 5358454
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/src/message-kinds/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type CreateOrderOptions = {
*/
export class Order extends Message {
/** a set of valid Message kinds that can come after an order */
readonly validNext = new Set<MessageKind>(['orderinstructions'])
readonly validNext = new Set<MessageKind>(['orderinstructions', 'close'])

/** The message kind (order) */
readonly kind = 'order'
Expand Down
15 changes: 11 additions & 4 deletions packages/protocol/tests/exchange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,27 @@ describe('Exchange', () => {
}
})

it('can add an OrderInstructions after Order', async () => {
it('can add an OrderInstructions or a Close after Order', async () => {
const exchange = new Exchange()

exchange.addMessages([rfq, quote, order])

exchange.addNextMessage(orderInstructions)
expect(exchange.orderInstructions).to.deep.eq(orderInstructions)
})

it('cannot add Rfq, Quote, Order, OrderStatus, or Close after Order', async () => {
it('can add a Close after Order', async () => {
const exchange = new Exchange()
exchange.addMessages([rfq, quote, order])

exchange.addNextMessage(closeByPfi)
expect(exchange.close).to.deep.eq(closeByPfi)
})

it('cannot add Rfq, Quote, Order, or OrderStatus after Order', async () => {
const exchange = new Exchange()
exchange.addMessages([rfq, quote, order])

for (const message of [rfq, quote, order, orderStatus, closeByAlice]) {
for (const message of [rfq, quote, order, orderStatus]) {
try {
exchange.addNextMessage(message)
expect.fail()
Expand Down

0 comments on commit 5358454

Please sign in to comment.