mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #681 from ryanxcharles/bug/fix-mocha-browser-tests
make mocha browser tests all run with no console errors
This commit is contained in:
commit
3053dfc005
8
copay.js
8
copay.js
|
@ -1,4 +1,3 @@
|
|||
|
||||
// core
|
||||
module.exports.PublicKeyRing = require('./js/models/core/PublicKeyRing');
|
||||
module.exports.TxProposals = require('./js/models/core/TxProposals');
|
||||
|
@ -14,11 +13,6 @@ var Insight = module.exports.Insight = require('./js/models/blockchain/Insight')
|
|||
var StorageLocalPlain = module.exports.StorageLocalPlain = require('./js/models/storage/LocalPlain');
|
||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('./js/models/storage/LocalEncrypted');
|
||||
|
||||
var WalletFactory = require('soop').load('./js/models/core/WalletFactory',{
|
||||
Network: WebRTC,
|
||||
Blockchain: Insight,
|
||||
Storage: StorageLocalEncrypted,
|
||||
});
|
||||
module.exports.WalletFactory = WalletFactory;
|
||||
module.exports.WalletFactory = require('./js/models/core/WalletFactory');
|
||||
module.exports.version = require('./version');
|
||||
module.exports.API = require('./API');
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
var imports = require('soop').imports();
|
||||
var Storage = imports.Storage;
|
||||
var Network = imports.Network;
|
||||
var Blockchain = imports.Blockchain;
|
||||
|
||||
var TxProposals = require('./TxProposals');
|
||||
var PublicKeyRing = require('./PublicKeyRing');
|
||||
var PrivateKey = require('./PrivateKey');
|
||||
var Wallet = require('./Wallet');
|
||||
|
||||
var WebRTC = module.exports.WebRTC = require('../network/WebRTC');
|
||||
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
||||
//var StorageLocalPlain = module.exports.StorageLocalPlain = require('../storage/LocalPlain');
|
||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('../storage/LocalEncrypted');
|
||||
|
||||
/*
|
||||
* WalletFactory
|
||||
*
|
||||
|
@ -19,9 +21,13 @@ function WalletFactory(config, version) {
|
|||
var self = this;
|
||||
config = config || {};
|
||||
|
||||
this.storage = new Storage(config.storage);
|
||||
this.network = new Network(config.network);
|
||||
this.blockchain = new Blockchain(config.blockchain);
|
||||
this.Storage = config.Storage || StorageLocalEncrypted;
|
||||
this.Network = config.Network || WebRTC;
|
||||
this.Blockchain = config.Blockchain || Insight;
|
||||
|
||||
this.storage = new this.Storage(config.storage);
|
||||
this.network = new this.Network(config.network);
|
||||
this.blockchain = new this.Blockchain(config.blockchain);
|
||||
|
||||
this.networkName = config.networkName;
|
||||
this.verbose = config.verbose;
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
<script>mocha.setup('bdd')</script>
|
||||
<script src="../lib/bitcore/browser/bundle.js"></script>
|
||||
<script src="../js/copayBundle.js"></script>
|
||||
<script>
|
||||
var copay = require('copay');
|
||||
</script>
|
||||
<script src="test.blockchain.Insight.js"></script>
|
||||
<script src="test.PrivateKey.js"></script>
|
||||
<script src="test.PublicKeyRing.js"></script>
|
||||
|
@ -24,7 +21,7 @@
|
|||
<script src="test.storage.LocalPlain.js"></script>
|
||||
<script src="test.TxProposals.js"></script>
|
||||
<script src="test.Wallet.js"></script>
|
||||
<script src="test.Walletfactory.js"></script>
|
||||
<script src="test.WalletFactory.js"></script>
|
||||
<script src="test.performance.js"></script>
|
||||
<!--
|
||||
-->
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var API = API || copay.API;
|
||||
var Storage = Storage || require('../test/mocks/FakeStorage');
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@ var should = chai.should();
|
|||
var bitcore = bitcore || require('bitcore');
|
||||
var Address = bitcore.Address;
|
||||
var buffertools = bitcore.buffertools;
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var PublicKeyRing = copay.PublicKeyRing;
|
||||
var AddressIndex = copay.AddressIndex;
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@ var chai = chai || require('chai');
|
|||
var should = chai.should();
|
||||
var bitcore = bitcore || require('bitcore');
|
||||
var buffertools = bitcore.buffertools;
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var Passphrase = copay.Passphrase;
|
||||
|
||||
|
||||
|
|
|
@ -7,11 +7,15 @@ var Transaction = bitcore.Transaction;
|
|||
var buffertools = bitcore.buffertools;
|
||||
var WalletKey = bitcore.WalletKey;
|
||||
var Key = bitcore.Key;
|
||||
var bignum = bitcore.bignum;
|
||||
var bignum = bitcore.Bignum;
|
||||
var networks = bitcore.networks;
|
||||
var Address = bitcore.Address;
|
||||
var BitcorePrivateKey = bitcore.PrivateKey;
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var PrivateKey = copay.PrivateKey || require('../js/models/core/PrivateKey');
|
||||
|
||||
var config = {
|
||||
|
|
|
@ -5,16 +5,16 @@ var should = chai.should();
|
|||
var bitcore = bitcore || require('bitcore');
|
||||
var Address = bitcore.Address;
|
||||
var buffertools = bitcore.buffertools;
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var PublicKeyRing = copay.PublicKeyRing;
|
||||
|
||||
var aMasterPubKey = 'tprv8ZgxMBicQKsPdSVTiWXEqCCzqRaRr9EAQdn5UVMpT9UHX67Dh1FmzEMbavPumpAicsUm2XvC6NTdcWB89yN5DUWx5HQ7z3KByUg7Ht74VRZ';
|
||||
|
||||
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
|
||||
var createW = function (networkName) {
|
||||
var config = {
|
||||
networkName: networkName || 'livenet',
|
||||
|
@ -37,6 +37,10 @@ var createW = function (networkName) {
|
|||
describe('PublicKeyRing model', function() {
|
||||
|
||||
it('should create an instance (livenet)', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
|
||||
var w = new PublicKeyRing({
|
||||
networkName: config.networkName
|
||||
});
|
||||
|
@ -50,6 +54,9 @@ describe('PublicKeyRing model', function() {
|
|||
});
|
||||
|
||||
it('should fail to generate shared pub keys wo extended key', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
var w2 = new PublicKeyRing(config);
|
||||
should.exist(w2);
|
||||
|
||||
|
@ -235,6 +242,9 @@ describe('PublicKeyRing model', function() {
|
|||
|
||||
|
||||
it('#merge pubkey tests', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
var w = new PublicKeyRing(config);
|
||||
should.exist(w);
|
||||
var copayers = [];
|
||||
|
@ -264,6 +274,9 @@ describe('PublicKeyRing model', function() {
|
|||
});
|
||||
|
||||
it('#merge pubkey tests (case 2)', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
var w = new PublicKeyRing(config);
|
||||
should.exist(w);
|
||||
|
||||
|
@ -281,6 +294,9 @@ describe('PublicKeyRing model', function() {
|
|||
|
||||
|
||||
it('#merge with nickname', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
var w = new PublicKeyRing(config);
|
||||
should.exist(w);
|
||||
for(var i=0; i<3; i++) {
|
||||
|
@ -315,6 +331,9 @@ describe('PublicKeyRing model', function() {
|
|||
|
||||
|
||||
it('#toObj #fromObj with nickname', function () {
|
||||
var config = {
|
||||
networkName:'livenet',
|
||||
};
|
||||
var w = new PublicKeyRing(config);
|
||||
should.exist(w);
|
||||
for(var i=0; i<3; i++) {
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var bitcore = bitcore || require('bitcore');
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var Structure = require('../js/models/core/Structure');
|
||||
|
||||
describe('Structure model', function() {
|
||||
|
|
|
@ -7,20 +7,24 @@ var Transaction = bitcore.Transaction;
|
|||
var buffertools = bitcore.buffertools;
|
||||
var WalletKey = bitcore.WalletKey;
|
||||
var Key = bitcore.Key;
|
||||
var bignum = bitcore.bignum;
|
||||
var bignum = bitcore.Bignum;
|
||||
var Script = bitcore.Script;
|
||||
var Builder = bitcore.TransactionBuilder;
|
||||
var util = bitcore.util;
|
||||
var networks = bitcore.networks;
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var fakeStorage = copay.FakeStorage;
|
||||
var PrivateKey = copay.PrivateKey || require('../js/models/PrivateKey');
|
||||
var TxProposals = copay.TxProposals || require('../js/models/TxProposal');
|
||||
var is_browser = (typeof process == 'undefined' || typeof process.versions === 'undefined')
|
||||
var PublicKeyRing = is_browser ? copay.PublicKeyRing :
|
||||
require('soop').load('../js/models/core/PublicKeyRing', {
|
||||
Storage: fakeStorage
|
||||
});
|
||||
var is_browser = (typeof process.versions === 'undefined')
|
||||
|
||||
var config = {
|
||||
networkName: 'testnet',
|
||||
|
@ -102,7 +106,7 @@ describe('TxProposals model', function() {
|
|||
tx = b.build();
|
||||
tx.isComplete().should.equal(true);
|
||||
|
||||
var s = new Script(new Buffer(unspentTest[0].scriptPubKey, 'hex'));
|
||||
var s = new Script(new bitcore.Buffer(unspentTest[0].scriptPubKey, 'hex'));
|
||||
|
||||
tx.verifyInput(0, s, {
|
||||
verifyP2SH: true,
|
||||
|
@ -126,7 +130,7 @@ describe('TxProposals model', function() {
|
|||
var createTx = function(toAddress, amountSatStr, utxos, opts, priv, pkr) {
|
||||
opts = opts || {};
|
||||
|
||||
var amountSat = bitcore.bignum(amountSatStr);
|
||||
var amountSat = bitcore.Bignum(amountSatStr);
|
||||
|
||||
if (!pkr.isComplete()) {
|
||||
throw new Error('publicKeyRing is not complete');
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var sinon = require('sinon');
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var Wallet = require('../js/models/core/Wallet');
|
||||
var Storage = require('./mocks/FakeStorage');
|
||||
var Network = require('./mocks/FakeNetwork');
|
||||
|
@ -77,7 +81,7 @@ describe('Wallet model', function() {
|
|||
should.exist(w.privateKey);
|
||||
should.exist(w.txProposals);
|
||||
should.exist(w.netKey);
|
||||
var b = new Buffer(w.netKey, 'base64');
|
||||
var b = new bitcore.Buffer(w.netKey, 'base64');
|
||||
b.toString('hex').length.should.equal(16);
|
||||
});
|
||||
|
||||
|
@ -287,6 +291,7 @@ describe('Wallet model', function() {
|
|||
});
|
||||
|
||||
it('call reconnect after interval', function(done) {
|
||||
this.timeout(10000);
|
||||
var w = createW2();
|
||||
var testTime = 1000;
|
||||
var callCount = 0;
|
||||
|
@ -539,6 +544,7 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
it('should create & sign transaction from received funds', function(done) {
|
||||
this.timeout(10000);
|
||||
var w = createW2();
|
||||
var pk = w.privateKey;
|
||||
w.privateKey = null;
|
||||
|
|
|
@ -7,16 +7,12 @@ var FakeNetwork = require('./mocks/FakeNetwork');
|
|||
var Insight = require('../js/models/blockchain/Insight');
|
||||
var FakeStorage = require('./mocks/FakeStorage');
|
||||
|
||||
var WalletFactory = typeof copay === 'undefined' ? require('soop').load('../js/models/core/WalletFactory', {
|
||||
Network: FakeNetwork,
|
||||
Blockchain: Insight,
|
||||
Storage: FakeStorage,
|
||||
}) : copay.WalletFactory;
|
||||
|
||||
var blanket = require("blanket")({
|
||||
"pattern": "/js/"
|
||||
});
|
||||
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var WalletFactory = require('../js/models/core/WalletFactory');
|
||||
|
||||
var addCopayers = function(w) {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
|
@ -26,11 +22,15 @@ var addCopayers = function(w) {
|
|||
|
||||
describe('WalletFactory model', function() {
|
||||
var config = {
|
||||
Network: FakeNetwork,
|
||||
Blockchain: Insight,
|
||||
Storage: FakeStorage,
|
||||
wallet: {
|
||||
requiredCopayers: 3,
|
||||
totalCopayers: 5,
|
||||
spendUnconfirmed: 1,
|
||||
reconnectDelay: 100,
|
||||
|
||||
},
|
||||
blockchain: {
|
||||
host: 'test.insight.is',
|
||||
|
@ -82,6 +82,9 @@ describe('WalletFactory model', function() {
|
|||
|
||||
it('BIP32 length problem', function() {
|
||||
var sconfig = {
|
||||
Network: FakeNetwork,
|
||||
Blockchain: Insight,
|
||||
Storage: FakeStorage,
|
||||
"networkName": "testnet",
|
||||
"network": {
|
||||
"key": "g23ihfh82h35rf",
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var bitcore = bitcore || require('bitcore');
|
||||
var copay = copay || require('../copay');
|
||||
try {
|
||||
var copay = require('copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var Insight = copay.Insight || require('../js/models/blockchain/Insight');
|
||||
|
||||
var ID = '933bf321393459b7';
|
||||
|
|
|
@ -90,7 +90,7 @@ describe("Unit: controllerUtils", function() {
|
|||
|
||||
|
||||
describe("Unit: Backup Service", function() {
|
||||
var sinon = require('../sinon');
|
||||
var sinon = require('sinon');
|
||||
beforeEach(angular.mock.module('copayApp.services'));
|
||||
it('should contain a backup service', inject(function(backupService) {
|
||||
expect(backupService).not.to.equal(null);
|
||||
|
|
|
@ -50,7 +50,9 @@ var createBundle = function(opts) {
|
|||
});
|
||||
b.require('./version');
|
||||
// b.external('bitcore');
|
||||
b.require('./js/models/core/WalletFactory');
|
||||
b.require('./js/models/core/WalletFactory', {
|
||||
expose: '../js/models/core/WalletFactory'
|
||||
});
|
||||
b.require('./js/models/core/Wallet');
|
||||
b.require('./js/models/core/Wallet', {
|
||||
expose: '../js/models/core/Wallet'
|
||||
|
@ -58,6 +60,9 @@ var createBundle = function(opts) {
|
|||
b.require('./test/mocks/FakeStorage', {
|
||||
expose: './mocks/FakeStorage'
|
||||
});
|
||||
b.require('./test/mocks/FakeBlockchain', {
|
||||
expose: './mocks/FakeBlockchain'
|
||||
});
|
||||
b.require('./js/models/core/Wallet', {
|
||||
expose: '../js/models/core/Wallet'
|
||||
});
|
||||
|
@ -81,10 +86,12 @@ var createBundle = function(opts) {
|
|||
});
|
||||
|
||||
if (opts.dontminify) {
|
||||
b.require('sinon', {
|
||||
expose: '../sinon'
|
||||
});
|
||||
//include dev dependencies
|
||||
b.require('sinon');
|
||||
b.require('blanket');
|
||||
b.require('soop');
|
||||
}
|
||||
|
||||
if (!opts.dontminify) {
|
||||
b.transform({
|
||||
global: true
|
||||
|
@ -101,7 +108,7 @@ if (require.main === module) {
|
|||
var program = require('commander');
|
||||
program
|
||||
.version('0.0.1')
|
||||
.option('-d, --dontminify', 'Don\'t minify the code.')
|
||||
.option('-d, --dontminify', 'Development. Don\'t minify the code.')
|
||||
.option('-o, --stdout', 'Specify output as stdout')
|
||||
.parse(process.argv);
|
||||
|
||||
|
|
Loading…
Reference in New Issue