Skip to content

Commit

Permalink
improvement: handle invalid gate io futures book ticker messages
Browse files Browse the repository at this point in the history
  • Loading branch information
thaaddeus committed Jun 14, 2022
1 parent eff88ed commit 18623f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mappers/gateiofutures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export class GateIOFuturesBookTickerMapper implements Mapper<'gate-io-futures',
*map(gateIoFuturesBookTickerMessage: GateIOFuturesBookTicker, localTimestamp: Date): IterableIterator<BookTicker> {
const gateIoFuturesBookTicker = gateIoFuturesBookTickerMessage.result

if (gateIoFuturesBookTicker.t === 0) {
return
}
const ticker: BookTicker = {
type: 'book_ticker',
symbol: gateIoFuturesBookTicker.s,
Expand Down Expand Up @@ -245,5 +248,5 @@ type GateIOFuturesBookTicker = {
channel: 'futures.book_ticker'
event: 'update'
error: null
result: { t: 1648771200080; u: 3502782378; s: 'BTC_USD'; b: string; B: number; a: string; A: number }
result: { t: number; u: 3502782378; s: 'BTC_USD'; b: string; B: number; a: string; A: number }
}
2 changes: 2 additions & 0 deletions test/__snapshots__/mappers.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4841,6 +4841,8 @@ Array [
]
`;

exports[`mappers map gate-io-futures messages 18`] = `Array []`;

exports[`mappers map gemini messages 1`] = `
Array [
Object {
Expand Down
8 changes: 8 additions & 0 deletions test/mappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5971,6 +5971,14 @@ describe('mappers', () => {
event: 'update',
error: null,
result: { t: 1648771200080, u: 3502782378, s: 'BTC_USD', b: '45534.7', B: 2500, a: '45534.8', A: 15227 }
},
{
id: null,
time: 1648880663,
channel: 'futures.book_ticker',
event: 'update',
error: null,
result: { t: 0, u: 0, s: 'BSW_USDT', b: '', B: 0, a: '', A: 0 }
}
]
const gateIOFuturesMapper = createMapper('gate-io-futures')
Expand Down

0 comments on commit 18623f1

Please sign in to comment.