add some mocha tests to karma 10
This commit is contained in:
parent
f624715fe1
commit
5206547a61
2 changed files with 20 additions and 17 deletions
|
|
@ -68,6 +68,9 @@ module.exports = function(config) {
|
||||||
'test/test.performance.js',
|
'test/test.performance.js',
|
||||||
'test/test.PrivateKey.js',
|
'test/test.PrivateKey.js',
|
||||||
'test/test.PublicKeyRing.js',
|
'test/test.PublicKeyRing.js',
|
||||||
|
'test/test.TxProposal.js',
|
||||||
|
'test/test.TxProposals.js',
|
||||||
|
'test/test.Wallet.js',
|
||||||
|
|
||||||
'test/unit/**/*.js',
|
'test/unit/**/*.js',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ var TransactionBuilder = bitcore.TransactionBuilder;
|
||||||
var Transaction = bitcore.Transaction;
|
var Transaction = bitcore.Transaction;
|
||||||
var Address = bitcore.Address;
|
var Address = bitcore.Address;
|
||||||
|
|
||||||
var config = {
|
var walletConfig = {
|
||||||
requiredCopayers: 3,
|
requiredCopayers: 3,
|
||||||
totalCopayers: 5,
|
totalCopayers: 5,
|
||||||
spendUnconfirmed: true,
|
spendUnconfirmed: true,
|
||||||
|
|
@ -30,7 +30,7 @@ var config = {
|
||||||
|
|
||||||
var getNewEpk = function() {
|
var getNewEpk = function() {
|
||||||
return new PrivateKey({
|
return new PrivateKey({
|
||||||
networkName: config.networkName,
|
networkName: walletConfig.networkName,
|
||||||
})
|
})
|
||||||
.deriveBIP45Branch()
|
.deriveBIP45Branch()
|
||||||
.extendedPublicKeyString();
|
.extendedPublicKeyString();
|
||||||
|
|
@ -46,7 +46,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('should fail to create an instance', function() {
|
it('should fail to create an instance', function() {
|
||||||
(function() {
|
(function() {
|
||||||
new Wallet(config)
|
new Wallet(walletConfig)
|
||||||
}).should.
|
}).should.
|
||||||
throw();
|
throw();
|
||||||
});
|
});
|
||||||
|
|
@ -58,11 +58,11 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
var createW = function(N, conf) {
|
var createW = function(N, conf) {
|
||||||
|
|
||||||
var c = JSON.parse(JSON.stringify(conf || config));
|
var c = JSON.parse(JSON.stringify(conf || walletConfig));
|
||||||
if (!N) N = c.totalCopayers;
|
if (!N) N = c.totalCopayers;
|
||||||
|
|
||||||
var mainPrivateKey = new copay.PrivateKey({
|
var mainPrivateKey = new copay.PrivateKey({
|
||||||
networkName: config.networkName
|
networkName: walletConfig.networkName
|
||||||
});
|
});
|
||||||
var mainCopayerEPK = mainPrivateKey.deriveBIP45Branch().extendedPublicKeyString();
|
var mainCopayerEPK = mainPrivateKey.deriveBIP45Branch().extendedPublicKeyString();
|
||||||
c.privateKey = mainPrivateKey;
|
c.privateKey = mainPrivateKey;
|
||||||
|
|
@ -78,9 +78,9 @@ describe('Wallet model', function() {
|
||||||
networkName: c.networkName,
|
networkName: c.networkName,
|
||||||
});
|
});
|
||||||
|
|
||||||
var storage = new Storage(config.storage);
|
var storage = new Storage(walletConfig.storage);
|
||||||
var network = new Network(config.network);
|
var network = new Network(walletConfig.network);
|
||||||
var blockchain = new Blockchain(config.blockchain);
|
var blockchain = new Blockchain(walletConfig.blockchain);
|
||||||
c.storage = storage;
|
c.storage = storage;
|
||||||
c.network = network;
|
c.network = network;
|
||||||
c.blockchain = blockchain;
|
c.blockchain = blockchain;
|
||||||
|
|
@ -100,8 +100,8 @@ describe('Wallet model', function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
c.networkName = config.networkName;
|
c.networkName = walletConfig.networkName;
|
||||||
c.verbose = config.verbose;
|
c.verbose = walletConfig.verbose;
|
||||||
c.version = '0.0.1';
|
c.version = '0.0.1';
|
||||||
|
|
||||||
return new Wallet(c);
|
return new Wallet(c);
|
||||||
|
|
@ -322,9 +322,9 @@ describe('Wallet model', function() {
|
||||||
o.opts.reconnectDelay = 100;
|
o.opts.reconnectDelay = 100;
|
||||||
|
|
||||||
var w2 = Wallet.fromObj(o,
|
var w2 = Wallet.fromObj(o,
|
||||||
new Storage(config.storage),
|
new Storage(walletConfig.storage),
|
||||||
new Network(config.network),
|
new Network(walletConfig.network),
|
||||||
new Blockchain(config.blockchain));
|
new Blockchain(walletConfig.blockchain));
|
||||||
should.exist(w2);
|
should.exist(w2);
|
||||||
w2.publicKeyRing.requiredCopayers.should.equal(w.publicKeyRing.requiredCopayers);
|
w2.publicKeyRing.requiredCopayers.should.equal(w.publicKeyRing.requiredCopayers);
|
||||||
should.exist(w2.publicKeyRing.getCopayerId);
|
should.exist(w2.publicKeyRing.getCopayerId);
|
||||||
|
|
@ -580,7 +580,7 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#getUnspent should honor spendUnconfirmed = false', function(done) {
|
it('#getUnspent should honor spendUnconfirmed = false', function(done) {
|
||||||
var conf = JSON.parse(JSON.stringify(config));
|
var conf = JSON.parse(JSON.stringify(walletConfig));
|
||||||
conf.spendUnconfirmed = false;
|
conf.spendUnconfirmed = false;
|
||||||
var w = createW2(null, null, conf);
|
var w = createW2(null, null, conf);
|
||||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||||
|
|
@ -592,7 +592,7 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#getUnspent and spendUnconfirmed should count transactions with 1 confirmations', function(done) {
|
it('#getUnspent and spendUnconfirmed should count transactions with 1 confirmations', function(done) {
|
||||||
var conf = JSON.parse(JSON.stringify(config));
|
var conf = JSON.parse(JSON.stringify(walletConfig));
|
||||||
conf.spendUnconfirmed = false;
|
conf.spendUnconfirmed = false;
|
||||||
var w = cachedCreateW2(null, null, conf);
|
var w = cachedCreateW2(null, null, conf);
|
||||||
w.blockchain.getUnspent = w.blockchain.getUnspent2;
|
w.blockchain.getUnspent = w.blockchain.getUnspent2;
|
||||||
|
|
@ -684,7 +684,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('should create & sign transaction from received funds', function(done) {
|
it('should create & sign transaction from received funds', function(done) {
|
||||||
var k2 = new PrivateKey({
|
var k2 = new PrivateKey({
|
||||||
networkName: config.networkName
|
networkName: walletConfig.networkName
|
||||||
});
|
});
|
||||||
|
|
||||||
var w = createW2([k2]);
|
var w = createW2([k2]);
|
||||||
|
|
@ -1093,7 +1093,7 @@ describe('Wallet model', function() {
|
||||||
it('should throw if network is different', function() {
|
it('should throw if network is different', function() {
|
||||||
var backup = copayConfig.forceNetwork;
|
var backup = copayConfig.forceNetwork;
|
||||||
copayConfig.forceNetwork = true;
|
copayConfig.forceNetwork = true;
|
||||||
config.networkName = 'livenet';
|
walletConfig.networkName = 'livenet';
|
||||||
createW2.should.throw(Error);
|
createW2.should.throw(Error);
|
||||||
copayConfig.forceNetwork = backup;
|
copayConfig.forceNetwork = backup;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue