WIP for automatic network join
This commit is contained in:
parent
ef3c8e2865
commit
d62dbeffca
12 changed files with 73 additions and 76 deletions
27
test/mocks/FakeNetwork.js
Normal file
27
test/mocks/FakeNetwork.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
var imports = require('soop').imports();
|
||||
var EventEmitter= imports.EventEmitter || require('events').EventEmitter;
|
||||
|
||||
function Network(opts) {
|
||||
}
|
||||
|
||||
Network.parent=EventEmitter;
|
||||
|
||||
Network.prototype.start = function(openCallback, opts) {
|
||||
// start! :D
|
||||
};
|
||||
|
||||
Network.prototype.send = function(peerIds, data, cb) {
|
||||
// send! c:
|
||||
};
|
||||
|
||||
Network.prototype.connectTo = function(peerId) {
|
||||
// connect C:
|
||||
};
|
||||
|
||||
|
||||
Network.prototype.disconnect = function(cb) {
|
||||
// disconect :c
|
||||
};
|
||||
|
||||
module.exports = require('soop')(Network);
|
||||
|
|
@ -69,16 +69,15 @@ describe('PrivateKey model', function() {
|
|||
|
||||
it('should calculate .id', function () {
|
||||
var w1 = new PrivateKey(config);
|
||||
should.exist(w1.id);
|
||||
w1.id.length.should.equal(40);
|
||||
should.exist(w1.getId());
|
||||
w1.getId().length.should.equal(40);
|
||||
});
|
||||
it('fromObj toObj roundtrip', function () {
|
||||
var w1 = new PrivateKey(config);
|
||||
var w2 = PrivateKey.fromObj(w1.toObj());
|
||||
|
||||
w2.toObj().extendedPrivateKeyString.should.equal(w1.toObj().extendedPrivateKeyString);
|
||||
w2.id.should.equal(w1.id);
|
||||
|
||||
w2.getId().should.equal(w1.getId());
|
||||
|
||||
JSON.stringify(w2.get(1,1).storeObj()).should
|
||||
.equal(JSON.stringify(w1.get(1,1).storeObj()));
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
|
||||
var WebRTC = require('../js/models/network/WebRTC');
|
||||
var FakeNetwork = require('./mocks/FakeNetwork');
|
||||
var Insight = require('../js/models/blockchain/Insight');
|
||||
var FakeStorage = require('./mocks/FakeStorage');
|
||||
|
||||
var WalletFactory = typeof copay === 'undefined' ? require('soop').load('../js/models/core/WalletFactory',{
|
||||
Network: WebRTC,
|
||||
Network: FakeNetwork,
|
||||
Blockchain: Insight,
|
||||
Storage: FakeStorage,
|
||||
}) : copay.WalletFactory;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue