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

Allow Close to be sent after any message kind #193

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion packages/http-server/src/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class TbdexHttpServer {
api.use(jsonBodyParser())

this.api = api

}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/src/message-kinds/order-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type CreateOrderStatusOptions = {
*/
export class OrderStatus extends Message {
/** a set of valid Message kinds that can come after an order status */
readonly validNext = new Set<MessageKind>(['orderstatus'])
readonly validNext = new Set<MessageKind>(['orderstatus', 'close'])
/** The message kind (orderstatus) */
readonly kind = 'orderstatus'

Expand Down
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>(['orderstatus'])
readonly validNext = new Set<MessageKind>(['orderstatus', 'close'])
Copy link
Contributor

Choose a reason for hiding this comment

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

we're allowing close right after order?

/** The message kind (order) */
readonly kind = 'order'

Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/tests/exchange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ describe('Exchange', () => {
expect(exchange.orderstatus).to.deep.eq([orderStatus])
})

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

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