invalid script test passing!
This commit is contained in:
parent
03d200bad7
commit
ddb3e6de70
|
@ -33,11 +33,9 @@ function Script(buffer) {
|
||||||
} else {
|
} else {
|
||||||
this.buffer = util.EMPTY_BUFFER;
|
this.buffer = util.EMPTY_BUFFER;
|
||||||
}
|
}
|
||||||
console.log(buffertools.toHex(this.buffer));
|
|
||||||
this.chunks = [];
|
this.chunks = [];
|
||||||
this.parse();
|
this.parse();
|
||||||
console.log(this.chunks);
|
}
|
||||||
};
|
|
||||||
this.class = Script;
|
this.class = Script;
|
||||||
|
|
||||||
Script.TX_UNKNOWN = TX_UNKNOWN;
|
Script.TX_UNKNOWN = TX_UNKNOWN;
|
||||||
|
|
|
@ -811,7 +811,7 @@ ScriptInterpreter.prototype.stackTop = function stackTop(offset) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ScriptInterpreter.prototype.stackBack = function stackBack() {
|
ScriptInterpreter.prototype.stackBack = function stackBack() {
|
||||||
return this.stack[-1];
|
return this.stack[this.stack.length -1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -944,7 +944,8 @@ function verifyStep3(scriptSig, scriptPubKey, txTo, nIn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.notEqual(siCopy.length, 0);
|
if (siCopy.length === 0)
|
||||||
|
throw new Error('siCopy should have length != 0');
|
||||||
|
|
||||||
var subscript = new Script(siCopy.stackPop());
|
var subscript = new Script(siCopy.stackPop());
|
||||||
|
|
||||||
|
|
|
@ -31,19 +31,17 @@ describe('ScriptInterpreter', function() {
|
||||||
var scriptPubKey = datum[1]; // output script
|
var scriptPubKey = datum[1]; // output script
|
||||||
var human = scriptSig + ' ' + scriptPubKey;
|
var human = scriptSig + ' ' + scriptPubKey;
|
||||||
it('should ' + (!valid ? 'not ' : '') + 'validate script ' + human, function(done) {
|
it('should ' + (!valid ? 'not ' : '') + 'validate script ' + human, function(done) {
|
||||||
console.log((!valid ? 'invalid ' : 'valid ') + human + ';' + (i++) + ' - ' + datum[2]);
|
|
||||||
try {
|
try {
|
||||||
ScriptInterpreter.verify(
|
ScriptInterpreter.verifyFull(
|
||||||
Script.fromHumanReadable(scriptSig),
|
Script.fromHumanReadable(scriptSig), // scriptSig
|
||||||
Script.fromHumanReadable(scriptPubKey),
|
Script.fromHumanReadable(scriptPubKey), // scriptPubKey
|
||||||
null, 0, 0, // tx, output index, and hashtype
|
null, 0, 0, // tx, output index, hashtype
|
||||||
|
{ verifyP2SH: !valid}, // only verify P2SH for invalid data set
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
} else {
|
} else {
|
||||||
var failed = (typeof err !== 'undefined') || (result === false);
|
var failed = (typeof err !== 'undefined') || (result === false);
|
||||||
console.log('err=' + err);
|
|
||||||
console.log('result=' + result);
|
|
||||||
failed.should.equal(true);
|
failed.should.equal(true);
|
||||||
}
|
}
|
||||||
if (typeof result !== 'undefined') {
|
if (typeof result !== 'undefined') {
|
||||||
|
|
|
@ -15,8 +15,8 @@ var examples = [
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('Examples', function() {
|
describe('Examples', function() {
|
||||||
//before(mute);
|
before(mute);
|
||||||
//after(unmute);
|
after(unmute);
|
||||||
examples.forEach(function(example) {
|
examples.forEach(function(example) {
|
||||||
it('valid '+example, function() {
|
it('valid '+example, function() {
|
||||||
var ex = require('../examples/'+example);
|
var ex = require('../examples/'+example);
|
||||||
|
|
Loading…
Reference in New Issue