tests: add BIP62 compliance tests
This commit is contained in:
parent
2638b251e1
commit
d96b7036fb
2 changed files with 35 additions and 0 deletions
|
@ -82,6 +82,7 @@
|
||||||
"bs58": "^2.0.1",
|
"bs58": "^2.0.1",
|
||||||
"cb-http-client": "^0.2.0",
|
"cb-http-client": "^0.2.0",
|
||||||
"httpify": "^1.0.0",
|
"httpify": "^1.0.0",
|
||||||
|
"minimaldata": "^1.0.0",
|
||||||
"mocha": "^2.2.0",
|
"mocha": "^2.2.0",
|
||||||
"proxyquire": "^1.4.0",
|
"proxyquire": "^1.4.0",
|
||||||
"sinon": "^1.12.2",
|
"sinon": "^1.12.2",
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var bcrypto = require('../src/crypto')
|
var bcrypto = require('../src/crypto')
|
||||||
var bscript = require('../src/script')
|
var bscript = require('../src/script')
|
||||||
|
var minimalData = require('minimaldata')
|
||||||
var ops = require('../src/opcodes')
|
var ops = require('../src/opcodes')
|
||||||
|
|
||||||
var fixtures = require('./fixtures/script.json')
|
var fixtures = require('./fixtures/script.json')
|
||||||
|
@ -440,4 +441,37 @@ describe('script', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('SCRIPT_VERIFY_MINIMALDATA policy', function () {
|
||||||
|
fixtures.valid.forEach(function (f) {
|
||||||
|
if (f.scriptSigHex) {
|
||||||
|
it('compliant for ' + f.type + ' scriptSig ' + f.scriptSig, function () {
|
||||||
|
var script = new Buffer(f.scriptSigHex, 'hex')
|
||||||
|
|
||||||
|
assert(minimalData(script))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.scriptPubKeyHex) {
|
||||||
|
it('compliant for ' + f.type + ' scriptPubKey ' + f.scriptPubKey, function () {
|
||||||
|
var script = new Buffer(f.scriptPubKeyHex, 'hex')
|
||||||
|
|
||||||
|
assert(minimalData(script))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function testEncodingForSize (i) {
|
||||||
|
it('compliant for data PUSH of length ' + i, function () {
|
||||||
|
var buffer = new Buffer(i)
|
||||||
|
var script = bscript.compile([buffer])
|
||||||
|
|
||||||
|
assert(minimalData(script), 'Failed for ' + i + ' length script')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < 520; ++i) {
|
||||||
|
testEncodingForSize(i)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue