From 8c165beb45fb253d0af90757df149c93fcebc232 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Fri, 20 Nov 2020 14:55:03 +0100 Subject: [PATCH] tests differ for server-side and client-side failures --- test/helpers/clienttest.js | 9 +++++++++ test/integration/api.js | 2 +- test/integration/dtrust.js | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/helpers/clienttest.js b/test/helpers/clienttest.js index 596a861..1b45808 100644 --- a/test/helpers/clienttest.js +++ b/test/helpers/clienttest.js @@ -26,6 +26,10 @@ const ERR_CHECKS = [ } ]; +const ERR_DATA_CHECK = (t, args) => { + t.ok(typeof args[0].data == 'object', 'must return response data'); +} + function ClientTest(framework, client) { this.framework = framework; this.client = client; @@ -60,6 +64,11 @@ ClientTest.prototype.fails = function () { return this; } +ClientTest.prototype.failsServerSide = function () { + this._tests.push(ERR_DATA_CHECK); + return this.fails(); +} + ClientTest.prototype.returnsTx = function () { TX_CHECKS.forEach(fn => this._tests.push(fn)); return this; diff --git a/test/integration/api.js b/test/integration/api.js index 1a91187..84cce3b 100644 --- a/test/integration/api.js +++ b/test/integration/api.js @@ -205,7 +205,7 @@ cache.require(['minFee', 'newAddress', 'fromAddress', 'fromLabel'], () => { CT.create(test, badApiKeyClient).title('Validate API key (invalid key)') .method('validate_api_key') - .fails() + .failsServerSide() .execute(); CT.create(test, client).title('Get network fee estimate') diff --git a/test/integration/dtrust.js b/test/integration/dtrust.js index 8bbde8e..e270320 100644 --- a/test/integration/dtrust.js +++ b/test/integration/dtrust.js @@ -73,7 +73,7 @@ CT.create(test, client).title('Get New DTrust Address (too high required sigs)') required_signatures: KEYS.length + 1, public_keys: KEYS.map(key => key.pub.toString('hex')).join(',') }) - .fails() + .failsServerSide() .execute(); CT.create(test, client).title('Get New DTrust Address (duplicate signers)') @@ -83,7 +83,7 @@ CT.create(test, client).title('Get New DTrust Address (duplicate signers)') required_signatures: KEYS.length, public_keys: KEYS.map(() => KEYS[0].pub.toString('hex')).join(',') }) - .fails() + .failsServerSide() .execute(); CT.create(test, client).title('Get DTrust Addresses') @@ -255,7 +255,7 @@ cache.require(['dtrustWithdrawal'], () => { CT.create(test, client).title('Sending in an already finished withdrawal') .method('sign_and_finalize_withdrawal') .payload({ signature_data: JSON.stringify(w.data) }) - .fails() + .failsServerSide() .execute(); });