mirror of https://github.com/BTCPrivate/copay.git
More test on TxProposal, Identity and Insight
This commit is contained in:
parent
a045432800
commit
40db2e2ba9
|
@ -75,8 +75,6 @@ TxProposal.prototype._checkPayPro = function() {
|
|||
if (!this.merchant.total || !this.merchant.outs[0].amountSatStr || !this.merchant.outs[0].address)
|
||||
throw new Error('PayPro: Missing amount');
|
||||
|
||||
console.log('outs ', this.builder.vanilla.outs);
|
||||
console.log('size ', _.size(outs));
|
||||
var outs = JSON.parse(this.builder.vanilla.outs);
|
||||
if (_.size(outs) != 1)
|
||||
throw new Error('PayPro: Wrong outs in Tx');
|
||||
|
|
|
@ -704,6 +704,37 @@ describe('Identity model', function() {
|
|||
|
||||
|
||||
describe('#importWalletFromObj', function() {
|
||||
it('should return an error', function(done) {
|
||||
var iden = new Identity(getDefaultParams());
|
||||
iden.verifyChecksum = sinon.stub().yields('error', true);
|
||||
iden.importWalletFromObj({}, {}, function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return an error case 2', function(done) {
|
||||
var iden = new Identity(getDefaultParams());
|
||||
iden.verifyChecksum = sinon.stub().yields(null, false);
|
||||
iden.importWalletFromObj({}, {}, function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error case 3', function(done) {
|
||||
var iden = new Identity(getDefaultParams());
|
||||
iden.verifyChecksum = sinon.stub().yields(null, true);
|
||||
iden.importWalletFromObj({}, {
|
||||
importWallet: function() {
|
||||
return false;
|
||||
}
|
||||
}, function(err) {
|
||||
console.log(err);
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should import a wallet, call the right encryption functions', function(done) {
|
||||
var args = createIdentity();
|
||||
args.storage.getItem.onFirstCall().callsArgWith(1, null, '{"wallet": "fakeData"}');
|
||||
|
|
|
@ -349,9 +349,6 @@ describe('TxProposal', function() {
|
|||
Buffer.isBuffer(info.script.getBuffer()).should.equal(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
it('#getSignersPubKeys', function() {
|
||||
var txp = dummyProposal();
|
||||
var pubkeys = txp.getSignersPubKeys();
|
||||
|
@ -548,12 +545,29 @@ describe('TxProposal', function() {
|
|||
txp.addMerchantData(md);
|
||||
}).should.throw('outputs');
|
||||
});
|
||||
|
||||
it('NOK OUTS (case 3)', function() {
|
||||
md.outs = [{}, {}];
|
||||
(function() {
|
||||
txp.addMerchantData(md);
|
||||
}).should.throw('outputs');
|
||||
});
|
||||
|
||||
it('NOK OUTS (case 4)', function() {
|
||||
txp.builder.vanilla.outs = '[1,2]';
|
||||
txp.merchant = {};
|
||||
txp.paymentProtocolURL = txp.merchant.request_url;
|
||||
txp.merchant.total = 1;
|
||||
txp.merchant.outs = [{
|
||||
amountSatStr: '1',
|
||||
address: '2NDJbzwzsmRgD2o5HHXPhuq5g6tkKTjYkd6'
|
||||
}];
|
||||
|
||||
(function() {
|
||||
txp._checkPayPro();
|
||||
}).should.throw('Wrong outs in Tx');
|
||||
});
|
||||
|
||||
it('NOK Amount', function() {
|
||||
md.total = undefined;
|
||||
(function() {
|
||||
|
@ -717,7 +731,7 @@ describe('TxProposal', function() {
|
|||
txp.creator.should.equal('creator');
|
||||
txp.createdTs.should.gte(ts);
|
||||
txp.seenBy['creator'].should.equal(txp.createdTs);
|
||||
})
|
||||
});
|
||||
it("New tx should have only 1 signature", function() {
|
||||
var txp = dummyProposal();
|
||||
var ts = Date.now();
|
||||
|
@ -734,7 +748,7 @@ describe('TxProposal', function() {
|
|||
'creator2': 1
|
||||
});
|
||||
}).should.throw('only 1');
|
||||
})
|
||||
});
|
||||
|
||||
it("if signed, should not change ts", function() {
|
||||
var txp = dummyProposal();
|
||||
|
@ -753,7 +767,8 @@ describe('TxProposal', function() {
|
|||
txp.creator.should.equal('creator');
|
||||
txp.signedBy['creator'].should.equal(1);
|
||||
txp.signedBy['pepe'].should.gte(ts);
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -291,6 +291,7 @@ describe('Insight model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
describe('getActivity', function() {
|
||||
it('should get activity for an innactive address', function(done) {
|
||||
var blockchain = new Insight(FAKE_OPTS);
|
||||
|
@ -309,6 +310,19 @@ describe('Insight model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not get activity because of error', function(done) {
|
||||
var blockchain = new Insight(FAKE_OPTS);
|
||||
|
||||
sinon.stub(blockchain, "getTransactions", function(addresses, from, to, cb) {
|
||||
cb('error', []);
|
||||
});
|
||||
|
||||
blockchain.getActivity(ADDRESSES, function(err, actives) {
|
||||
chai.expect(err).to.be.not.null;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get activity for active addresses', function(done) {
|
||||
var blockchain = new Insight(FAKE_OPTS);
|
||||
|
||||
|
|
Loading…
Reference in New Issue