bitcoinjs-lib/test/network.js

35 lines
881 B
JavaScript
Raw Normal View History

2014-06-17 08:48:06 +02:00
var assert = require('assert')
var networks = require('../src/networks')
var sinon = require('sinon')
2014-06-17 08:48:06 +02:00
var Transaction = require('../src/transaction')
2014-06-18 09:27:36 +02:00
var fixtures = require('./fixtures/network')
describe('networks', function() {
var txToBuffer
before(function(){
txToBuffer = sinon.stub(Transaction.prototype, "toBuffer")
})
after(function(){
Transaction.prototype.toBuffer.restore()
})
2014-06-18 09:27:36 +02:00
fixtures.valid.forEach(function(f) {
describe(f.network + ' estimateFee', function() {
var network = networks[f.network]
2014-06-18 09:27:36 +02:00
it('calculates the fee correctly for ' + f.description, function() {
var buffer = new Buffer(f.txSize)
txToBuffer.returns(buffer)
2014-06-17 08:48:06 +02:00
2014-06-18 09:27:36 +02:00
var estimateFee = network.estimateFee
var tx = new Transaction()
2014-06-18 09:27:36 +02:00
tx.outs = f.outputs || []
2014-06-18 09:27:36 +02:00
assert.equal(estimateFee(tx), f.fee)
})
2014-06-17 08:48:06 +02:00
})
})
})