You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.8 KiB
107 lines
2.8 KiB
'use strict';
|
|
|
|
var should = require('chai').should();
|
|
var bitcore = require('..');
|
|
var BN = bitcore.BN;
|
|
var Txout = bitcore.Txout;
|
|
var Script = bitcore.Script;
|
|
var Varint = bitcore.Varint;
|
|
var BufferReader = bitcore.BufferReader;
|
|
|
|
describe('Txout', function() {
|
|
|
|
var valuebn = BN(5);
|
|
var script = Script().fromString('OP_CHECKMULTISIG');
|
|
var scriptvi = Varint(script.toBuffer().length);
|
|
|
|
it('should make a new txout', function() {
|
|
var txout = new Txout();
|
|
should.exist(txout);
|
|
txout = Txout();
|
|
should.exist(txout);
|
|
Txout(valuebn, scriptvi, script).valuebn.toString().should.equal('5');
|
|
});
|
|
|
|
describe('#set', function() {
|
|
|
|
it('should set this object', function() {
|
|
var txout = new Txout().set({
|
|
valuebn: valuebn,
|
|
scriptvi: scriptvi,
|
|
script: script
|
|
});
|
|
should.exist(txout.valuebn);
|
|
should.exist(txout.scriptvi);
|
|
should.exist(txout.script);
|
|
});
|
|
|
|
});
|
|
|
|
describe('#fromJSON', function() {
|
|
|
|
it('should set from this json', function() {
|
|
var txout = Txout().fromJSON({
|
|
valuebn: valuebn.toJSON(),
|
|
scriptvi: scriptvi.toJSON(),
|
|
script: script.toJSON()
|
|
});
|
|
should.exist(txout.valuebn);
|
|
should.exist(txout.scriptvi);
|
|
should.exist(txout.script);
|
|
});
|
|
|
|
});
|
|
|
|
describe('#toJSON', function() {
|
|
|
|
it('should return this json', function() {
|
|
var txout = Txout().fromJSON({
|
|
valuebn: valuebn.toJSON(),
|
|
scriptvi: scriptvi.toJSON(),
|
|
script: script.toJSON()
|
|
});
|
|
var json = txout.toJSON();
|
|
should.exist(json.valuebn);
|
|
should.exist(json.scriptvi);
|
|
should.exist(json.script);
|
|
});
|
|
|
|
});
|
|
|
|
describe('#fromBuffer', function() {
|
|
|
|
it('should make this txin from this known buffer', function() {
|
|
var txout = Txout().fromBuffer(new Buffer('050000000000000001ae', 'hex'));
|
|
txout.toBuffer().toString('hex').should.equal('050000000000000001ae');
|
|
});
|
|
|
|
});
|
|
|
|
describe('#fromBufferReader', function() {
|
|
|
|
it('should make this txin from this known buffer', function() {
|
|
var txout = Txout().fromBufferReader(BufferReader(new Buffer('050000000000000001ae', 'hex')));
|
|
txout.toBuffer().toString('hex').should.equal('050000000000000001ae');
|
|
});
|
|
|
|
});
|
|
|
|
describe('#toBuffer', function() {
|
|
|
|
it('should output this known buffer', function() {
|
|
var txout = Txout().fromBufferReader(BufferReader(new Buffer('050000000000000001ae', 'hex')));
|
|
txout.toBuffer().toString('hex').should.equal('050000000000000001ae');
|
|
});
|
|
|
|
});
|
|
|
|
describe('#toBufferWriter', function() {
|
|
|
|
it('should output this known buffer', function() {
|
|
var txout = Txout().fromBufferReader(BufferReader(new Buffer('050000000000000001ae', 'hex')));
|
|
txout.toBufferWriter().concat().toString('hex').should.equal('050000000000000001ae');
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|