add tests to _onPublicKeyRing
This commit is contained in:
parent
ab7be87b85
commit
b3584aea77
3 changed files with 69 additions and 14 deletions
|
|
@ -76,6 +76,7 @@ PublicKeyRing.prototype.resetCache = function() {
|
|||
* as a parameter
|
||||
*/
|
||||
PublicKeyRing.trim = function(data) {
|
||||
preconditions.checkArgument(data);
|
||||
var opts = {};
|
||||
['walletId', 'networkName', 'requiredCopayers', 'totalCopayers',
|
||||
'indexes', 'nicknameFor', 'copayersExtPubKeys'
|
||||
|
|
@ -698,6 +699,7 @@ PublicKeyRing.prototype.getRedeemScriptMap = function(paths) {
|
|||
*/
|
||||
|
||||
PublicKeyRing.prototype._checkInPKR = function(inPKR, ignoreId) {
|
||||
preconditions.checkArgument(_.isObject(inPKR));
|
||||
|
||||
if (!ignoreId && this.walletId !== inPKR.walletId)
|
||||
throw new Error('inPKR walletId mismatch');
|
||||
|
|
@ -786,8 +788,8 @@ PublicKeyRing.prototype.mergeIndexes = function(indexes) {
|
|||
* @return {boolean} true if the internal state has changed
|
||||
*/
|
||||
PublicKeyRing.prototype.merge = function(inPKR, ignoreId) {
|
||||
this._checkInPKR(inPKR, ignoreId);
|
||||
|
||||
this._checkInPKR(inPKR, ignoreId);
|
||||
var hasChanged = false;
|
||||
hasChanged |= this.mergeIndexes(inPKR.indexes);
|
||||
hasChanged |= this._mergePubkeys(inPKR);
|
||||
|
|
|
|||
|
|
@ -327,15 +327,18 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
|||
try {
|
||||
hasChanged = this.publicKeyRing.merge(inPKR, true);
|
||||
} catch (e) {
|
||||
log.debug('Wallet:' + this.id + '## WALLET ERROR', e);
|
||||
this.emitAndKeepAlive('connectionError', e.message);
|
||||
log.warn('Wallet:' + this.id, e);
|
||||
return;
|
||||
}
|
||||
if (hasChanged) {
|
||||
console.log('[Wallet.js.333:hasChanged:]',hasChanged); //TODO
|
||||
if (wasIncomplete) {
|
||||
this.sendPublicKeyRing();
|
||||
}
|
||||
|
||||
console.log('[Wallet.js.335:wasIncomplete:]',wasIncomplete); //TODO
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
console.log('[Wallet.js.338]'); //TODO
|
||||
this._lockIncomming();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue