basic Transaction test working

This commit is contained in:
Manuel Araoz 2014-02-28 09:37:02 -03:00
parent 6755b84fbf
commit ade6f36c34
2 changed files with 2 additions and 7 deletions

View File

@ -26,7 +26,7 @@ function spec(b) {
if (data.o) { if (data.o) {
this.o = data.o; this.o = data.o;
} else { } else {
if (data.oTxHash && typeof data.oIndex !== 'undefined') { if (data.oTxHash && typeof data.oIndex !== 'undefined' && data.oIndex >= 0) {
var hash = new Buffer(data.oTxHash, 'hex'); var hash = new Buffer(data.oTxHash, 'hex');
hash = buffertools.reverse(hash); hash = buffertools.reverse(hash);
var voutBuf = new Buffer(4); var voutBuf = new Buffer(4);
@ -153,7 +153,6 @@ function spec(b) {
bufs.push(buf); bufs.push(buf);
bufs.push(util.varIntBuf(this.ins.length)); bufs.push(util.varIntBuf(this.ins.length));
console.log(this.ins.length);
this.ins.forEach(function (txin) { this.ins.forEach(function (txin) {
bufs.push(txin.serialize()); bufs.push(txin.serialize());
}); });
@ -650,7 +649,6 @@ function spec(b) {
Transaction.prototype.parse = function (parser) { Transaction.prototype.parse = function (parser) {
if (Buffer.isBuffer(parser)) { if (Buffer.isBuffer(parser)) {
console.dir(parser);
this._buffer = parser; this._buffer = parser;
parser = new Parser(parser); parser = new Parser(parser);
} }

View File

@ -55,13 +55,10 @@ describe('Transaction', function() {
ins.push(input); ins.push(input);
}); });
var raw = new Buffer(datum[1]); var raw = new Buffer(datum[1], 'hex');
var tx = new Transaction(); var tx = new Transaction();
tx.parse(raw); tx.parse(raw);
buffertools.toHex(tx.serialize()).should.equal(buffertools.toHex(raw)); buffertools.toHex(tx.serialize()).should.equal(buffertools.toHex(raw));
}); });
} }
}); });