Skip to content

Commit e46fc22

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): wrap test suites in describe blocks
Add proper describe blocks to organize test cases into suites for better test hierarchy and reporting. This change helps with test organization and makes output more readable. Issue: BTC-2786 Co-authored-by: llm-git <[email protected]>
1 parent 434fd72 commit e46fc22

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

packages/wasm-utxo/test/address/utxolibCompat.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ function runTest(network: utxolib.Network, addressFormat?: AddressFormat) {
117117
});
118118
}
119119

120-
utxolib.getNetworkList().forEach((network) => {
121-
runTest(network);
122-
const mainnet = utxolib.getMainnet(network);
123-
if (mainnet === utxolib.networks.bitcoincash || mainnet === utxolib.networks.ecash) {
124-
runTest(network, "cashaddr");
125-
}
120+
describe("utxolib compatible address encoding/decoding", function () {
121+
utxolib.getNetworkList().forEach((network) => {
122+
runTest(network);
123+
const mainnet = utxolib.getMainnet(network);
124+
if (mainnet === utxolib.networks.bitcoincash || mainnet === utxolib.networks.ecash) {
125+
runTest(network, "cashaddr");
126+
}
127+
});
126128
});

packages/wasm-utxo/test/fixedScript/address.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ function runTest(
105105
});
106106
}
107107

108-
utxolib.getNetworkList().forEach((network) => {
109-
runTest(network);
110-
runTest(network, { derivationPrefixes: ["m/1/2", "m/0/0", "m/0/0"] });
111-
if (
112-
utxolib.getMainnet(network) === utxolib.networks.bitcoincash ||
113-
utxolib.getMainnet(network) === utxolib.networks.ecash
114-
) {
115-
runTest(network, { addressFormat: "cashaddr" });
116-
}
108+
describe("address for networks", function () {
109+
utxolib.getNetworkList().forEach((network) => {
110+
runTest(network);
111+
runTest(network, { derivationPrefixes: ["m/1/2", "m/0/0", "m/0/0"] });
112+
if (
113+
utxolib.getMainnet(network) === utxolib.networks.bitcoincash ||
114+
utxolib.getMainnet(network) === utxolib.networks.ecash
115+
) {
116+
runTest(network, { addressFormat: "cashaddr" });
117+
}
118+
});
117119
});

packages/wasm-utxo/test/fixedScriptToDescriptor.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ function runTest(
116116
});
117117
}
118118

119-
scriptTypes.forEach((scriptType) => {
120-
index.forEach((index) => {
121-
scope.forEach((scope) => {
122-
runTest(scriptType, index, scope);
119+
describe("fixedScript to descriptor", function () {
120+
scriptTypes.forEach((scriptType) => {
121+
index.forEach((index) => {
122+
scope.forEach((scope) => {
123+
runTest(scriptType, index, scope);
124+
});
123125
});
124126
});
125127
});

packages/wasm-utxo/test/psbtFixedScriptCompat.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,28 @@ function describeUpdateInputWithDescriptor(
130130
});
131131
}
132132

133-
fixtures.forEach(({ psbt, scriptType, stage }) => {
134-
describe(`PSBT fixture ${scriptType} ${stage}`, function () {
135-
let buf: Buffer;
136-
let wrappedPsbt: Psbt;
137-
138-
before(function () {
139-
buf = psbt.toBuffer();
140-
wrappedPsbt = toWrappedPsbt(buf);
141-
});
133+
describe("PSBT fixture", function () {
134+
fixtures.forEach(({ psbt, scriptType, stage }) => {
135+
describe(`PSBT fixture ${scriptType} ${stage}`, function () {
136+
let buf: Buffer;
137+
let wrappedPsbt: Psbt;
138+
139+
before(function () {
140+
buf = psbt.toBuffer();
141+
wrappedPsbt = toWrappedPsbt(buf);
142+
});
142143

143-
it("should map to same hex", function () {
144-
assertEqualBuffer(buf, wrappedPsbt.serialize());
145-
});
144+
it("should map to same hex", function () {
145+
assertEqualBuffer(buf, wrappedPsbt.serialize());
146+
});
146147

147-
it("should round-trip utxolib -> ms -> utxolib", function () {
148-
assertEqualBuffer(buf, toUtxoPsbt(wrappedPsbt).toBuffer());
149-
});
148+
it("should round-trip utxolib -> ms -> utxolib", function () {
149+
assertEqualBuffer(buf, toUtxoPsbt(wrappedPsbt).toBuffer());
150+
});
150151

151-
if (stage === "bare") {
152-
describeUpdateInputWithDescriptor(psbt, scriptType);
153-
}
152+
if (stage === "bare") {
153+
describeUpdateInputWithDescriptor(psbt, scriptType);
154+
}
155+
});
154156
});
155157
});

0 commit comments

Comments
 (0)