Skip to content

Commit 030dce3

Browse files
author
Jansen McQuivey
committed
BG-7981 Fix broken logic on transfers address filtering
Summary: Haste makes waste. Reviewers: leo, thomas, boris, bigly, tyler Reviewed By: tyler Subscribers: tyler Differential Revision: https://phabricator.bitgo.com/D10051
1 parent cda3154 commit 030dce3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/v2/wallet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Wallet.prototype.transfers = function(params, callback) {
207207
}
208208

209209
if (params.address) {
210-
if (!_.isArray(params.address) || !_.isString) {
210+
if (!_.isArray(params.address) && !_.isString(params.address)) {
211211
throw new Error('invalid address argument, expecting string or array');
212212
}
213213
if (_.isArray(params.address)) {

test/v2/unit/wallet.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,32 @@ describe('V2 Wallet:', function() {
9898
scope.isDone().should.be.True();
9999
}));
100100

101+
it('should accept a string argument for address', co(function *() {
102+
const params = {
103+
limit: 1,
104+
address: 'stringAddress'
105+
};
106+
107+
const apiParams = {
108+
limit: '1',
109+
address: 'stringAddress'
110+
};
111+
112+
const scope =
113+
nock(bgUrl)
114+
.get(`/api/v2/${wallet.coin()}/wallet/${wallet.id()}/transfer`)
115+
.query(_.matches(apiParams))
116+
.reply(200);
117+
118+
try {
119+
yield wallet.transfers(params);
120+
} catch (e) {
121+
// test is successful if nock is consumed, HMAC errors expected
122+
}
123+
124+
scope.isDone().should.be.True();
125+
}));
126+
101127
it('should throw errors for invalid expected parameters', co(function *() {
102128
(() => wallet.transfers({ address: 13375 })).should.throw('invalid address argument, expecting string or array');
103129

0 commit comments

Comments
 (0)