handle_inv tests
This commit is contained in:
parent
8c2e118f76
commit
1df72a818c
|
@ -32,7 +32,6 @@
|
||||||
"afterEach",
|
"afterEach",
|
||||||
"it",
|
"it",
|
||||||
"inject",
|
"inject",
|
||||||
"expect",
|
|
||||||
"$",
|
"$",
|
||||||
"io",
|
"io",
|
||||||
"app",
|
"app",
|
||||||
|
|
|
@ -111,6 +111,12 @@ function spec() {
|
||||||
|
|
||||||
peerman.start();
|
peerman.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PeerSync.prototype.close = function() {
|
||||||
|
this.sync.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return PeerSync;
|
return PeerSync;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ function spec() {
|
||||||
this.rpc = new RpcClient(config.bitcoind);
|
this.rpc = new RpcClient(config.bitcoind);
|
||||||
|
|
||||||
|
|
||||||
if (!(opts && opts.skip_db_connection)) {
|
if (!(opts && opts.skip_db_connection) && !mongoose.connection) {
|
||||||
mongoose.connect(config.db, {server: {auto_reconnect: true}} );
|
mongoose.connect(config.db, {server: {auto_reconnect: true}} );
|
||||||
}
|
}
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
|
@ -364,8 +364,9 @@ function spec() {
|
||||||
sync();
|
sync();
|
||||||
}, retry_secs * 1000);
|
}, retry_secs * 1000);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return next(err, that.block_count);
|
return next(err, that.block_count);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +378,6 @@ function spec() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync.prototype.close = function() {
|
Sync.prototype.close = function() {
|
||||||
console.log("closing connection");
|
|
||||||
this.db.close();
|
this.db.close();
|
||||||
};
|
};
|
||||||
return Sync;
|
return Sync;
|
||||||
|
|
|
@ -1,21 +1,39 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
var assert = require('assert');
|
var chai = require('chai'),
|
||||||
|
expect = chai.expect,
|
||||||
|
sinon = require('sinon');
|
||||||
|
|
||||||
var PeerSync = require('../../lib/PeerSync.js').class();
|
var PeerSync = require('../../lib/PeerSync.js').class();
|
||||||
describe('Unit testing PeerSync', function() {
|
describe('PeerSync', function() {
|
||||||
var ps;
|
var ps, inv_info;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ps = new PeerSync();
|
ps = new PeerSync();
|
||||||
|
ps.init();
|
||||||
|
});
|
||||||
|
afterEach(function(){
|
||||||
|
ps.close();
|
||||||
});
|
});
|
||||||
describe('#init()', function() {
|
describe('#init()', function() {
|
||||||
it('should return with no errors', function() {
|
it('should return with no errors', function() {
|
||||||
assert.doesNotThrow(function() {
|
var other_ps = new PeerSync();
|
||||||
ps.init();
|
expect(other_ps.init.bind(other_ps)).not.to.throw(Error);
|
||||||
});
|
other_ps.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#handle_inv()', function() {
|
describe('#handle_inv()', function() {
|
||||||
it('should return with no errors');
|
inv_info = {
|
||||||
it('should call sendGetData');
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('#handle_tx()', function() {
|
describe('#handle_tx()', function() {
|
||||||
it('should call storeTxs');
|
it('should call storeTxs');
|
||||||
|
|
Loading…
Reference in New Issue