Add validation and tests for spendUnconfirmed = false
This commit is contained in:
parent
4d6e9f8a6d
commit
26c829f6de
4 changed files with 47 additions and 7 deletions
|
|
@ -26,7 +26,7 @@ describe('Wallet model', function() {
|
|||
var config = {
|
||||
requiredCopayers: 3,
|
||||
totalCopayers: 5,
|
||||
spendUnconfirmed: 1,
|
||||
spendUnconfirmed: true,
|
||||
reconnectDelay: 100,
|
||||
networkName: 'testnet',
|
||||
};
|
||||
|
|
@ -42,9 +42,9 @@ describe('Wallet model', function() {
|
|||
w.getNetworkName().should.equal('testnet');
|
||||
});
|
||||
|
||||
var createW = function(netKey, N) {
|
||||
var createW = function(netKey, N, conf) {
|
||||
|
||||
var c = JSON.parse(JSON.stringify(config));
|
||||
var c = JSON.parse(JSON.stringify(conf || config));
|
||||
if (!N) N = c.totalCopayers;
|
||||
|
||||
if (netKey) c.netKey = netKey;
|
||||
|
|
@ -122,10 +122,10 @@ describe('Wallet model', function() {
|
|||
"confirmations": 7
|
||||
}];
|
||||
|
||||
var createW2 = function(privateKeys, N) {
|
||||
var createW2 = function(privateKeys, N, conf) {
|
||||
if (!N) N = 3;
|
||||
var netKey = 'T0FbU2JLby0=';
|
||||
var w = createW(netKey, N);
|
||||
var w = createW(netKey, N, conf);
|
||||
should.exist(w);
|
||||
|
||||
var pkr = w.publicKeyRing;
|
||||
|
|
@ -467,6 +467,31 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('#getUnspent should honor spendUnconfirmed = false', function(done) {
|
||||
var conf = JSON.parse(JSON.stringify(config));
|
||||
conf.spendUnconfirmed = false;
|
||||
var w = createW2(null, null, conf);
|
||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||
balance.should.equal(2500010000);
|
||||
safeBalance.should.equal(0);
|
||||
balanceByAddr.mji7zocy8QzYywQakwWf99w9bCT6orY1C1.should.equal(2500010000);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('#getUnspent and spendUnconfirmed should count transactions with 1 confirmations', function(done) {
|
||||
var conf = JSON.parse(JSON.stringify(config));
|
||||
conf.spendUnconfirmed = false;
|
||||
var w = createW2(null, null, conf);
|
||||
w.blockchain.getUnspent = w.blockchain.getUnspent2;
|
||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||
balance.should.equal(2500010000);
|
||||
safeBalance.should.equal(2500010000);
|
||||
balanceByAddr.mji7zocy8QzYywQakwWf99w9bCT6orY1C1.should.equal(2500010000);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
var roundErrorChecks = [{
|
||||
unspent: [1.0001],
|
||||
balance: 100010000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue