mirror of https://github.com/BTCPrivate/copay.git
add wallet tests
This commit is contained in:
parent
341c9d8ffa
commit
d4b2ac1ad4
|
@ -35,6 +35,7 @@ Wallet.prototype._startInterface = function(config) {
|
|||
|
||||
|
||||
Wallet.prototype.create = function(opts) {
|
||||
opts = opts || {};
|
||||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID'));
|
||||
|
||||
|
@ -67,14 +68,6 @@ Wallet.prototype._checkLoad = function(walletId) {
|
|||
this.storage.get(walletId, 'txProposals') &&
|
||||
this.storage.get(walletId, 'privateKey')
|
||||
;
|
||||
|
||||
console.log('[Wallet.js.71]',
|
||||
this.storage.get(walletId, 'publicKeyRing'),
|
||||
this.storage.get(walletId, 'txProposals'),
|
||||
this.storage.get(walletId, 'privateKey'));
|
||||
|
||||
console.log('[Wallet.js.73:ret:]',walletId, ret); //TODO
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -169,6 +162,15 @@ Wallet.prototype.addSeenToTxProposals = function() {
|
|||
return ret;
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype.getAddresses = function() {
|
||||
return this.publicKeyRing.getAddresses();
|
||||
};
|
||||
|
||||
Wallet.prototype.listUnspent = function(cb) {
|
||||
this.blockchain.listUnspent(this.getAddresses(), cb);
|
||||
};
|
||||
|
||||
// // HERE? not sure
|
||||
// Wallet.prototype.cleanPeers = function() {
|
||||
// this.storage.remove('peerData');
|
||||
|
|
|
@ -9,6 +9,13 @@ var Wallet = require('soop').load('../js/models/core/Wallet', {
|
|||
Blockchain: copay.Insight
|
||||
});
|
||||
|
||||
|
||||
var addCopayers = function (w) {
|
||||
for(var i=0; i<4; i++) {
|
||||
w.publicKeyRing.addCopayer();
|
||||
}
|
||||
};
|
||||
|
||||
describe('Wallet model', function() {
|
||||
var config = {
|
||||
wallet: {
|
||||
|
@ -19,13 +26,44 @@ describe('Wallet model', function() {
|
|||
var opts = {};
|
||||
|
||||
|
||||
it.skip('should create an instance', function () {
|
||||
it('should create an instance', function () {
|
||||
var opts = {};
|
||||
var w = Wallet.create(config, opts);
|
||||
var w = new Wallet(config);
|
||||
should.exist(w);
|
||||
});
|
||||
|
||||
|
||||
it('should fail to load', function () {
|
||||
var opts = {};
|
||||
var w = new Wallet(config);
|
||||
w.load(123);
|
||||
should.not.exist(w.id);
|
||||
});
|
||||
|
||||
|
||||
it('should create', function () {
|
||||
var opts = {};
|
||||
var w = new Wallet(config);
|
||||
w.create();
|
||||
should.exist(w.id);
|
||||
should.exist(w.publicKeyRing);
|
||||
should.exist(w.privateKey);
|
||||
should.exist(w.txProposals);
|
||||
});
|
||||
|
||||
it('should create', function () {
|
||||
var opts = {};
|
||||
var w = new Wallet(config);
|
||||
w.create();
|
||||
addCopayers(w);
|
||||
w.publicKeyRing.generateAddress(false);
|
||||
|
||||
should.exist(w.id);
|
||||
w.publicKeyRing.isComplete().should.equal(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe('factory', function() {
|
||||
it('should create the factory', function() {
|
||||
should.exist(Wallet.factory);
|
||||
|
|
Loading…
Reference in New Issue