Skip to content

Commit

Permalink
fix(electrs): Improve promise error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-savu committed Apr 19, 2021
1 parent 534f3b7 commit 94910f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@interlay/polkabtc",
"version": "0.14.0",
"version": "0.14.1",
"description": "JavaScript library to interact with PolkaBTC",
"main": "build/index.js",
"typings": "build/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/external/electrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ export class DefaultElectrsAPI implements ElectrsAPI {
console.log("Did not find opreturn, retrying...");
if(timeoutMs < retryIntervalMs) {
reject("Timeout elapsed");
} else {
this.waitForOpreturn(data, timeoutMs - retryIntervalMs, retryIntervalMs).then(resolve).catch(reject);
}
this.waitForOpreturn(data, timeoutMs - retryIntervalMs, retryIntervalMs).then(resolve);
}, retryIntervalMs);
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/integration/parachain/staging/refund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("refund", () => {
});

it("should not generate a refund request", async () => {
const isueResult = await issue(
const issueResult = await issue(
api,
electrsAPI,
bitcoinCoreClient,
Expand All @@ -45,14 +45,14 @@ describe("refund", () => {
false,
false
);
const refund = await refundAPI.getRequestByIssueId(isueResult.request.id);
const refund = await refundAPI.getRequestByIssueId(issueResult.request.id);
// The parachain returns an Option<> refund request if none was found,
// which is deserialized as a refund request with blank/default fields
assert.equal(refund.amount_btc.toString(), "0");
}).timeout(1000000);

it("should generate a refund request", async () => {
const isueResult = await issue(
const issueResult = await issue(
api,
electrsAPI,
bitcoinCoreClient,
Expand All @@ -62,7 +62,7 @@ describe("refund", () => {
true,
true
);
const refund = await refundAPI.getRequestByIssueId(isueResult.request.id);
const refund = await refundAPI.getRequestByIssueId(issueResult.request.id);
assert.notEqual(refund.amount_btc.toString(), "0");
}).timeout(1000000);

Expand Down

0 comments on commit 94910f6

Please sign in to comment.