tests: add coin tests
This commit is contained in:
parent
17e473fda5
commit
b9f19038ba
42
test/coin-test.js
Normal file
42
test/coin-test.js
Normal file
@ -0,0 +1,42 @@
|
||||
/* eslint-env mocha */
|
||||
/* eslint prefer-arrow-callback: "off" */
|
||||
|
||||
'use strict';
|
||||
|
||||
const Coin = require('../lib/primitives/coin');
|
||||
const assert = require('./util/assert');
|
||||
const common = require('../test/util/common');
|
||||
|
||||
const tx1 = common.readTX('tx1');
|
||||
const coin1 = common.readFile('coin1.raw');
|
||||
|
||||
describe('Coin', function() {
|
||||
it('should instantiate from tx', () => {
|
||||
const [tx] = tx1.getTX();
|
||||
const coin = Coin.fromTX(tx, 0, 0);
|
||||
|
||||
assert.strictEqual(coin.getAddress().toString(),
|
||||
'3KUER9kZ693d5FQgvmr5qNDKnSpP9nXv9v');
|
||||
assert.strictEqual(coin.value, 5000000);
|
||||
assert.strictEqual(coin.getType(), 'multisig');
|
||||
assert.strictEqual(coin.version, 1);
|
||||
assert.strictEqual(coin.height, 0);
|
||||
assert.strictEqual(coin.coinbase, false);
|
||||
assert.strictEqual(coin.txid(),
|
||||
'ff80fe4937e2de16411c3a2bc534d661dc8b4f8aad75e6fbc4b1ec6060d9ef1c');
|
||||
assert.strictEqual(coin.index, 0);
|
||||
});
|
||||
|
||||
it('should instantiate from raw', () => {
|
||||
const coin = Coin.fromRaw(coin1);
|
||||
|
||||
assert.strictEqual(coin.getAddress().toString(),
|
||||
'3KUER9kZ693d5FQgvmr5qNDKnSpP9nXv9v');
|
||||
assert.strictEqual(coin.value, 5000000);
|
||||
assert.strictEqual(coin.getType(), 'multisig');
|
||||
assert.strictEqual(coin.version, 1);
|
||||
assert.strictEqual(coin.height, 0);
|
||||
assert.strictEqual(coin.coinbase, false);
|
||||
assert.strictEqual(coin.index, 0);
|
||||
});
|
||||
});
|
||||
BIN
test/data/coin1.raw
Normal file
BIN
test/data/coin1.raw
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user