|
@ -51,13 +51,46 @@ describe('Wallet service', function() { |
|
|
describe('#getInstance', function() { |
|
|
describe('#getInstance', function() { |
|
|
it('should get server instance', function() { |
|
|
it('should get server instance', function() { |
|
|
var server = WalletService.getInstance({ |
|
|
var server = WalletService.getInstance({ |
|
|
clientVersion: 'bwc-0.0.1', |
|
|
clientVersion: 'bwc-2.9.0', |
|
|
}); |
|
|
}); |
|
|
server.clientVersion.should.equal('bwc-0.0.1'); |
|
|
server.clientVersion.should.equal('bwc-2.9.0'); |
|
|
|
|
|
}); |
|
|
|
|
|
it('should not get server instance for BWC lower than v1.2', function() { |
|
|
|
|
|
var err; |
|
|
|
|
|
try { |
|
|
|
|
|
var server = WalletService.getInstance({ |
|
|
|
|
|
clientVersion: 'bwc-1.1.99', |
|
|
|
|
|
}); |
|
|
|
|
|
} catch (ex) { |
|
|
|
|
|
err = ex; |
|
|
|
|
|
} |
|
|
|
|
|
should.exist(err); |
|
|
|
|
|
err.code.should.equal('UPGRADE_NEEDED'); |
|
|
|
|
|
}); |
|
|
|
|
|
it('should get server instance for non-BWC clients', function() { |
|
|
|
|
|
var server = WalletService.getInstance({ |
|
|
|
|
|
clientVersion: 'dummy-1.0.0', |
|
|
|
|
|
}); |
|
|
|
|
|
server.clientVersion.should.equal('dummy-1.0.0'); |
|
|
|
|
|
server = WalletService.getInstance({}); |
|
|
|
|
|
(clientVersion == null).should.be.true; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
describe('#getInstanceWithAuth', function() { |
|
|
describe('#getInstanceWithAuth', function() { |
|
|
|
|
|
it('should not get server instance for BWC lower than v1.2', function(done) { |
|
|
|
|
|
var server = WalletService.getInstanceWithAuth({ |
|
|
|
|
|
copayerId: '1234', |
|
|
|
|
|
message: 'hello world', |
|
|
|
|
|
signature: 'xxx', |
|
|
|
|
|
clientVersion: 'bwc-1.1.99', |
|
|
|
|
|
}, function(err, server) { |
|
|
|
|
|
should.exist(err); |
|
|
|
|
|
should.not.exist(server); |
|
|
|
|
|
err.code.should.equal('UPGRADE_NEEDED'); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
it('should get server instance for existing copayer', function(done) { |
|
|
it('should get server instance for existing copayer', function(done) { |
|
|
helpers.createAndJoinWallet(1, 2, function(s, wallet) { |
|
|
helpers.createAndJoinWallet(1, 2, function(s, wallet) { |
|
|
var xpriv = TestData.copayers[0].xPrivKey; |
|
|
var xpriv = TestData.copayers[0].xPrivKey; |
|
@ -69,18 +102,18 @@ describe('Wallet service', function() { |
|
|
copayerId: wallet.copayers[0].id, |
|
|
copayerId: wallet.copayers[0].id, |
|
|
message: 'hello world', |
|
|
message: 'hello world', |
|
|
signature: sig, |
|
|
signature: sig, |
|
|
clientVersion: 'bwc-0.0.1', |
|
|
clientVersion: 'bwc-2.0.0', |
|
|
}, function(err, server) { |
|
|
}, function(err, server) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
server.walletId.should.equal(wallet.id); |
|
|
server.walletId.should.equal(wallet.id); |
|
|
server.copayerId.should.equal(wallet.copayers[0].id); |
|
|
server.copayerId.should.equal(wallet.copayers[0].id); |
|
|
server.clientVersion.should.equal('bwc-0.0.1'); |
|
|
server.clientVersion.should.equal('bwc-2.0.0'); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should fail when requesting for non-existent copayer', function(done) { |
|
|
it.only('should fail when requesting for non-existent copayer', function(done) { |
|
|
var message = 'hello world'; |
|
|
var message = 'hello world'; |
|
|
var opts = { |
|
|
var opts = { |
|
|
copayerId: 'dummy', |
|
|
copayerId: 'dummy', |
|
|