This commit is contained in:
Ivan Socolsky 2015-10-27 15:38:11 -03:00
parent f00b5dbe68
commit 2f990f42a8
3 changed files with 30 additions and 1 deletions

View File

@ -17,6 +17,7 @@ var errors = {
INVALID_ADDRESS: 'Invalid address',
KEY_IN_COPAYER: 'Key already registered',
LOCKED_FUNDS: 'Funds are locked by pending transaction proposals',
MAIN_ADDRESS_GAP_REACHED: 'Maximum number of consecutive addresses without activity reached',
NOT_AUTHORIZED: 'Not authorized',
TOO_MANY_KEYS: 'Too many keys registered',
TX_ALREADY_BROADCASTED: 'The transaction proposal is already broadcasted',

View File

@ -63,9 +63,11 @@ WalletService.BACKOFF_OFFSET = 3;
// Time a copayer need to wait to create a new TX after her tx previous proposal we rejected. (incremental). in Minutes.
WalletService.BACKOFF_TIME = 2;
WalletService.MAX_MAIN_ADDRESS_GAP = 20;
// Fund scanning parameters
WalletService.SCAN_CONFIG = {
maxGap: 20,
maxGap: WalletService.MAX_MAIN_ADDRESS_GAP,
};
WalletService.FEE_LEVELS = [{

View File

@ -1667,6 +1667,32 @@ describe('Wallet service', function() {
});
});
});
it.only('should fail to create more consecutive addresses with no activity than allowed', function(done) {
var MAX_MAIN_ADDRESS_GAP_old = WalletService.MAX_MAIN_ADDRESS_GAP;
var n = WalletService.MAX_MAIN_ADDRESS_GAP = 2;
helpers.stubAddressActivity([]);
async.map(_.range(n), function(i, next) {
server.createAddress({}, next);
}, function(err, addresses) {
addresses.length.should.equal(n);
server.createAddress({}, function(err, address) {
should.exist(err);
should.not.exist(address);
err.code.should.equal('MAIN_ADDRESS_GAP_REACHED');
server.createAddress({
ignoreMaxGap: true
}, function(err, address) {
should.not.exist(err);
should.exist(address);
address.path.should.equal('m/0/' + n);
WalletService.MAX_MAIN_ADDRESS_GAP = MAX_MAIN_ADDRESS_GAP_old;
done();
});
});
});
});
});
describe('1-of-1 (BIP44 & P2PKH)', function() {