refactor tests.
This commit is contained in:
parent
0cfbaf91b5
commit
6d7e81080e
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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())
|
||||
});
|
||||
|
||||
|
||||
@ -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];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user