From b3f02eb70a053ccd79a05b413c9107433604275b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 13 Aug 2017 08:03:34 -0700 Subject: [PATCH] test: run sigops tests without cache. --- test/block-test.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/block-test.js b/test/block-test.js index 12f87dea..05cb8599 100644 --- a/test/block-test.js +++ b/test/block-test.js @@ -359,18 +359,22 @@ describe('Block', function() { for (const [name, sigops, weight] of sigopsVectors) { const ctx = common.readBlock(name); - it(`should count sigops for ${name}`, () => { - const [block, view] = ctx.getBlock(); - const flags = Script.flags.VERIFY_P2SH | Script.flags.VERIFY_WITNESS; + for (const cache of [false, true]) { + const word = cache ? 'with' : 'without'; + 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; - for (const tx of block.txs) - count += tx.getSigopsCost(view, flags); + if (!cache) + block.refresh(true); - assert.strictEqual(count, sigops); - assert.strictEqual(block.getWeight(), weight); - block.refresh(); - assert.strictEqual(block.getWeight(), weight); - }); + let count = 0; + for (const tx of block.txs) + count += tx.getSigopsCost(view, flags); + + assert.strictEqual(count, sigops); + assert.strictEqual(block.getWeight(), weight); + }); + } } });