forked from bcoin-org/bcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoin-test.js
42 lines (35 loc) · 1.34 KB
/
coin-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
});
});