Skip to content

Commit

Permalink
Merge branch 'main' into jonfung/UnifiedContextualLogging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfung-dydx committed Jan 4, 2024
2 parents 972670f + 925b3b3 commit 7c7d0d5
Show file tree
Hide file tree
Showing 517 changed files with 6,801 additions and 4,477 deletions.
34 changes: 33 additions & 1 deletion .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,43 @@ pull_request_rules:
backport:
branches:
- release/protocol/v0.3.x
- name: backport to release/indexer/v1.x branch
conditions:
- base=main
- label=backport/indexer/v1.x
actions:
backport:
branches:
- release/indexer/v1.x
- name: backport to release/protocol/v1.x branch
conditions:
- base=main
- label=backport/protocol/v1.x
actions:
backport:
branches:
- release/protocol/v1.x
- release/protocol/v1.x
- name: backport to release/protocol/v2.x branch
conditions:
- base=main
- label=backport/protocol/v2.x
actions:
backport:
branches:
- release/protocol/v2.x
- name: backport to release/indexer/v3.x branch
conditions:
- base=main
- label=backport/indexer/v3.x
actions:
backport:
branches:
- release/indexer/v3.x
- name: backport to release/protocol/v3.x branch
conditions:
- base=main
- label=backport/protocol/v3.x
actions:
backport:
branches:
- release/protocol/v3.x
6 changes: 6 additions & 0 deletions e2e-testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ In another terminal, run
```
pnpm build && pnpm test
```

#### Quickest way to reset the network/clear all Indexer data sources without rebuilding from scratch

```
./reset-network.sh
```
56 changes: 56 additions & 0 deletions e2e-testing/__tests__/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
import {
IPlaceOrder, Order_Side, Order_TimeInForce, OrderFlags,
} from '@dydxprotocol/v4-client-js';
import Long from 'long';

import { OrderDetails } from './types';

export const DYDX_LOCAL_ADDRESS = 'dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4';
export const DYDX_LOCAL_MNEMONIC = 'merge panther lobster crazy road hollow amused security before critic about cliff exhibit cause coyote talent happy where lion river tobacco option coconut small';
export const DYDX_LOCAL_ADDRESS_2 = 'dydx10fx7sy6ywd5senxae9dwytf8jxek3t2gcen2vs';
export const DYDX_LOCAL_MNEMONIC_2 = 'color habit donor nurse dinosaur stable wonder process post perfect raven gold census inside worth inquiry mammal panic olive toss shadow strong name drum';

export const MNEMONIC_TO_ADDRESS: Record<string, string> = {
[DYDX_LOCAL_MNEMONIC]: DYDX_LOCAL_ADDRESS,
[DYDX_LOCAL_MNEMONIC_2]: DYDX_LOCAL_ADDRESS_2,
};

export const ADDRESS_TO_MNEMONIC: Record<string, string> = {
[DYDX_LOCAL_ADDRESS]: DYDX_LOCAL_MNEMONIC,
[DYDX_LOCAL_ADDRESS_2]: DYDX_LOCAL_MNEMONIC_2,
};

export const PERPETUAL_PAIR_BTC_USD: number = 0;
export const quantums: Long = new Long(1_000_000_000);
export const subticks: Long = new Long(1_000_000_000);

export const defaultOrder: IPlaceOrder = {
clientId: 0,
orderFlags: OrderFlags.SHORT_TERM,
clobPairId: PERPETUAL_PAIR_BTC_USD,
side: Order_Side.SIDE_BUY,
quantums,
subticks,
timeInForce: Order_TimeInForce.TIME_IN_FORCE_UNSPECIFIED,
reduceOnly: false,
clientMetadata: 0,
};

export const orderDetails: OrderDetails[] = [
{
mnemonic: DYDX_LOCAL_MNEMONIC,
timeInForce: 0,
orderFlags: 64,
side: 1,
clobPairId: PERPETUAL_PAIR_BTC_USD,
quantums: 10000000,
subticks: 5000000000,
},
{
mnemonic: DYDX_LOCAL_MNEMONIC_2,
timeInForce: 0,
orderFlags: 64,
side: 2,
clobPairId: PERPETUAL_PAIR_BTC_USD,
quantums: 5000000,
subticks: 5000000000,
},
];
9 changes: 9 additions & 0 deletions e2e-testing/__tests__/helpers/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type OrderDetails = {
mnemonic: string;
timeInForce: number;
orderFlags: number;
side: number;
clobPairId: number;
quantums: number;
subticks: number;
};
37 changes: 37 additions & 0 deletions e2e-testing/__tests__/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
import { IPlaceOrder, Network, SocketClient } from '@dydxprotocol/v4-client-js';
import Long from 'long';

import { defaultOrder } from './constants';
import { OrderDetails } from './types';

export async function sleep(milliseconds: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

export function createModifiedOrder(
order: OrderDetails,
): IPlaceOrder {
const modifiedOrder: IPlaceOrder = defaultOrder;
modifiedOrder.clientId = Math.floor(Math.random() * 1000000000);
modifiedOrder.goodTilBlock = 0;
modifiedOrder.clobPairId = order.clobPairId;
modifiedOrder.timeInForce = order.timeInForce;
modifiedOrder.reduceOnly = false;
modifiedOrder.orderFlags = order.orderFlags;
modifiedOrder.side = order.side;
modifiedOrder.quantums = Long.fromNumber(order.quantums);
modifiedOrder.subticks = Long.fromNumber(order.subticks);
return modifiedOrder;
}

export function connectAndValidateSocketClient(validateMessage: Function): void {
const mySocket = new SocketClient(
Network.local().indexerConfig,
() => {},
() => {},
(message) => {
if (typeof message.data === 'string') {
const data = JSON.parse(message.data as string);
validateMessage(data, mySocket);
}
},
);
mySocket.connect();
}
Loading

0 comments on commit 7c7d0d5

Please sign in to comment.