Fixed typo on getAddressesOrdered
This commit is contained in:
parent
27e0a8a560
commit
e415604870
5 changed files with 38 additions and 17 deletions
|
|
@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('ReceiveController',
|
|||
$scope.showAll = false;
|
||||
|
||||
var w = $rootScope.wallet;
|
||||
var lastAddr = _.first(w.getAddressesOrderer());
|
||||
var lastAddr = _.first(w.getAddressesOrdered());
|
||||
var balance = w.balanceInfo.balanceByAddr;
|
||||
$scope.setAddressList();
|
||||
|
||||
|
|
|
|||
|
|
@ -540,13 +540,13 @@ PublicKeyRing.prototype.getAddresses = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* getAddressesOrderer
|
||||
* {@link Wallet#getAddressesOrderer}
|
||||
* getAddressesOrdered
|
||||
* {@link Wallet#getAddressesOrdered}
|
||||
*
|
||||
* @param pubkey
|
||||
* @return {string[]}
|
||||
*/
|
||||
PublicKeyRing.prototype.getAddressesOrderer = function(pubkey) {
|
||||
PublicKeyRing.prototype.getAddressesOrdered = function(pubkey) {
|
||||
this._checkCache();
|
||||
|
||||
var info = _.map(this.cache.addressToPath, function(path, addr) {
|
||||
|
|
@ -559,9 +559,7 @@ PublicKeyRing.prototype.getAddressesOrderer = function(pubkey) {
|
|||
var l = info.length;
|
||||
|
||||
var sortedInfo = _.sortBy(info, function(i) {
|
||||
var goodness = ( (i.copayerIndex !== copayerIndex) ? 2 * l : 0 )
|
||||
+ ( i.isChange ? l : 0 )
|
||||
+ l - i.addressIndex;
|
||||
var goodness = ((i.copayerIndex !== copayerIndex) ? 2 * l : 0) + (i.isChange ? l : 0) + l - i.addressIndex;
|
||||
return goodness;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2062,13 +2062,13 @@ Wallet.prototype.getAddresses = function() {
|
|||
|
||||
|
||||
/**
|
||||
* @desc gets the list of addresses, orderder for the caller:
|
||||
* @desc gets the list of addresses, ordered for the caller:
|
||||
* 1) himselfs first
|
||||
* 2) receive address first
|
||||
* 3) last created first
|
||||
*/
|
||||
Wallet.prototype.getAddressesOrderer = function() {
|
||||
return this.publicKeyRing.getAddressesOrderer(this.publicKey);
|
||||
Wallet.prototype.getAddressesOrdered = function() {
|
||||
return this.publicKeyRing.getAddressesOrdered(this.publicKey);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ describe('PublicKeyRing model', function() {
|
|||
[true, false].forEach(function(isChange) {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var aStr = w.generateAddress(isChange, k.pub);
|
||||
var a= new bitcore.Address(aStr);
|
||||
var a = new bitcore.Address(aStr);
|
||||
a.isValid().should.equal(true);
|
||||
a.isScript().should.equal(true);
|
||||
a.network().name.should.equal('livenet');
|
||||
|
|
@ -161,8 +161,8 @@ describe('PublicKeyRing model', function() {
|
|||
var setup = getCachedW();
|
||||
var pubkeyring = setup.w;
|
||||
var address = pubkeyring.generateAddress(false, setup.pub);
|
||||
_.indexOf(pubkeyring.getReceiveAddresses(),address).should.be.above(-1);
|
||||
_.indexOf(pubkeyring.getAddresses(),address).should.be.above(-1);
|
||||
_.indexOf(pubkeyring.getReceiveAddresses(), address).should.be.above(-1);
|
||||
_.indexOf(pubkeyring.getAddresses(), address).should.be.above(-1);
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -170,8 +170,8 @@ describe('PublicKeyRing model', function() {
|
|||
var setup = getCachedW();
|
||||
var pubkeyring = setup.w;
|
||||
var address = pubkeyring.generateAddress(true, setup.pub);
|
||||
_.indexOf(pubkeyring.getReceiveAddresses(),address).should.be.equal(-1);
|
||||
_.indexOf(pubkeyring.getAddresses(),address).should.be.above(-1);
|
||||
_.indexOf(pubkeyring.getReceiveAddresses(), address).should.be.equal(-1);
|
||||
_.indexOf(pubkeyring.getAddresses(), address).should.be.above(-1);
|
||||
});
|
||||
|
||||
it('should generate one address by default', function() {
|
||||
|
|
@ -179,6 +179,8 @@ describe('PublicKeyRing model', function() {
|
|||
var w = k.w;
|
||||
var a = w.getAddresses();
|
||||
a.length.should.equal(1);
|
||||
var b = w.getAddressesOrdered();
|
||||
b.length.should.equal(1);
|
||||
});
|
||||
|
||||
it('should generate one address by default', function() {
|
||||
|
|
@ -190,7 +192,7 @@ describe('PublicKeyRing model', function() {
|
|||
a = w.getAddresses();
|
||||
a.length.should.equal(1);
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('should generate 4+1 addresses', function() {
|
||||
var k = createW();
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ describe('Wallet model', function() {
|
|||
it('should getNetworkName', function() {
|
||||
var w = cachedCreateW();
|
||||
w.getNetworkName().should.equal('testnet');
|
||||
w.isTestnet().should.be.true;
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -155,6 +156,7 @@ describe('Wallet model', function() {
|
|||
var w = cachedCreateW();
|
||||
should.exist(w);
|
||||
w.publicKeyRing.walletId.should.equal(w.id);
|
||||
w.getId().should.equal(w.id);
|
||||
w.txProposals.walletId.should.equal(w.id);
|
||||
w.requiredCopayers.should.equal(3);
|
||||
should.exist(w.id);
|
||||
|
|
@ -318,6 +320,7 @@ describe('Wallet model', function() {
|
|||
var w = cachedCreateW2();
|
||||
unSpentTestFromWallet(unspentTest[0], w.publicKeyRing.generateAddress(true));
|
||||
|
||||
|
||||
var txp = w._createTxProposal(
|
||||
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
|
||||
'123456789',
|
||||
|
|
@ -325,11 +328,13 @@ describe('Wallet model', function() {
|
|||
unspentTest
|
||||
);
|
||||
|
||||
w.addSeenToTxProposals().should.be.false;
|
||||
Object.keys(txp.getSignersPubKeys()).length.should.equal(1);
|
||||
var tx = txp.builder.build();
|
||||
should.exist(tx);
|
||||
chai.expect(txp.comment).to.be.null;
|
||||
tx.isComplete().should.equal(false);
|
||||
w.addSeenToTxProposals().should.be.false;
|
||||
Object.keys(txp.seenBy).length.should.equal(1);
|
||||
Object.keys(txp.signedBy).length.should.equal(1);
|
||||
});
|
||||
|
|
@ -377,6 +382,12 @@ describe('Wallet model', function() {
|
|||
|
||||
wallet.addressIsOwn('mmHqhvTVbxgJTnePa7cfweSRjBCy9bQQXJ').should.equal(false);
|
||||
wallet.addressIsOwn('mgtUfP9sTJ6vPLoBxZLPEccGpcjNVryaCX').should.equal(false);
|
||||
|
||||
|
||||
allAddresses = wallet.getAddressesOrdered();
|
||||
for (var i = 0; i < allAddresses.length; i++) {
|
||||
wallet.addressIsOwn(allAddresses[i]).should.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('#create. Signing with derivate keys', function() {
|
||||
|
|
@ -874,7 +885,9 @@ describe('Wallet model', function() {
|
|||
}, function(err, ntxid) {
|
||||
var s = sinon.stub(w, 'getMyCopayerId').returns('213');
|
||||
Object.keys(w.txProposals.get(ntxid).rejectedBy).length.should.equal(0);
|
||||
w.addSeenToTxProposals().should.be.true;
|
||||
w.reject(ntxid);
|
||||
|
||||
Object.keys(w.txProposals.get(ntxid).rejectedBy).length.should.equal(1);
|
||||
w.txProposals.get(ntxid).rejectedBy['213'].should.gt(1);
|
||||
s.restore();
|
||||
|
|
@ -2053,6 +2066,15 @@ describe('Wallet model', function() {
|
|||
payload.walletId.should.equal(w.id);
|
||||
payload.txProposal.should.deep.equal(txp.toObjTrim());
|
||||
});
|
||||
it('should be able to sendAllTxProposals since ', function() {
|
||||
w.txProposals.add(txp);
|
||||
w.sendAllTxProposals(null, txp.createdTs);
|
||||
w.network.send.calledOnce.should.equal(true);
|
||||
var payload = w.network.send.getCall(0).args[1];
|
||||
payload.type.should.equal('txProposal');
|
||||
payload.walletId.should.equal(w.id);
|
||||
payload.txProposal.should.deep.equal(txp.toObjTrim());
|
||||
});
|
||||
it('should be able to sendSignature', function() {
|
||||
w.txProposals.add(txp);
|
||||
w.sendSignature(txp.getId());
|
||||
|
|
@ -2541,7 +2563,6 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
// TODO
|
||||
describe.skip('#onPayProPaymentAck', function() {
|
||||
it('should emit', function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue