Skip to content

Commit

Permalink
wallet-http: fix the return of POST /reveal and /redeem when no name …
Browse files Browse the repository at this point in the history
…provided
  • Loading branch information
peipeiInt committed Jan 8, 2021
1 parent a1409dc commit e5cb964
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/wallet/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ class HTTP extends Server {

if (!name) {
const tx = await req.wallet.sendRevealAll();
return tx.getJSON(this.network);
return res.json(200, tx.getJSON(this.network));
}

const options = TransactionOptions.fromValidator(valid);
Expand Down Expand Up @@ -1105,7 +1105,7 @@ class HTTP extends Server {

if (!name) {
const tx = await req.wallet.sendRedeemAll();
return tx.getJSON(this.network);
return res.json(200, tx.getJSON(this.network));
}

const options = TransactionOptions.fromValidator(valid);
Expand Down
27 changes: 27 additions & 0 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,33 @@ describe('Wallet HTTP', function() {
assert.equal(reveals.length, 1);
});

it('should create all reveals', async () => {
await wallet.createOpen({
name: name
});

await mineBlocks(treeInterval + 1, cbAddress);

for (let i = 0; i < 3; i++) {
await wallet.createBid({
name: name,
bid: 1000,
lockup: 2000
});
}

await mineBlocks(biddingPeriod + 1, cbAddress);

const {info} = await nclient.execute('getnameinfo', [name]);
assert.equal(info.name, name);
assert.equal(info.state, 'REVEAL');

const json = await wallet.createReveal();

const reveals = json.outputs.filter(output => output.covenant.type === types.REVEAL);
assert.equal(reveals.length, 3);
});

it('should get all reveals (single player)', async () => {
await wallet.createOpen({
name: name
Expand Down

0 comments on commit e5cb964

Please sign in to comment.