Skip to content

Commit

Permalink
Merge pull request #280 from interlay/dan/electrs-promise-errors
Browse files Browse the repository at this point in the history
fix(electrs): Improve promise error handling
  • Loading branch information
daniel-savu authored Apr 19, 2021
2 parents 534f3b7 + 94910f6 commit e556a1c
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 e556a1c

Please sign in to comment.