2014-01-15 07:53:44 -08:00
|
|
|
'use strict';
|
2014-01-16 11:12:32 -08:00
|
|
|
var chai = require('chai'),
|
|
|
|
expect = chai.expect,
|
|
|
|
sinon = require('sinon');
|
|
|
|
|
2014-01-15 07:53:44 -08:00
|
|
|
var PeerSync = require('../../lib/PeerSync.js').class();
|
2014-01-16 11:12:32 -08:00
|
|
|
describe('PeerSync', function() {
|
|
|
|
var ps, inv_info;
|
2014-01-16 08:01:10 -08:00
|
|
|
beforeEach(function() {
|
|
|
|
ps = new PeerSync();
|
2014-01-16 11:12:32 -08:00
|
|
|
ps.init();
|
|
|
|
});
|
|
|
|
afterEach(function(){
|
|
|
|
ps.close();
|
2014-01-16 08:01:10 -08:00
|
|
|
});
|
2014-01-15 07:53:44 -08:00
|
|
|
describe('#init()', function() {
|
|
|
|
it('should return with no errors', function() {
|
2014-01-16 11:12:32 -08:00
|
|
|
var other_ps = new PeerSync();
|
|
|
|
expect(other_ps.init.bind(other_ps)).not.to.throw(Error);
|
|
|
|
other_ps.close();
|
2014-01-15 07:53:44 -08:00
|
|
|
});
|
|
|
|
});
|
2014-01-16 08:01:10 -08:00
|
|
|
describe('#handle_inv()', function() {
|
2014-01-16 11:12:32 -08:00
|
|
|
inv_info = {
|
|
|
|
message: {invs: []},
|
|
|
|
conn: {sendGetData: sinon.spy()}
|
|
|
|
};
|
|
|
|
it('should return with no errors', function(){
|
|
|
|
expect(function() {
|
|
|
|
ps.handle_inv(inv_info);
|
|
|
|
}).not.to.throw(Error);
|
|
|
|
});
|
|
|
|
it('should call sendGetData', function() {
|
|
|
|
ps.handle_inv(inv_info);
|
|
|
|
expect(inv_info.conn.calledOnce);
|
|
|
|
});
|
2014-01-16 08:01:10 -08:00
|
|
|
});
|
|
|
|
describe('#handle_tx()', function() {
|
|
|
|
it('should call storeTxs');
|
|
|
|
});
|
|
|
|
describe('#handle_block()', function() {
|
|
|
|
it('should call storeBlock');
|
|
|
|
it('should call storeTxs for each transaction');
|
|
|
|
});
|
|
|
|
describe('#run()', function() {
|
|
|
|
it('should setup peerman');
|
|
|
|
});
|
2014-01-15 07:53:44 -08:00
|
|
|
});
|
|
|
|
|