diff --git a/package.json b/package.json index ebe4819..57ca6b7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:integration:local:abc": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 test/integration && mocha --timeout 30000 test/integration/chains/abc/", "test:integration:local:bchn": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/", "test:integration:local:testnet": "RESTURL=http://localhost:4000/v4/ mocha --timeout 30000 test/integration/chains/testnet", - "test:temp": "export RESTURL=https://bchn.fullstack.cash/v4/ && mocha --timeout 30000 -g '#UTXO' test/integration/chains/bchn/", + "test:temp": "export RESTURL=https://abc.fullstack.cash/v4/ && mocha --timeout 30000 -g '#UTXO' test/integration/chains/abc/", "test:temp2": "mocha --timeout=30000 -g '#Util' test/unit/", "coverage": "nyc report --reporter=text-lcov | coveralls", "coverage:report": "nyc --reporter=html mocha --timeout 25000 test/unit/", diff --git a/src/util.js b/src/util.js index 684a4c2..51dfc4c 100644 --- a/src/util.js +++ b/src/util.js @@ -150,6 +150,30 @@ class Util { } } + /** + * @api util.sleep() sleep() + * @apiName sleep + * @apiGroup Util + * @apiDescription Promise-based delay. + * Expects an integer as input, which represents milliseconds. This function + * will return a Promise that resolves that many milliseconds later. + * + * + * @apiExample Example usage: + * (async () => { + * try { + * const tenSeconds = 10000 + * await bchjs.Util.sleep(tenSeconds) + * } catch(error) { + * console.error(error) + * } + * })() + * + */ + sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)) + } + /** * @api util.validateAddress() validateAddress() * @apiName Validate Address. diff --git a/test/integration/chains/abc/utxo-integration.js b/test/integration/chains/abc/utxo-integration.js index ab856fc..1fb5655 100644 --- a/test/integration/chains/abc/utxo-integration.js +++ b/test/integration/chains/abc/utxo-integration.js @@ -22,9 +22,13 @@ describe('#UTXO', () => { const result = await bchjs.Utxo.get(addr) // console.log(`result: ${JSON.stringify(result, null, 2)}`) - assert.isArray(result.bchUtxos) - assert.isArray(result.slpUtxos) - assert.isArray(result.nullUtxos) + assert.isArray(result) + assert.property(result[0], 'address') + assert.property(result[0], 'bchUtxos') + assert.property(result[0], 'nullUtxos') + assert.property(result[0], 'slpUtxos') + assert.isArray(result[0].bchUtxos) + assert.isArray(result[0].nullUtxos) }) }) })