Skip to content

Commit

Permalink
DF-20728 Tiingo uppercase (#3542)
Browse files Browse the repository at this point in the history
* DF-20728 force uppercase assets on tiingo lwba and crypto endpoints

* add changeset

* undo crypto endpoint since there are no current issues

* update test

---------

Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3f3d59c commit ef5dfa4
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-grapes-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/tiingo-adapter': patch
---

Force uppercase assets on cryptolwba endpoint
6 changes: 6 additions & 0 deletions packages/sources/tiingo/src/endpoint/crypto-lwba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ export const endpoint = new LwbaEndpoint({
transport,
inputParameters: inputParameters,
overrides: overrides.tiingo,
requestTransforms: [
(req) => {
req.requestContext.data.base = req.requestContext.data.base.toUpperCase()
req.requestContext.data.quote = req.requestContext.data.quote.toUpperCase()
},
],
})
1 change: 1 addition & 0 deletions packages/sources/tiingo/src/endpoint/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { config } from '../config'
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
import { priceEndpointInputParametersDefinition } from '@chainlink/external-adapter-framework/adapter'
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'

export const inputParameters = new InputParameters(priceEndpointInputParametersDefinition, [
{
base: 'ETH',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ exports[`websocket crypto endpoint should return success 1`] = `
}
`;

exports[`websocket crypto_lwba endpoint should only subscribe once 1`] = `
{
"data": {
"ask": 1794.2063137650225,
"bid": 1793.6242715443277,
"mid": 1793.915292654675,
},
"result": null,
"statusCode": 200,
"timestamps": {
"providerDataReceivedUnixMs": 2028,
"providerDataStreamEstablishedUnixMs": 2020,
"providerIndicatedTimeUnixMs": 1680187094577,
},
}
`;

exports[`websocket crypto_lwba endpoint should only subscribe once 2`] = `
{
"data": {
"ask": 1794.2063137650225,
"bid": 1793.6242715443277,
"mid": 1793.915292654675,
},
"result": null,
"statusCode": 200,
"timestamps": {
"providerDataReceivedUnixMs": 2028,
"providerDataStreamEstablishedUnixMs": 2020,
"providerIndicatedTimeUnixMs": 1680187094577,
},
}
`;

exports[`websocket crypto_lwba endpoint should return error (invariant violation) 1`] = `
{
"error": {
Expand Down
21 changes: 21 additions & 0 deletions packages/sources/tiingo/test/integration/adapter-ws.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from './fixtures'
import { WebSocketClassProvider } from '@chainlink/external-adapter-framework/transports'
import FakeTimers from '@sinonjs/fake-timers'
import * as lwbaTransport from '../../src/transport/crypto-lwba'
import * as lwbaEndpoint from '../../src/endpoint/crypto-lwba'

describe('websocket', () => {
let mockWsServerCrypto: MockWebsocketServer | undefined
Expand Down Expand Up @@ -100,6 +102,25 @@ describe('websocket', () => {
const response = await testAdapter.request(spreadData)
expect(response.json()).toMatchSnapshot()
})
it('should only subscribe once', async () => {
const lwbaDataLowercase = {
endpoint: 'crypto_lwba',
base: 'eth',
quote: 'usd',
}
const lwbaDataUppercase = {
endpoint: 'crypto_lwba',
base: 'ETH',
quote: 'USD',
}
const response1 = await testAdapter.request(lwbaDataLowercase)
expect(response1.json()).toMatchSnapshot()

const response2 = await testAdapter.request(lwbaDataUppercase)
expect(response2.json()).toMatchSnapshot()

expect(lwbaTransport.transport.subscriptionSet.getAll()).toHaveLength(1)
})
it('should return error (invariant violation)', async () => {
// fast forward to next message (which contains an invariant violation)
testAdapter.clock.tick(5000)
Expand Down

0 comments on commit ef5dfa4

Please sign in to comment.