Skip to content

Commit

Permalink
tests differ for server-side and client-side failures
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklodder committed Nov 20, 2020
1 parent 9f77e1f commit 8c165be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions test/helpers/clienttest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions test/integration/dtrust.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand All @@ -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')
Expand Down Expand Up @@ -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();

});

0 comments on commit 8c165be

Please sign in to comment.