bitcore-node-zcash/test/model/transaction.js

77 lines
2.3 KiB
JavaScript
Raw Normal View History

2014-01-08 12:04:45 -08:00
#!/usr/bin/env node
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var
mongoose= require('mongoose'),
assert = require('assert'),
config = require('../../config/config'),
Transaction = require('../../app/models/Transaction');
mongoose.connection.on('error', function(err) { console.log(err); });
describe('Transaction fromIdWithInfo', function(){
2014-01-08 12:04:45 -08:00
before(function(done) {
mongoose.connect(config.db);
done();
});
after(function(done) {
mongoose.connection.close();
done();
});
it('should pool tx\'s object from mongoose', function(done) {
2014-01-09 13:18:47 -08:00
var test_txid = '21798ddc9664ac0ef618f52b151dda82dafaf2e26d2bbef6cdaf55a6957ca237';
Transaction.fromIdWithInfo(test_txid, function(err, tx) {
2014-01-08 12:04:45 -08:00
if (err) done(err);
2014-01-09 13:18:47 -08:00
assert.equal(tx.txid, test_txid);
2014-01-09 13:35:14 -08:00
assert(!tx.info.isCoinBase);
2014-01-08 12:04:45 -08:00
done();
});
});
it('should pool tx\'s info from bitcoind', function(done) {
2014-01-09 13:18:47 -08:00
var test_txid = '21798ddc9664ac0ef618f52b151dda82dafaf2e26d2bbef6cdaf55a6957ca237';
Transaction.fromIdWithInfo(test_txid, function(err, tx) {
2014-01-08 12:04:45 -08:00
if (err) done(err);
2014-01-09 13:18:47 -08:00
assert.equal(tx.info.txid, test_txid);
assert.equal(tx.info.blockhash, '000000000185678d3d7ecc9962c96418174431f93fe20bf216d5565272423f74');
assert.equal(tx.info.valueOut, 1.66174);
assert.equal(tx.info.feeds, 0.0005 );
assert.equal(tx.info.size, 226 );
2014-01-09 13:35:14 -08:00
assert(!tx.info.isCoinBase);
2014-01-08 12:04:45 -08:00
done();
});
});
2014-01-09 13:18:47 -08:00
2014-01-10 10:51:19 -08:00
it('test a coinbase TX 2a104bab1782e9b6445583296d4a0ecc8af304e4769ceb64b890e8219c562399', function(done) {
2014-01-09 13:18:47 -08:00
var test_txid2 = '2a104bab1782e9b6445583296d4a0ecc8af304e4769ceb64b890e8219c562399';
Transaction.fromIdWithInfo(test_txid2, function(err, tx) {
if (err) done(err);
assert(tx.info.isCoinBase);
assert.equal(tx.info.txid, test_txid2);
2014-01-09 13:35:14 -08:00
assert(!tx.info.feeds);
2014-01-09 13:18:47 -08:00
done();
});
});
2014-01-10 10:51:19 -08:00
it('test a broken TX 64496d005faee77ac5a18866f50af6b8dd1f60107d6795df34c402747af98608', function(done) {
var test_txid2 = '64496d005faee77ac5a18866f50af6b8dd1f60107d6795df34c402747af98608';
Transaction.fromIdWithInfo(test_txid2, function(err, tx) {
if (err) done(err);
assert.equal(tx.info.txid, test_txid2);
assert.equal(tx.info.vin[0].addr, null);
done();
});
});
2014-01-09 13:18:47 -08:00
2014-01-08 12:04:45 -08:00
});