Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase unit test coverage: unit tests for Electrum.getTransaction #747

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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