Skip to content

Commit

Permalink
Merge pull request bcoin-org#324 from tuxcanfly/test-coin
Browse files Browse the repository at this point in the history
Primitives tests: coin
  • Loading branch information
chjj authored Oct 19, 2017
2 parents 9098d4d + b9f1903 commit af64e2d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/coin-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
Binary file added test/data/coin1.raw
Binary file not shown.

0 comments on commit af64e2d

Please sign in to comment.