Added integration tests for getting blocks.
This commit is contained in:
parent
b9aa8a4d4f
commit
1e67cd3ac1
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
// These tests require a fully synced Bitcore Code data directory.
|
||||
var chai = require('chai');
|
||||
var bitcore = require('bitcore');
|
||||
var bitcoind;
|
||||
|
||||
/* jshint unused: false */
|
||||
var should = chai.should();
|
||||
var assert = chai.assert;
|
||||
var sinon = require('sinon');
|
||||
var blockData = require('./livenet-block-data.json');
|
||||
|
||||
describe('Basic Functionality', function() {
|
||||
|
||||
before(function(done) {
|
||||
this.timeout(30000);
|
||||
bitcoind = require('../')({
|
||||
directory: '~/.bitcoin',
|
||||
});
|
||||
|
||||
bitcoind.on('error', function(err) {
|
||||
bitcoind.log('error="%s"', err.message);
|
||||
});
|
||||
|
||||
bitcoind.on('open', function(status) {
|
||||
bitcoind.log('status="%s"', status);
|
||||
});
|
||||
|
||||
console.log('Waiting for Bitcoin Core to initialize...');
|
||||
|
||||
bitcoind.on('ready', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('will get correct block data', function() {
|
||||
|
||||
blockData.forEach(function(data) {
|
||||
var block = bitcore.Block.fromString(data);
|
||||
it('block ' + block.hash, function(done) {
|
||||
bitcoind.getBlock(block.hash, function(err, response) {
|
||||
assert(response === data, 'incorrect block data for ' + block.hash);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
File diff suppressed because one or more lines are too long
|
@ -39,8 +39,11 @@
|
|||
"tiny": "0.0.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~1.16.2",
|
||||
"async": "1.2.1",
|
||||
"benchmark": "1.0.0"
|
||||
"benchmark": "1.0.0",
|
||||
"bitcore": "^0.12.12",
|
||||
"chai": "3.0.0",
|
||||
"mocha": "~1.16.2",
|
||||
"sinon": "^1.15.4"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue