Skip to content

Commit 33c2bd9

Browse files
committed
tests: improve test coverage
1 parent a598134 commit 33c2bd9

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/payments/p2tr.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function p2tr(a, opts) {
6767
const tweakedKey = (0, types_1.tweakPublicKey)(a.internalPubkey, o.hash);
6868
if (tweakedKey) return tweakedKey.x;
6969
}
70-
return null;
7170
});
7271
lazy.prop(o, 'signature', () => {
7372
if (a.witness?.length !== 1) return;

test/fixtures/p2tr.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@
5959
]
6060
}
6161
},
62+
{
63+
"description": "address, output and signature from pubkey and witness",
64+
"arguments": {
65+
"pubkey": "ab610d22c801def8a1e02368d1b92018970eb52a729919705e8a1a2f60c750f5",
66+
"witness": [
67+
"300602010002010001"
68+
]
69+
},
70+
"expected": {
71+
"name": "p2tr",
72+
"address": "bc1p4dss6gkgq8003g0qyd5drwfqrztsadf2w2v3juz73gdz7cx82r6sj7lcqx",
73+
"output": "OP_1 ab610d22c801def8a1e02368d1b92018970eb52a729919705e8a1a2f60c750f5",
74+
"input": null,
75+
"signature": "300602010002010001",
76+
"witness": [
77+
"300602010002010001"
78+
]
79+
}
80+
},
6281
{
6382
"description": "address, pubkey and output from internalPubkey",
6483
"arguments": {
@@ -150,6 +169,13 @@
150169
"pubkey": "ab610d22c801def8a1e02368d1b92018970eb52a729919705e8a1a2f60c750f5"
151170
}
152171
},
172+
{
173+
"exception": "Invalid internalPubkey for p2t",
174+
"options": {},
175+
"arguments": {
176+
"internalPubkey": "9fa5ffb68821cf559001caa0577eeea4978b29416def328a707b15e91701a2f8"
177+
}
178+
},
153179
{
154180
"exception": "Signature mismatch",
155181
"arguments": {

ts_src/payments/p2tr.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
7373
const tweakedKey = tweakPublicKey(a.internalPubkey, o.hash)
7474
if (tweakedKey) return tweakedKey.x
7575
}
76-
return null
7776
});
7877
lazy.prop(o, 'signature', () => {
7978
if (a.witness?.length !== 1) return;

0 commit comments

Comments
 (0)