mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
* first attempt at overloading * fix TS issues * improve connection typing * more cleanup * edit all ledger files * more renames * fix all other request calls * clean up serverinfo * fixes more request calls * remove old legacy browser stuff * remove unused types * remove exports from objects * add type to method signatures * add ledger requests * fix most tests * comment out formatBidsAndAsks * fix proxy test * comment out failing tests * move client-related files into client * add payment channel requests * fix imports * remove finished TODOs * fix tests * fix integ tests * remove exported types * better ci
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import assert from 'assert-diff'
|
|
import {ExponentialBackoff} from '../src/client/backoff'
|
|
|
|
describe('ExponentialBackoff', function () {
|
|
it('duration() return value starts with the min value', function () {
|
|
// default: 100ms
|
|
assert(new ExponentialBackoff().duration(), 100)
|
|
assert(new ExponentialBackoff({min: 100}).duration(), 100)
|
|
assert(new ExponentialBackoff({min: 123}).duration(), 123)
|
|
})
|
|
|
|
it('duration() return value increases when called multiple times', function () {
|
|
const backoff = new ExponentialBackoff({min: 100, max: 1000})
|
|
assert.strictEqual(backoff.duration(), 100)
|
|
assert.strictEqual(backoff.duration(), 200)
|
|
assert.strictEqual(backoff.duration(), 400)
|
|
assert.strictEqual(backoff.duration(), 800)
|
|
})
|
|
|
|
it('duration() never returns greater than the max value', function () {
|
|
const backoff = new ExponentialBackoff({min: 300, max: 1000})
|
|
assert.strictEqual(backoff.duration(), 300)
|
|
assert.strictEqual(backoff.duration(), 600)
|
|
assert.strictEqual(backoff.duration(), 1000)
|
|
assert.strictEqual(backoff.duration(), 1000)
|
|
})
|
|
|
|
it('reset() will reset the duration() value', function () {
|
|
const backoff = new ExponentialBackoff({min: 100, max: 1000})
|
|
assert.strictEqual(backoff.duration(), 100)
|
|
assert.strictEqual(backoff.duration(), 200)
|
|
assert.strictEqual(backoff.duration(), 400)
|
|
backoff.reset()
|
|
assert.strictEqual(backoff.duration(), 100)
|
|
assert.strictEqual(backoff.duration(), 200)
|
|
})
|
|
})
|