Browse Source

test

activeAddress
Ivan Socolsky 9 years ago
parent
commit
2f990f42a8
  1. 1
      lib/errors/errordefinitions.js
  2. 4
      lib/server.js
  3. 26
      test/integration/server.js

1
lib/errors/errordefinitions.js

@ -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',

4
lib/server.js

@ -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 = [{

26
test/integration/server.js

@ -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() {

Loading…
Cancel
Save