From b27df612daaf2365d9d4fb3f5bd7fb6c5b0f9f80 Mon Sep 17 00:00:00 2001 From: junderw <junderwood@bitcoinbank.co.jp> Date: Mon, 8 Apr 2019 15:34:12 +0900 Subject: [PATCH] Randomize sleep times --- test/integration/_regtest.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/_regtest.js b/test/integration/_regtest.js index 81821c1..d2a3c7d 100644 --- a/test/integration/_regtest.js +++ b/test/integration/_regtest.js @@ -46,11 +46,12 @@ async function faucet (address, value) { let count = 0 let _unspents = [] const sleep = ms => new Promise((resolve, reject) => setTimeout(resolve, ms)) + const randInt = (min, max) => min + Math.floor((max - min + 1) * Math.random()) do { if (count > 0) { if (count >= 5) throw new Error('Missing Inputs') console.log('Missing Inputs, retry #' + count) - await sleep(200) + await sleep(randInt(150, 250)) } const txId = await _faucetRequest(address, value) @@ -68,7 +69,7 @@ async function faucet (address, value) { } ) - await sleep(100) + await sleep(randInt(50, 150)) const results = await unspents(address)