Skip to content

Commit

Permalink
Increase unit test coverage: unit tests for Electrum.getTransaction (#…
Browse files Browse the repository at this point in the history
…747)

#Refs: #714.
This PR adds a missing unit test for `Electrum.getTransaction`.
  • Loading branch information
lukasz-zimnoch authored Nov 15, 2023
2 parents a9ed10d + fa34d16 commit bd04b6c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions typescript/test/lib/electrum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import {
testnetTxHashes,
testnetUTXO,
} from "../data/electrum"
import { expect } from "chai"
import chai, { expect } from "chai"
import chaiAsPromised from "chai-as-promised"
import https from "https"

chai.use(chaiAsPromised)

const BLOCKSTREAM_TESTNET_API_URL = "https://blockstream.info/testnet/api"

const testnetCredentials: ElectrumCredentials[] = [
Expand Down Expand Up @@ -145,7 +148,16 @@ describe("Electrum", () => {
expect(result).to.be.eql(testnetTransaction)
})

// TODO: Add case when transaction doesn't exist.
it("should throw for unknown transaction hash", async function () {
// Set custom timeout as the electrum server attempts to execute the
// function several times.
this.timeout(100000)
const unknownTransaction = BitcoinTxHash.from(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
)
await expect(electrumClient.getTransaction(unknownTransaction)).to
.be.rejected
})
})

describe("getRawTransaction", () => {
Expand Down

0 comments on commit bd04b6c

Please sign in to comment.