Skip to content

Commit

Permalink
tests: fix test to account for a problem in recent versions of regtes…
Browse files Browse the repository at this point in the history
…t-server (see: bitcoinjs/regtest-server#23)
  • Loading branch information
landabaso committed May 30, 2024
1 parent 87020c6 commit 1853068
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ async function burnTx({
const descs = [];
const descriptor = new Descriptor({ expression, network });
const address = descriptor.getAddress();
const unspents = await regtestUtils.unspents(address);

//const unspents = await regtestUtils.unspents(address); broken. See: https://github.com/bitcoinjs/regtest-server/issues/23

const response = await fetch(
`${ESPLORA_LOCAL_REGTEST_URL}/address/${address}/utxo`
);
const unspents = await response.json();

let value = 0;
if (unspents.length === 0) return null;
for (const unspent of unspents) {
const tx = await regtestUtils.fetch(unspent.txId);
const tx = await regtestUtils.fetch(unspent.txid);
descriptor.updatePsbt({ psbt, vout: unspent.vout, txHex: tx.txHex });
descs.push(descriptor);
value += unspent.value;
Expand Down Expand Up @@ -141,7 +148,7 @@ for (const regtestExplorer of regtestExplorers) {
const { balance, txCount } = await explorer.fetchAddress(address);
expect(balance).toBeGreaterThanOrEqual(descriptor.value);
expect(txCount > 0).toEqual(true);
//DEPRECATED
//DEPRECATED --- unspents is broken anyway, see: https://github.com/bitcoinjs/regtest-server/issues/23
//const expectedUtxos = await regtestUtils.unspents(address);

//const { confirmed } = await explorer.fetchUtxos({ address });
Expand Down

0 comments on commit 1853068

Please sign in to comment.