From 55207e57427b30ae4380d30dd33e867ac6e1b773 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 27 Jul 2018 20:44:02 +1000 Subject: [PATCH] tests/payments/p2pk*: add signature mismatch tests --- src/payments/p2pk.js | 2 +- test/fixtures/p2pk.json | 13 +++++++++++++ test/fixtures/p2pkh.json | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/payments/p2pk.js b/src/payments/p2pk.js index 5f65030..4073d52 100644 --- a/src/payments/p2pk.js +++ b/src/payments/p2pk.js @@ -65,7 +65,7 @@ function p2pk (a, opts) { } if (a.signature) { - if (a.input && !a.input.equals(o.input)) throw new TypeError('Input mismatch') + if (a.input && !a.input.equals(o.input)) throw new TypeError('Signature mismatch') } if (a.input) { diff --git a/test/fixtures/p2pk.json b/test/fixtures/p2pk.json index 7ede5f4..a07c5b8 100644 --- a/test/fixtures/p2pk.json +++ b/test/fixtures/p2pk.json @@ -116,6 +116,19 @@ "pubkey": "030000000000000000000000000000000000000000000000000000000000000001", "input": "ffffffffffffffff" } + }, + { + "exception": "Input has invalid signature", + "arguments": { + "input": "30060201ff0201ff01" + } + }, + { + "exception": "Signature mismatch", + "arguments": { + "signature": "300602010002010001", + "input": "300602010302010301" + } } ], "dynamic": { diff --git a/test/fixtures/p2pkh.json b/test/fixtures/p2pkh.json index d16b181..118111d 100644 --- a/test/fixtures/p2pkh.json +++ b/test/fixtures/p2pkh.json @@ -204,6 +204,13 @@ "hash": "ffffffffffffffffffffffffffffffffffffffff", "input": "300602010002010001 030000000000000000000000000000000000000000000000000000000000000001" } + }, + { + "exception": "Signature mismatch", + "arguments": { + "signature": "300602010002010001", + "input": "300602010302010301 030000000000000000000000000000000000000000000000000000000000000001" + } } ], "dynamic": {