test: run sigops tests without cache.

This commit is contained in:
Christopher Jeffrey 2017-08-13 08:03:34 -07:00
parent d33443186c
commit b3f02eb70a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -359,18 +359,22 @@ describe('Block', function() {
for (const [name, sigops, weight] of sigopsVectors) { for (const [name, sigops, weight] of sigopsVectors) {
const ctx = common.readBlock(name); const ctx = common.readBlock(name);
it(`should count sigops for ${name}`, () => { for (const cache of [false, true]) {
const [block, view] = ctx.getBlock(); const word = cache ? 'with' : 'without';
const flags = Script.flags.VERIFY_P2SH | Script.flags.VERIFY_WITNESS; it(`should count sigops for ${name} (${word} cache)`, () => {
const [block, view] = ctx.getBlock();
const flags = Script.flags.VERIFY_P2SH | Script.flags.VERIFY_WITNESS;
let count = 0; if (!cache)
for (const tx of block.txs) block.refresh(true);
count += tx.getSigopsCost(view, flags);
assert.strictEqual(count, sigops); let count = 0;
assert.strictEqual(block.getWeight(), weight); for (const tx of block.txs)
block.refresh(); count += tx.getSigopsCost(view, flags);
assert.strictEqual(block.getWeight(), weight);
}); assert.strictEqual(count, sigops);
assert.strictEqual(block.getWeight(), weight);
});
}
} }
}); });