diff --git a/modules/chronik-client/test/test.ts b/modules/chronik-client/test/test.ts --- a/modules/chronik-client/test/test.ts +++ b/modules/chronik-client/test/test.ts @@ -1,5 +1,6 @@ import * as chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; +import { FailoverProxy } from '../failoverProxy'; import { BlockDetails, BlockInfo, @@ -10,13 +11,13 @@ Utxo, UtxoState, } from '../index'; -import { FailoverProxy } from '../failoverProxy'; const expect = chai.expect; const assert = chai.assert; chai.use(chaiAsPromised); -const TEST_URL = 'https://chronik.be.cash/xec'; +const LIVE_URL_ONE = 'https://chronik.fabien.cash'; +const LIVE_URL_TWO = 'https://chronik2.fabien.cash'; const GENESIS_PK = '04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc' + @@ -132,7 +133,7 @@ }); describe('/broadcast-tx', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('throws a decode error', async () => { assert.isRejected( chronik.broadcastTx('00000000'), @@ -145,7 +146,7 @@ }); describe('/blockchain-info', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('gives us the blockchain info', async () => { const blockchainInfo = await chronik.blockchainInfo(); expect(blockchainInfo.tipHash.length).to.eql(64); @@ -176,7 +177,7 @@ }); describe('/block/:hash', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('gives us the Genesis block by hash', async () => { const block = await chronik.block( '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', @@ -194,7 +195,7 @@ }); describe('/blocks/:start/:end', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('gives us the first few blocks', async () => { const blocks = await chronik.blocks(0, 10); expect(blocks.length).to.equal(11); @@ -229,7 +230,7 @@ }); describe('/tx/:txid', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('results in Not Found', async () => { assert.isRejected( chronik.tx( @@ -358,7 +359,7 @@ }); describe('/token/:tokenId', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('results in Not Found', async () => { assert.isRejected( chronik.token( @@ -408,7 +409,7 @@ }); describe('/validate-utxos', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('validates the UTXOs', async () => { const validationResult = await chronik.validateUtxos([ { @@ -455,7 +456,7 @@ }); describe('/script/:type/:payload/history', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('gives us the first page', async () => { const script = chronik.script('p2pk', GENESIS_PK); const history = await script.history(); @@ -483,7 +484,7 @@ }); describe('/script/:type/:payload/utxos', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); it('gives us the UTXOs', async () => { const script = chronik.script('p2pk', GENESIS_PK); const utxos = await script.utxos(); @@ -494,7 +495,7 @@ }); describe('/ws', () => { - const chronik = new ChronikClient(TEST_URL); + const chronik = new ChronikClient(LIVE_URL_ONE); xit('gives us a confirmation', async () => { const promise = new Promise((resolve: (msg: SubscribeMsg) => void) => { const ws = chronik.ws({ @@ -522,7 +523,7 @@ 'https://chronikaaaa.be.cash/xec', 'https://chronikzzzz.be.cash/xec', 'https://chroniktttt.be.cash/xec', - TEST_URL, // working + LIVE_URL_ONE, // working ]); it('connects to a working ws in an array of broken ws', async () => { const promise = new Promise(resolve => { @@ -539,14 +540,14 @@ describe('FailoverProxy', () => { it('appendWsUrls combines an object array of valid urls with wsUrls', () => { const urls = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'https://chronik.fabien.cash', 'https://chronik2.fabien.cash', ]; const proxyInterface = new FailoverProxy(urls); const expectedResult = [ { - url: TEST_URL, + url: 'https://chronik.be.cash/xec', wsUrl: 'wss://chronik.be.cash/xec/ws', }, { @@ -562,14 +563,14 @@ }); it('appendWsUrls combines an array of mixed valid https and http urls with wsUrls', () => { const urls = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', ]; const proxyInterface = new FailoverProxy(urls); const expectedResult = [ { - url: TEST_URL, + url: 'https://chronik.be.cash/xec', wsUrl: 'wss://chronik.be.cash/xec/ws', }, { @@ -585,7 +586,7 @@ }); it('appendWsUrls returns an empty array for an empty input', () => { const urls = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', ]; @@ -594,7 +595,7 @@ }); it('appendWsUrls throws error on an invalid regular endpoint', () => { const urls = [ - TEST_URL, + LIVE_URL_ONE, 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', ]; @@ -610,14 +611,14 @@ }); it('FailoverProxy instantiates with a valid url array', () => { const urls = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', ]; const proxyInterface = new FailoverProxy(urls); const expectedProxyArray = [ { - url: TEST_URL, + url: 'https://chronik.be.cash/xec', wsUrl: 'wss://chronik.be.cash/xec/ws', }, { @@ -647,7 +648,7 @@ describe('deriveEndpointIndex', () => { it('deriveEndpointIndex iterates through a four element array with default working index', () => { const testArray = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', 'https://chronik3.fabien.cash', @@ -662,7 +663,7 @@ }); it('deriveEndpointIndex iterates through a four element array with working index set to 3', () => { const testArray = [ - TEST_URL, + 'https://chronik.be.cash/xec', 'http://chronik.fabien.cash', 'https://chronik2.fabien.cash', 'https://chronik3.fabien.cash',