Skip to content

Commit

Permalink
Send subaccount messages for child.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau committed May 7, 2024
1 parent 5c25763 commit 3319ca9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion indexer/services/socks/__tests__/lib/message-forwarder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { dbHelpers, testMocks, perpetualMarketRefresher } from '@dydxprotocol-in
import {
btcClobPairId,
btcTicker,
defaultChildSubaccountId,
defaultSubaccountId,
ethClobPairId,
ethTicker,
Expand Down Expand Up @@ -64,6 +65,15 @@ describe('message-forwarder', () => {
version: SUBACCOUNTS_WEBSOCKET_MESSAGE_VERSION,
};

const childSubaccountMessage: SubaccountMessage = {
blockHeight: '2',
transactionIndex: 2,
eventIndex: 2,
contents: '{}',
subaccountId: defaultChildSubaccountId,
version: SUBACCOUNTS_WEBSOCKET_MESSAGE_VERSION,
}

const btcTradesMessages: TradeMessage[] = [
{
...baseTradeMessage,
Expand Down Expand Up @@ -123,6 +133,17 @@ describe('message-forwarder', () => {
},
];

const childSubaccountMessages: SubaccountMessage[] = [
{
...childSubaccountMessage,
contents: JSON.stringify({ val: '1' }),
},
{
...childSubaccountMessage,
contents: JSON.stringify({ val: '2' }),
},
]

const mockAxiosResponse: Object = { a: 'b' };
const subaccountInitialMessage: Object = {
...mockAxiosResponse,
Expand Down Expand Up @@ -358,7 +379,7 @@ describe('message-forwarder', () => {
);

// await each message to ensure they are sent in order
for (const subaccountMessage of subaccountMessages) {
for (const subaccountMessage of childSubaccountMessages) {
await producer.send({
topic: WebsocketTopics.TO_WEBSOCKETS_SUBACCOUNTS,
messages: [{
Expand Down

0 comments on commit 3319ca9

Please sign in to comment.