mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-12-29 08:07:51 +01:00
736b2adc37
Signed-off-by: getlarge <ed@getlarge.eu>
27 lines
852 B
JavaScript
27 lines
852 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/connection'
|
|
|
|
const conn = new Connection()
|
|
|
|
test('Ensure that BackoffTimedelta works properly', t => {
|
|
const req = conn.transport.pickConnection()
|
|
req.backoffTime = Date.now() + 50
|
|
const target = req.getBackoffTimedelta()
|
|
// The value should be close to 50
|
|
t.is(target > 45, true)
|
|
})
|
|
|
|
test('Ensure that updateBackoffTime throws and error on TimeoutError', async t => {
|
|
const req = conn.transport.pickConnection()
|
|
const errorMessage = 'TimeoutError'
|
|
req.connectionError = new Error(errorMessage)
|
|
|
|
t.throws(() => {
|
|
req.updateBackoffTime()
|
|
}, { instanceOf: Error, message: errorMessage })
|
|
})
|