fixed outpoint bug and added first test
This commit is contained in:
parent
bab42bbed8
commit
68b3ddf482
@ -69,7 +69,7 @@ Outpoint.fromOptions = function fromOptions(options) {
|
|||||||
|
|
||||||
Outpoint.prototype.clone = function clone() {
|
Outpoint.prototype.clone = function clone() {
|
||||||
const outpoint = new Outpoint();
|
const outpoint = new Outpoint();
|
||||||
outpoint.hash = this.value;
|
outpoint.hash = this.hash;
|
||||||
outpoint.index = this.index;
|
outpoint.index = this.index;
|
||||||
return outpoint;
|
return outpoint;
|
||||||
};
|
};
|
||||||
|
|||||||
26
test/outpoint-test.js
Normal file
26
test/outpoint-test.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Outpoint = require('../lib/primitives/outpoint');
|
||||||
|
const assert = require('./util/assert');
|
||||||
|
const common = require('./util/common');
|
||||||
|
|
||||||
|
const OUTPOINT_SIZE = 36;
|
||||||
|
const tx1 = common.readTX('tx1').getRaw();
|
||||||
|
const rawOutpoint1 = tx1.slice(5, 5+OUTPOINT_SIZE);
|
||||||
|
|
||||||
|
const tx2 = common.readTX('tx2').getRaw();
|
||||||
|
const rawOutpoint2 = tx2.slice(5, 5+OUTPOINT_SIZE);
|
||||||
|
|
||||||
|
describe('Outpoint', () => {
|
||||||
|
it('should clone the outpoint correctly', () => {
|
||||||
|
const raw = rawOutpoint1.slice();
|
||||||
|
const outpointObject = Outpoint.fromRaw(raw);
|
||||||
|
const clone = outpointObject.clone();
|
||||||
|
const equals = outpointObject.equals(clone);
|
||||||
|
|
||||||
|
assert.strictEqual(outpointObject !== clone, true);
|
||||||
|
assert.strictEqual(equals, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user