aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/test/data_sources
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-12-06 03:08:19 +0800
committerGitHub <noreply@github.com>2018-12-06 03:08:19 +0800
commitb2dd5495bcf13a9ea71498b5def12c75589b0156 (patch)
tree0e0d728d540e747c32a083d604d7916a35ea95cf /packages/pipeline/test/data_sources
parent72a30260d88e722a6b076134693360c573f6c70f (diff)
parente0348f9c044b4909260e4864398b4f50232da620 (diff)
downloaddexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar.gz
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar.bz2
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar.lz
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar.xz
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.tar.zst
dexon-sol-tools-b2dd5495bcf13a9ea71498b5def12c75589b0156.zip
Merge pull request #1377 from 0xProject/feature/pipeline-cleanup-mega-rebase
Merge all pipeline code into development
Diffstat (limited to 'packages/pipeline/test/data_sources')
-rw-r--r--packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts b/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts
new file mode 100644
index 000000000..cb374bbb1
--- /dev/null
+++ b/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts
@@ -0,0 +1,47 @@
+import * as chai from 'chai';
+import 'mocha';
+import * as R from 'ramda';
+
+import { CryptoCompareOHLCVSource } from '../../../src/data_sources/ohlcv_external/crypto_compare';
+import { TradingPair } from '../../../src/utils/get_ohlcv_trading_pairs';
+import { chaiSetup } from '../../utils/chai_setup';
+
+chaiSetup.configure();
+const expect = chai.expect;
+
+// tslint:disable:custom-no-magic-numbers
+describe('ohlcv_external data source (Crypto Compare)', () => {
+ describe('generateBackfillIntervals', () => {
+ it('generates pairs with intervals to query', () => {
+ const source = new CryptoCompareOHLCVSource();
+ const pair: TradingPair = {
+ fromSymbol: 'ETH',
+ toSymbol: 'ZRX',
+ latestSavedTime: new Date().getTime() - source.interval * 2,
+ };
+
+ const expected = [
+ pair,
+ R.merge(pair, { latestSavedTime: pair.latestSavedTime + source.interval }),
+ R.merge(pair, { latestSavedTime: pair.latestSavedTime + source.interval * 2 }),
+ ];
+
+ const actual = source.generateBackfillIntervals(pair);
+ expect(actual).deep.equal(expected);
+ });
+
+ it('returns single pair if no backfill is needed', () => {
+ const source = new CryptoCompareOHLCVSource();
+ const pair: TradingPair = {
+ fromSymbol: 'ETH',
+ toSymbol: 'ZRX',
+ latestSavedTime: new Date().getTime() - source.interval + 5000,
+ };
+
+ const expected = [pair];
+
+ const actual = source.generateBackfillIntervals(pair);
+ expect(actual).deep.equal(expected);
+ });
+ });
+});