mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-01 07:55:21 +01:00
24 lines
714 B
JavaScript
24 lines
714 B
JavaScript
// Copyright BigchainDB GmbH and BigchainDB contributors
|
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
import test from 'ava'
|
|
|
|
import {
|
|
Connection
|
|
} from '../../src'
|
|
|
|
test('Pick connection with earliest backoff time', async t => {
|
|
const path1 = 'http://localhost:9984/api/v1/'
|
|
const path2 = 'http://localhostwrong:9984/api/v1/'
|
|
|
|
// Reverse order
|
|
const conn = new Connection([path2, path1])
|
|
// This will trigger the 'forwardRequest' so the correct connection will be taken
|
|
await conn.searchAssets('example')
|
|
|
|
const connection1 = conn.transport.connectionPool[1]
|
|
|
|
t.deepEqual(conn.transport.pickConnection(), connection1)
|
|
})
|