Skip to content

Commit b9d3ce3

Browse files
committed
Tests should at least run
1 parent 05cbb01 commit b9d3ce3

File tree

11 files changed

+195
-338
lines changed

11 files changed

+195
-338
lines changed

packages/bitcore-wallet-client/.gitignore

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,19 @@ build/Release
2323
# Dependency directory
2424
# Commenting this out is preferred by some people, see
2525
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
26-
node_modules
2726

2827
# Users Environment Variables
2928
.lock-wscript
3029

31-
*.swp
3230
out/
3331
db/*
3432

3533
docs
3634

37-
# VIM ignore
38-
[._]*.s[a-w][a-z]
39-
[._]s[a-w][a-z]
40-
*.un~
41-
Session.vim
42-
.netrwhist
43-
*~
44-
4535
# OSX
46-
.DS_Store
4736
.AppleDouble
4837
.LSOverride
4938

50-
ts_build
5139

5240
*debug.log
5341
node_modules/
@@ -65,4 +53,3 @@ Session.vim
6553
.netrwhist
6654
*~
6755
ts_build
68-
built/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var Client = require('./src/lib');
1+
var Client = require('./ts_build');
22
module.exports = Client;
33

44
// Errors thrown by the library
5-
Client.errors = require('./src/lib/errors');
5+
Client.errors = require('./ts_build/errors');

packages/bitcore-wallet-client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@
5959
"typescript-eslint-parser": "^22.0.0"
6060
},
6161
"scripts": {
62-
"start": "npm run clean && npm run tsc && ./start.sh",
62+
"start": "npm run clean && npm run tsc && node app.js",
6363
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",
6464
"test": "./node_modules/.bin/mocha --exit",
6565
"test:ci": "npm run test",
66-
"stop": "./stop.sh",
6766
"docs": "./node_modules/.bin/jsdox lib/* lib/common lib/errors -o docs && cat README.header.md docs/*.md LICENSE > README.md",
6867
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
6968
"compile": "npm run tsc",

packages/bitcore-wallet-client/src/lib/api.ts

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -324,140 +324,6 @@ export class API extends EventEmitter {
324324
this.request.setCredentials(this.credentials);
325325
}
326326

327-
/**
328-
* Import from Mnemonics (language autodetected)
329-
* Can throw an error if mnemonic is invalid
330-
* Will try compilant and non-compliantDerivation
331-
*
332-
* @param {String} BIP39 words
333-
* @param {Object} opts
334-
* @param {String} opts.coin - default 'btc'
335-
* @param {String} opts.network - default 'livenet'
336-
* @param {String} opts.passphrase
337-
* @param {Number} opts.account - default 0
338-
* @param {String} opts.derivationStrategy - default 'BIP44'
339-
* @param {String} opts.entropySourcePath - Only used if the wallet was created on a HW wallet, in which that private keys was not available for all the needed derivations
340-
* @param {String} opts.walletPrivKey - if available, walletPrivKey for encrypting metadata
341-
*/
342-
importFromMnemonic(words, opts, cb) {
343-
$.checkState(false, 'not supported');
344-
345-
log.debug('Importing from Mnemonic');
346-
347-
opts = opts || {};
348-
opts.coin = opts.coin || 'btc';
349-
350-
function derive(nonCompliantDerivation?, useLegacyCoinType?) {
351-
return Credentials.fromMnemonic(opts.coin, opts.network || 'livenet', words, opts.passphrase, opts.account || 0, opts.derivationStrategy || Constants.DERIVATION_STRATEGIES.BIP44, {
352-
nonCompliantDerivation,
353-
entropySourcePath: opts.entropySourcePath,
354-
walletPrivKey: opts.walletPrivKey,
355-
useLegacyCoinType,
356-
});
357-
}
358-
359-
try {
360-
this.credentials = derive();
361-
} catch (e) {
362-
log.info('Mnemonic error:', e);
363-
return cb(new Errors.INVALID_BACKUP);
364-
}
365-
this.request.setCredentials(this.credentials);
366-
// TODO BWC => ts
367-
_import(function (err, ret) {
368-
if (!err) return cb(null, ret);
369-
if (err instanceof Errors.INVALID_BACKUP) return cb(err);
370-
if (err instanceof Errors.NOT_AUTHORIZED || err instanceof Errors.WALLET_DOES_NOT_EXIST) {
371-
372-
var altCredentials;
373-
// Only BTC wallets can be nonCompliantDerivation
374-
switch (opts.coin) {
375-
case 'btc':
376-
// try using nonCompliantDerivation
377-
altCredentials = derive(true);
378-
break;
379-
case 'bch':
380-
// try using 0 as coin for BCH (old wallets)
381-
altCredentials = derive(false, true);
382-
break;
383-
default:
384-
return cb(err);
385-
}
386-
387-
if (altCredentials.xPubKey.toString() == this.credentials.xPubKey.toString())
388-
return cb(err);
389-
390-
this.credentials = altCredentials;
391-
this.request.setCredentials(this.credentials);
392-
return this._import(cb);
393-
}
394-
return cb(err);
395-
});
396-
}
397-
398-
/*
399-
* Import from extended private key
400-
*
401-
* @param {String} xPrivKey
402-
* @param {String} opts.coin - default 'btc'
403-
* @param {Number} opts.account - default 0
404-
* @param {String} opts.derivationStrategy - default 'BIP44'
405-
* @param {String} opts.compliantDerivation - default 'true'
406-
* @param {String} opts.walletPrivKey - if available, walletPrivKey for encrypting metadata
407-
* @param {Callback} cb - The callback that handles the response. It returns a flag indicating that the wallet is imported.
408-
*/
409-
importFromExtendedPrivateKey(xPrivKey, opts, cb) {
410-
$.checkState(false, 'not supported');
411-
log.debug('Importing from Extended Private Key');
412-
413-
if (!cb) {
414-
cb = opts;
415-
opts = {};
416-
log.warn('DEPRECATED WARN: importFromExtendedPrivateKey should receive 3 parameters.');
417-
}
418-
419-
try {
420-
this.credentials = Credentials.fromExtendedPrivateKey(opts.coin || 'btc', xPrivKey, opts.account || 0, opts.derivationStrategy || Constants.DERIVATION_STRATEGIES.BIP44, opts);
421-
} catch (e) {
422-
log.info('xPriv error:', e);
423-
return cb(new Errors.INVALID_BACKUP);
424-
}
425-
426-
this.request.setCredentials(this.credentials);
427-
this._import(cb);
428-
}
429-
430-
/**
431-
* Import from Extended Public Key
432-
*
433-
* @param {String} xPubKey
434-
* @param {String} source - A name identifying the source of the xPrivKey
435-
* @param {String} entropySourceHex - A HEX string containing pseudo-random data, that can be deterministically derived from the xPrivKey, and should not be derived from xPubKey.
436-
* @param {Object} opts
437-
* @param {String} opts.coin - default 'btc'
438-
* @param {Number} opts.account - default 0
439-
* @param {String} opts.derivationStrategy - default 'BIP44'
440-
* @param {String} opts.compliantDerivation - default 'true'
441-
*/
442-
importFromExtendedPublicKey(xPubKey, source, entropySourceHex, opts, cb) {
443-
$.checkState(false, 'not supported');
444-
$.checkArgument(arguments.length == 5, 'DEPRECATED: should receive 5 arguments');
445-
$.checkArgument(_.isUndefined(opts) || _.isObject(opts));
446-
$.shouldBeFunction(cb);
447-
448-
opts = opts || {};
449-
log.debug('Importing from Extended Private Key');
450-
try {
451-
this.credentials = Credentials.fromExtendedPublicKey(opts.coin || 'btc', xPubKey, source, entropySourceHex, opts.account || 0, opts.derivationStrategy || Constants.DERIVATION_STRATEGIES.BIP44, opts);
452-
} catch (e) {
453-
log.info('xPriv error:', e);
454-
return cb(new Errors.INVALID_BACKUP);
455-
}
456-
457-
this.request.setCredentials(this.credentials);
458-
this._import(cb);
459-
}
460-
461327
decryptBIP38PrivateKey(encryptedPrivateKeyBase58, passphrase, opts, cb) {
462328
var Bip38 = require('bip38');
463329
var bip38 = new Bip38();

packages/bitcore-wallet-client/src/lib/paypro.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class PayPro {
219219
}
220220

221221
if (!_.isNumber(data.outputs[0].amount)) {
222-
return cb(new Error('Bad output amount ' + e));
222+
return cb(new Error('Bad output amount'));
223223
}
224224
ret.amount = data.outputs[0].amount;
225225

packages/bitcore-wallet-client/test/api.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var async = require('async');
1010
var request = require('supertest');
1111
var Uuid = require('uuid');
1212
var sjcl = require('sjcl');
13-
var log = require('../src/lib/log');
13+
var log = require('../ts_build/log');
1414
var mongodb = require('mongodb');
1515
var config = require('./test-config');
1616
var oldCredentials = require('./legacyCredentialsExports');
@@ -23,16 +23,16 @@ var Bitcore_ = {
2323

2424
var BWS = require('bitcore-wallet-service');
2525

26-
var Common = require('../src/lib/common');
26+
var Common = require('../ts_build/common');
2727
var Constants = Common.Constants;
2828
var Utils = Common.Utils;
29-
var Client = require('../src/lib');
29+
var Client = require('../ts_build');
3030
var Key = Client.Key;
31-
var Request = require('../src/lib/request.js');
31+
var Request = require('../ts_build/request.js');
3232
var ExpressApp = BWS.ExpressApp;
3333
var Storage = BWS.Storage;
3434
var TestData = require('./testdata');
35-
var Errors = require('../src/lib/errors');
35+
var Errors = require('../ts_build/errors');
3636

3737
var helpers = {};
3838

0 commit comments

Comments
 (0)