refactor tests.

This commit is contained in:
Christopher Jeffrey 2016-04-19 11:59:12 -07:00
parent 0cfbaf91b5
commit 6d7e81080e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 10 additions and 9 deletions

View File

@ -4070,7 +4070,10 @@ Script.parseRaw = function parseRaw(data, enc) {
if (enc === 'hex')
data = new Buffer(data, 'hex');
return Script.parseScript(data);
return {
code: Script.decode(data),
raw: data
};
};
/**

View File

@ -39,15 +39,13 @@ describe('Script', function() {
it('should recognize a P2SH output', function () {
var hex = 'a91419a7d869032368fd1f1e26e5e73a4ad0e474960e87'
var encoded = new Buffer(hex, 'hex')
var decoded = new bcoin.script(encoded);
var decoded = bcoin.script.fromRaw(hex, 'hex');
assert(decoded.isScripthash())
});
it('should recognize a Null Data output', function () {
var hex = '6a28590c080112220a1b353930632e6f7267282a5f5e294f7665726c6179404f7261636c65103b1a010c'
var encoded = new Buffer(hex, 'hex')
var decoded = new Script(encoded);
var decoded = bcoin.script.fromRaw(hex, 'hex');
assert(decoded.isNulldata())
});

View File

@ -96,14 +96,14 @@ describe('TX', function() {
var suffix = nocache ? ' without cache' : ' with cache';
it('should decode/encode with parser/framer' + suffix, function() {
var tx = bcoin.tx(parser.parseTX(new Buffer(raw, 'hex')));
var tx = bcoin.tx.fromRaw(raw, 'hex');
clearCache(tx, nocache);
assert.equal(tx.render().toString('hex'), raw);
});
it('should be verifiable' + suffix, function() {
var tx = bcoin.tx(parser.parseTX(new Buffer(raw, 'hex')));
var p = bcoin.tx(parser.parseTX(new Buffer(inp, 'hex')));
var tx = bcoin.tx.fromRaw(raw, 'hex');
var p = bcoin.tx.fromRaw(inp, 'hex');
tx.fillCoins(p);
clearCache(tx, nocache);
@ -240,7 +240,7 @@ describe('TX', function() {
return;
var tx = bcoin.tx.fromRaw(data[0], 'hex');
clearCache(tx, nocache);
var script = new bcoin.script(new Buffer(data[1], 'hex'));
var script = bcoin.script.fromRaw(data[1], 'hex');
clearCache(script, nocache);
var index = data[2];
var type = data[3];