Add script test to prove that OP_0 evaluates as the empty vector, rather than [0]. Also adds debug output in case an script_invalid.json test fails.

This commit is contained in:
Andreas Schildbach 2014-03-10 23:14:21 +01:00 committed by Mike Hearn
parent b6149bfa48
commit b17533f8fb
3 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,6 @@
/**
* Copyright 2011 Google Inc.
* Copyright 2014 Andreas Schildbach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -192,10 +193,15 @@ public class ScriptTest {
if (line.trim().endsWith("],") || line.trim().equals("]")) {
String[] scripts = script.split(",");
try {
Script scriptSig = parseScriptString(scripts[0].replaceAll("[\"\\[\\]]", "").trim());
Script scriptPubKey = parseScriptString(scripts[1].replaceAll("[\"\\[\\]]", "").trim());
scripts[0] = scripts[0].replaceAll("[\"\\[\\]]", "").trim();
scripts[1] = scripts[1].replaceAll("[\"\\[\\]]", "").trim();
Script scriptSig = parseScriptString(scripts[0]);
Script scriptPubKey = parseScriptString(scripts[1]);
scriptSig.correctlySpends(new Transaction(params), 0, scriptPubKey, true);
System.err.println("scriptSig: " + scripts[0]);
System.err.println("scriptPubKey: " + scripts[1]);
System.err.flush();
fail();
} catch (VerificationException e) {
// Expected.

View File

@ -325,5 +325,7 @@
["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"],
["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "OP_RESERVED in P2SH should fail"],
["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"]
["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"],
["0x00", "'00' EQUAL", "Basic OP_0 execution"]
]

View File

@ -411,5 +411,7 @@
["0x4c 0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242",
"0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL",
"Basic PUSHDATA1 signedness check"]
"Basic PUSHDATA1 signedness check"],
["0x00", "SIZE 0 EQUAL", "Basic OP_0 execution"]
]