Skip to content

Commit

Permalink
Jack/dependabot (#102)
Browse files Browse the repository at this point in the history
* Bump @babel/traverse from 7.21.5 to 7.23.2

Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.21.5 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump ws and @types/ws

Bumps [ws](https://github.com/websockets/ws) and [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws). These dependencies needed to be updated together.

Updates `ws` from 8.13.0 to 8.14.2
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@8.13.0...8.14.2)

Updates `@types/ws` from 8.5.4 to 8.5.6
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: direct:development
  update-type: version-update:semver-minor
- dependency-name: "@types/ws"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @grpc/proto-loader from 0.7.7 to 0.7.10

Bumps [@grpc/proto-loader](https://github.com/grpc/grpc-node) from 0.7.7 to 0.7.10.
- [Release notes](https://github.com/grpc/grpc-node/releases)
- [Commits](https://github.com/grpc/grpc-node/compare/@grpc/[email protected]...@grpc/[email protected])

---
updated-dependencies:
- dependency-name: "@grpc/proto-loader"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump ts-jest from 29.1.0 to 29.1.1

Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 29.1.0 to 29.1.1.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](kulshekhar/ts-jest@v29.1.0...v29.1.1)

---
updated-dependencies:
- dependency-name: ts-jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* dependabot

* Fix README

* Revert "dependabot"

This reverts commit c9aca75.

* Fix dependabot relay tests

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Phillip LeBlanc <[email protected]>
  • Loading branch information
3 people authored Oct 23, 2023
1 parent 6d0d110 commit 63a0512
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 96 deletions.
1 change: 1 addition & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
API_KEY: ${{ secrets.API_KEY }}
RELAY_KEY: ${{ secrets.RELAY_KEY }}
RELAY_SECRET: ${{ secrets.RELAY_SECRET }}
RELAY_URL: ${{ secrets.RELAY_URL }}
publish-npm:
needs: build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
API_KEY: ${{ secrets.API_KEY }}
RELAY_KEY: ${{ secrets.RELAY_KEY }}
RELAY_SECRET: ${{ secrets.RELAY_SECRET }}
RELAY_URL: ${{ secrets.RELAY_URL }}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ const main = async () => {
'recent_blocks',
'SELECT number, "timestamp", gas_used FROM eth.recent_blocks LIMIT 10',
'https://o4skc7qyx7mrl8x7wdtgmc.hooks.webhookrelay.com'
);
).catch((reason) => {
console.error('Query failed.', reason)
});

if (!queryResp.ok) {
console.error('Query failed.', queryResp.status);
if !queryResp {
return;
}

Expand Down
50 changes: 32 additions & 18 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import {
import { LatestPrices } from '../src/interfaces';

const RELAY_BUCKETS = ['spice.js'];
const RELAY_URL = 'https://o4skc7qyx7mrl8x7wdtgmc.hooks.webhookrelay.com';
const RELAY_URL = process.env.RELAY_URL;
if (!RELAY_URL) {
throw 'RELAY_URL environment variable not set';
}

const HTTP_DATA_PATH = process.env.HTTP_URL ? process.env.HTTP_URL : 'https://data.spiceai.io'
const FLIGHT_PATH = process.env.FLIGHT_URL ? process.env.FLIGHT_URL : 'flight.spiceai.io:443'
const HTTP_DATA_PATH = process.env.HTTP_URL
? process.env.HTTP_URL
: 'https://data.spiceai.io';
const FLIGHT_PATH = process.env.FLIGHT_URL
? process.env.FLIGHT_URL
: 'flight.spiceai.io:443';

dotenv.config();
const api_key = process.env.API_KEY;
Expand All @@ -23,13 +30,20 @@ if (!api_key) {
}
const client = new SpiceClient(api_key, HTTP_DATA_PATH, FLIGHT_PATH);
beforeAll(async () => {
let p1 = client.queryAsync('recent_eth_blocks', 'SELECT number, "timestamp", base_fee_per_gas, base_fee_per_gas / 1e9 AS base_fee_per_gas_gwei FROM eth.recent_blocks limit 3', RELAY_URL);
let p2 = client.queryAsync('recent_eth_transactions_paged', `SELECT block_number, transaction_index, "value" FROM eth.recent_transactions limit 1250`, RELAY_URL);
await p1
await p2
let p1 = client.queryAsync(
'recent_eth_blocks',
'SELECT number, "timestamp", base_fee_per_gas, base_fee_per_gas / 1e9 AS base_fee_per_gas_gwei FROM eth.recent_blocks limit 3',
RELAY_URL
);
let p2 = client.queryAsync(
'recent_eth_transactions_paged',
`SELECT block_number, transaction_index, "value" FROM eth.recent_transactions limit 1250`,
RELAY_URL
);
await p1;
await p2;
}, 30000);


const wait = (ms: number) => new Promise((res) => setTimeout(res, ms));

test('streaming works', async () => {
Expand Down Expand Up @@ -151,7 +165,7 @@ test('async query all pages works', async () => {
}, 30000);

test('test latest prices (USD) works', async () => {
let pair='BTC-USD';
let pair = 'BTC-USD';
const price = await client.getLatestPrices([pair]);
const latestPrice = price as LatestPrices;

Expand All @@ -164,7 +178,7 @@ test('test latest prices (USD) works', async () => {
});

test('test latest prices (other currency) works', async () => {
let pair='BTC-AUD';
let pair = 'BTC-AUD';
const price = await client.getLatestPrices([pair]);
const latestPrice = price as LatestPrices;

Expand All @@ -177,48 +191,48 @@ test('test latest prices (other currency) works', async () => {
}, 10000);

test('test historical prices works', async () => {
let pairs=['BTC-USD'];
let pairs = ['BTC-USD'];
const prices = await client.getPrices(
pairs,
new Date('2023-01-01').getTime() / 1000,
new Date('2023-01-02').getTime() / 1000,
'1h'
);

pairs.forEach((v: string) => {
expect(prices[v]).toBeTruthy();
expect(prices[v].length).toEqual(24);

let unixMilli = Math.floor(new Date('2023-01-01T01:00:00Z').getTime());
prices[v].forEach((price, index) => {
expect(new Date(price.timestamp).getTime()).toEqual(unixMilli);
unixMilli += 3600 * 1000
unixMilli += 3600 * 1000;
});

expect(prices[v][0].price).toEqual(16527.39);
expect(prices[v][23].price).toEqual(16612.22);
})
});
}, 10000);

test('test historical prices with multiple pairs', async () => {
let pairs=['BTC-USD', 'ETH-AUD'];
let pairs = ['BTC-USD', 'ETH-AUD'];
const prices = await client.getPrices(
pairs,
new Date('2023-01-01').getTime() / 1000,
new Date('2023-01-02').getTime() / 1000,
'1h'
);

pairs.forEach((v: string) => {
expect(prices[v]).toBeTruthy();
expect(prices[v].length).toEqual(24);

let unixMilli = Math.floor(new Date('2023-01-01T01:00:00Z').getTime());
prices[v].forEach((price, index) => {
expect(new Date(price.timestamp).getTime()).toEqual(unixMilli);
unixMilli += 3600 * 1000
unixMilli += 3600 * 1000;
});
expect(prices[v][0].price).toBeGreaterThan(0.0);
expect(prices[v][23].price).toBeGreaterThan(0.0);
})
});
}, 10000);
Loading

0 comments on commit 63a0512

Please sign in to comment.