invalid script test passing!

This commit is contained in:
Manuel Araoz 2014-03-18 19:17:43 -03:00
parent 03d200bad7
commit ddb3e6de70
4 changed files with 11 additions and 14 deletions

View File

@ -33,11 +33,9 @@ function Script(buffer) {
} else {
this.buffer = util.EMPTY_BUFFER;
}
console.log(buffertools.toHex(this.buffer));
this.chunks = [];
this.parse();
console.log(this.chunks);
};
}
this.class = Script;
Script.TX_UNKNOWN = TX_UNKNOWN;

View File

@ -811,7 +811,7 @@ ScriptInterpreter.prototype.stackTop = function stackTop(offset) {
};
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;
}
assert.notEqual(siCopy.length, 0);
if (siCopy.length === 0)
throw new Error('siCopy should have length != 0');
var subscript = new Script(siCopy.stackPop());

View File

@ -31,19 +31,17 @@ describe('ScriptInterpreter', function() {
var scriptPubKey = datum[1]; // output script
var human = scriptSig + ' ' + scriptPubKey;
it('should ' + (!valid ? 'not ' : '') + 'validate script ' + human, function(done) {
console.log((!valid ? 'invalid ' : 'valid ') + human + ';' + (i++) + ' - ' + datum[2]);
try {
ScriptInterpreter.verify(
Script.fromHumanReadable(scriptSig),
Script.fromHumanReadable(scriptPubKey),
null, 0, 0, // tx, output index, and hashtype
ScriptInterpreter.verifyFull(
Script.fromHumanReadable(scriptSig), // scriptSig
Script.fromHumanReadable(scriptPubKey), // scriptPubKey
null, 0, 0, // tx, output index, hashtype
{ verifyP2SH: !valid}, // only verify P2SH for invalid data set
function(err, result) {
if (valid) {
should.not.exist(err);
} else {
var failed = (typeof err !== 'undefined') || (result === false);
console.log('err=' + err);
console.log('result=' + result);
failed.should.equal(true);
}
if (typeof result !== 'undefined') {

View File

@ -15,8 +15,8 @@ var examples = [
];
describe('Examples', function() {
//before(mute);
//after(unmute);
before(mute);
after(unmute);
examples.forEach(function(example) {
it('valid '+example, function() {
var ex = require('../examples/'+example);