|
@ -75,6 +75,7 @@ helpers.getAuthServer = function(copayerId, cb) { |
|
|
|
|
|
|
|
|
helpers.createAndJoinWallet = function(id, m, n, cb) { |
|
|
helpers.createAndJoinWallet = function(id, m, n, cb) { |
|
|
var server = new CopayServer(); |
|
|
var server = new CopayServer(); |
|
|
|
|
|
var copayerIds = []; |
|
|
|
|
|
|
|
|
var walletOpts = { |
|
|
var walletOpts = { |
|
|
id: id, |
|
|
id: id, |
|
@ -90,19 +91,19 @@ helpers.createAndJoinWallet = function(id, m, n, cb) { |
|
|
|
|
|
|
|
|
var copayerOpts = { |
|
|
var copayerOpts = { |
|
|
walletId: id, |
|
|
walletId: id, |
|
|
id: '' + i, |
|
|
|
|
|
name: 'copayer ' + i, |
|
|
name: 'copayer ' + i, |
|
|
xPubKey: someXPubKeys[i - 1], |
|
|
xPubKey: someXPubKeys[i - 1], |
|
|
xPubKeySignature: someXPubKeysSignatures[i - 1], |
|
|
xPubKeySignature: someXPubKeysSignatures[i - 1], |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
server.joinWallet(copayerOpts, function(err, copayerId) { |
|
|
|
|
|
copayerIds.push(copayerId); |
|
|
return cb(err); |
|
|
return cb(err); |
|
|
}); |
|
|
}); |
|
|
}, function(err) { |
|
|
}, function(err) { |
|
|
if (err) return new Error('Could not generate wallet'); |
|
|
if (err) return new Error('Could not generate wallet'); |
|
|
|
|
|
|
|
|
helpers.getAuthServer('1', function(s) { |
|
|
helpers.getAuthServer(copayerIds[0], function(s) { |
|
|
s.getWallet({}, function(err, w) { |
|
|
s.getWallet({}, function(err, w) { |
|
|
cb(s, w); |
|
|
cb(s, w); |
|
|
}); |
|
|
}); |
|
@ -333,20 +334,19 @@ describe('Copay server', function() { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
var copayerOpts = { |
|
|
var copayerOpts = { |
|
|
walletId: '123', |
|
|
walletId: '123', |
|
|
id: '999', |
|
|
|
|
|
name: 'me', |
|
|
name: 'me', |
|
|
xPubKey: aXPubKey, |
|
|
xPubKey: aXPubKey, |
|
|
xPubKeySignature: aXPubKeySignature, |
|
|
xPubKeySignature: aXPubKeySignature, |
|
|
}; |
|
|
}; |
|
|
server.joinWallet(copayerOpts, function(err) { |
|
|
server.joinWallet(copayerOpts, function(err, copayerId) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
helpers.getAuthServer('999', function(server) { |
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
wallet.id.should.equal('123'); |
|
|
wallet.id.should.equal('123'); |
|
|
wallet.copayers.length.should.equal(1); |
|
|
wallet.copayers.length.should.equal(1); |
|
|
var copayer = wallet.copayers[0]; |
|
|
var copayer = wallet.copayers[0]; |
|
|
copayer.id.should.equal('999'); |
|
|
|
|
|
copayer.name.should.equal('me'); |
|
|
copayer.name.should.equal('me'); |
|
|
|
|
|
copayer.id.should.equal(copayerId); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -366,7 +366,6 @@ describe('Copay server', function() { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
var copayerOpts = { |
|
|
var copayerOpts = { |
|
|
walletId: '234', |
|
|
walletId: '234', |
|
|
id: '999', |
|
|
|
|
|
name: 'me', |
|
|
name: 'me', |
|
|
xPubKey: 'dummy', |
|
|
xPubKey: 'dummy', |
|
|
xPubKeySignature: 'dummy', |
|
|
xPubKeySignature: 'dummy', |
|
@ -402,12 +401,12 @@ describe('Copay server', function() { |
|
|
xPubKey: someXPubKeys[1], |
|
|
xPubKey: someXPubKeys[1], |
|
|
xPubKeySignature: someXPubKeysSignatures[1], |
|
|
xPubKeySignature: someXPubKeysSignatures[1], |
|
|
}; |
|
|
}; |
|
|
server.joinWallet(copayer1Opts, function(err) { |
|
|
server.joinWallet(copayer1Opts, function(err, copayer1Id) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
helpers.getAuthServer('111', function(server) { |
|
|
helpers.getAuthServer(copayer1Id, function(server) { |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
server.getWallet({}, function(err, wallet) { |
|
|
wallet.status.should.equal('complete'); |
|
|
wallet.status.should.equal('complete'); |
|
|
server.joinWallet(copayer2Opts, function(err) { |
|
|
server.joinWallet(copayer2Opts, function(err, copayer2Id) { |
|
|
should.exist(err); |
|
|
should.exist(err); |
|
|
err.code.should.equal('WFULL'); |
|
|
err.code.should.equal('WFULL'); |
|
|
err.message.should.equal('Wallet full'); |
|
|
err.message.should.equal('Wallet full'); |
|
@ -563,7 +562,7 @@ describe('Copay server', function() { |
|
|
message: aText, |
|
|
message: aText, |
|
|
signature: aTextSignature, |
|
|
signature: aTextSignature, |
|
|
}; |
|
|
}; |
|
|
helpers.getAuthServer('2', function (server) { |
|
|
helpers.getAuthServer(wallet.copayers[1].id, function (server) { |
|
|
server.verifyMessageSignature(opts, function(err, isValid) { |
|
|
server.verifyMessageSignature(opts, function(err, isValid) { |
|
|
should.not.exist(err); |
|
|
should.not.exist(err); |
|
|
isValid.should.be.false; |
|
|
isValid.should.be.false; |
|
|