check reserialized tx hashes in tx tests.
This commit is contained in:
parent
80e6126f0c
commit
716d94ec9b
@ -203,10 +203,7 @@ describe('Script', function() {
|
|||||||
|
|
||||||
comments += ' (' + expected + ')';
|
comments += ' (' + expected + ')';
|
||||||
|
|
||||||
if (witness)
|
witness = bcoin.witness.fromTestString(witness);
|
||||||
witness = bcoin.witness.fromTestString(witness);
|
|
||||||
else
|
|
||||||
witness = new bcoin.witness();
|
|
||||||
input = bcoin.script.fromTestString(input);
|
input = bcoin.script.fromTestString(input);
|
||||||
output = bcoin.script.fromTestString(output);
|
output = bcoin.script.fromTestString(output);
|
||||||
|
|
||||||
|
|||||||
@ -25,15 +25,20 @@ function parseTX(file) {
|
|||||||
function clearCache(tx, nocache) {
|
function clearCache(tx, nocache) {
|
||||||
var i, input, output;
|
var i, input, output;
|
||||||
|
|
||||||
if (!nocache)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tx instanceof bcoin.script) {
|
if (tx instanceof bcoin.script) {
|
||||||
|
if (!nocache)
|
||||||
|
return;
|
||||||
delete tx.raw;
|
delete tx.raw;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tx.raw;
|
if (!nocache) {
|
||||||
|
assert.equal(tx.hash('hex'), tx.clone().hash('hex'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete tx._raw;
|
||||||
|
delete tx._hash;
|
||||||
|
|
||||||
for (i = 0; i < tx.inputs.length; i++) {
|
for (i = 0; i < tx.inputs.length; i++) {
|
||||||
input = tx.inputs[i];
|
input = tx.inputs[i];
|
||||||
@ -179,7 +184,6 @@ describe('TX', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tx = data.tx;
|
var tx = data.tx;
|
||||||
clearCache(tx, nocache);
|
|
||||||
var flags = data.flags;
|
var flags = data.flags;
|
||||||
var comments = comment.trim();
|
var comments = comment.trim();
|
||||||
if (!comments)
|
if (!comments)
|
||||||
@ -189,27 +193,32 @@ describe('TX', function() {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
if (comments.indexOf('Coinbase') === 0) {
|
if (comments.indexOf('Coinbase') === 0) {
|
||||||
it('should handle valid coinbase' + suffix + ': ' + comments, function () {
|
it('should handle valid coinbase' + suffix + ': ' + comments, function () {
|
||||||
|
clearCache(tx, nocache);
|
||||||
assert.ok(tx.isSane());
|
assert.ok(tx.isSane());
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it('should handle valid tx test' + suffix + ': ' + comments, function () {
|
it('should handle valid tx test' + suffix + ': ' + comments, function () {
|
||||||
|
clearCache(tx, nocache);
|
||||||
assert.ok(tx.verify(null, true, flags));
|
assert.ok(tx.verify(null, true, flags));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (comments === 'Duplicate inputs') {
|
if (comments === 'Duplicate inputs') {
|
||||||
it('should handle duplicate input test' + suffix + ': ' + comments, function () {
|
it('should handle duplicate input test' + suffix + ': ' + comments, function () {
|
||||||
|
clearCache(tx, nocache);
|
||||||
assert.ok(!tx.isSane());
|
assert.ok(!tx.isSane());
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comments.indexOf('Coinbase') === 0) {
|
if (comments.indexOf('Coinbase') === 0) {
|
||||||
it('should handle invalid coinbase' + suffix + ': ' + comments, function () {
|
it('should handle invalid coinbase' + suffix + ': ' + comments, function () {
|
||||||
|
clearCache(tx, nocache);
|
||||||
assert.ok(!tx.isSane());
|
assert.ok(!tx.isSane());
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it('should handle invalid tx test' + suffix + ': ' + comments, function () {
|
it('should handle invalid tx test' + suffix + ': ' + comments, function () {
|
||||||
|
clearCache(tx, nocache);
|
||||||
assert.ok(!tx.verify(null, true, flags));
|
assert.ok(!tx.verify(null, true, flags));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user