Skip to content

Commit 65b0328

Browse files
committed
newlines in strings are invalid JSON
Although script_valid.json and script_invalid.json are loaded correctly by the JSON interpreter used by bitcoin core, these same files are often used by other libraries and do not necessarily load correctly due to the fact that newlines contained inside strings are not valid and must instead use the escape character \n. The files tx_valid.json and tx_invalid.json handle this correctly, so I've changed the formatting in script_valid.json and script_invalid.json to mirror those files.
1 parent 0286fe5 commit 65b0328

File tree

2 files changed

+23
-31
lines changed

2 files changed

+23
-31
lines changed

src/test/data/script_invalid.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
[
2-
["
3-
Format is: [scriptPubKey, scriptSig, flags, ... comments]
4-
It is evaluated as if there was a crediting coinbase transaction with two 0
5-
pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
6-
followed by a spending transaction which spends this output as only input (and
7-
correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
8-
nSequences are max.
9-
"],
2+
["Format is: [scriptPubKey, scriptSig, flags, ... comments]"],
3+
["It is evaluated as if there was a crediting coinbase transaction with two 0"],
4+
["pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,"],
5+
["followed by a spending transaction which spends this output as only input (and"],
6+
["correct prevout hash), using the given scriptSig. All nLockTimes are 0, all"],
7+
["nSequences are max."],
108

119
["", "DEPTH", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
1210
[" ", "DEPTH", "P2SH,STRICTENC", "and multiple spaces should not change that."],
@@ -496,11 +494,9 @@ nSequences are max.
496494
["0 0x02 0x0000 0", "CHECKMULTISIGVERIFY 1", "MINIMALDATA"],
497495

498496

499-
["
500-
Order of CHECKMULTISIG evaluation tests, inverted by swapping the order of
501-
pubkeys/signatures so they fail due to the STRICTENC rules on validly encoded
502-
signatures and pubkeys.
503-
"],
497+
["Order of CHECKMULTISIG evaluation tests, inverted by swapping the order of"],
498+
["pubkeys/signatures so they fail due to the STRICTENC rules on validly encoded"],
499+
["signatures and pubkeys."],
504500
[
505501
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
506502
"2 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 0 2 CHECKMULTISIG NOT",

src/test/data/script_valid.json

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
[
2-
["
3-
Format is: [scriptPubKey, scriptSig, flags, ... comments]
4-
It is evaluated as if there was a crediting coinbase transaction with two 0
5-
pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
6-
followed by a spending transaction which spends this output as only input (and
7-
correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
8-
nSequences are max.
9-
"],
2+
["Format is: [scriptPubKey, scriptSig, flags, ... comments]"],
3+
["It is evaluated as if there was a crediting coinbase transaction with two 0"],
4+
["pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,"],
5+
["followed by a spending transaction which spends this output as only input (and"],
6+
["correct prevout hash), using the given scriptSig. All nLockTimes are 0, all"],
7+
["nSequences are max."],
108

119
["", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
1210
[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "and multiple spaces should not change that."],
@@ -664,16 +662,14 @@ nSequences are max.
664662
["0 0 0x02 0x0000", "CHECKMULTISIGVERIFY 1", ""],
665663
["0 0x02 0x0000 0", "CHECKMULTISIGVERIFY 1", ""],
666664

667-
["
668-
CHECKMULTISIG evaluation order tests. CHECKMULTISIG evaluates signatures and
669-
pubkeys in a specific order, and will exit early if the number of signatures
670-
left to check is greater than the number of keys left. As STRICTENC fails the
671-
script when it reaches an invalidly encoded signature or pubkey, we can use it
672-
to test the exact order in which signatures and pubkeys are evaluated by
673-
distinguishing CHECKMULTISIG returning false on the stack and the script as a
674-
whole failing.
675-
See also the corresponding inverted versions of these tests in script_invalid.json
676-
"],
665+
["CHECKMULTISIG evaluation order tests. CHECKMULTISIG evaluates signatures and"],
666+
["pubkeys in a specific order, and will exit early if the number of signatures"],
667+
["left to check is greater than the number of keys left. As STRICTENC fails the"],
668+
["script when it reaches an invalidly encoded signature or pubkey, we can use it"],
669+
["to test the exact order in which signatures and pubkeys are evaluated by"],
670+
["distinguishing CHECKMULTISIG returning false on the stack and the script as a"],
671+
["whole failing."],
672+
["See also the corresponding inverted versions of these tests in script_invalid.json"],
677673
[
678674
"0 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501 0x47 0x3044022044dc17b0887c161bb67ba9635bf758735bdde503e4b0a0987f587f14a4e1143d022009a215772d49a85dae40d8ca03955af26ad3978a0ff965faa12915e9586249a501",
679675
"2 0 0x21 0x02865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac0 2 CHECKMULTISIG NOT",

0 commit comments

Comments
 (0)