over 1800 tests.

This commit is contained in:
Christopher Jeffrey 2016-04-19 04:25:28 -07:00
parent 67f03b5004
commit b3c1a2a81b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -134,24 +134,59 @@ describe('Script', function() {
assert.deepEqual(stack.slice(), [[1], [3], [5]]); assert.deepEqual(stack.slice(), [[1], [3], [5]]);
}); });
var dummyInput = { function success(res, stack) {
prevout: { if (!res)
hash: constants.NULL_HASH, return false;
index: 0 if (stack.length === 0)
}, return false;
coin: { if (!bcoin.script.bool(stack.pop()))
version: 1, return false;
height: 0, return true;
value: constants.MAX_MONEY.clone(), }
script: new bcoin.script([]),
coinbase: false, it('should handle CScriptNums correctly', function () {
hash: constants.NULL_HASH, var s = bcoin.script.fromSymbolic([
index: 0 new Buffer([0xff, 0xff, 0xff, 0x7f]), 'OP_NEGATE', 'OP_DUP', 'OP_ADD'
}, ]);
script: new bcoin.script([]), var s2 = bcoin.script.fromSymbolic([
witness: new bcoin.script.witness([]), new Buffer([0xfe, 0xff, 0xff, 0xff, 0x80]),
sequence: 0xffffffff 'OP_EQUAL'
}; ]);
var stack = new bcoin.script.stack();
assert(s.execute(stack));
assert(success(s2.execute(stack), stack));
});
it('should handle CScriptNums correctly', function () {
var s = bcoin.script.fromSymbolic([
'OP_11', 'OP_10', 'OP_1', 'OP_ADD'
]);
var s2 = bcoin.script.fromSymbolic([
'OP_NUMNOTEQUAL',
'OP_NOT'
]);
var stack = new bcoin.script.stack();
assert(s.execute(stack));
assert(success(s2.execute(stack), stack));
});
it('should handle OP_ROLL correctly', function () {
var s = bcoin.script.fromSymbolic([
new Buffer([0x16]), new Buffer([0x15]), new Buffer([0x14])
]);
var s2 = bcoin.script.fromSymbolic([
'OP_0',
'OP_ROLL',
new Buffer([0x14]),
'OP_EQUALVERIFY',
'OP_DEPTH',
'OP_2',
'OP_EQUAL'
]);
var stack = new bcoin.script.stack();
assert(s.execute(stack));
assert(success(s2.execute(stack), stack));
});
scripts.forEach(function(data) { scripts.forEach(function(data) {
// ["Format is: [[wit...]?, scriptSig, scriptPubKey, flags, expected_scripterror, ... comments]"], // ["Format is: [[wit...]?, scriptSig, scriptPubKey, flags, expected_scripterror, ... comments]"],