make unit configurable in settings. update after @cmgustavo comments
This commit is contained in:
parent
12b45fcfb9
commit
00ca9f1c32
14 changed files with 359 additions and 259 deletions
|
|
@ -308,15 +308,21 @@ describe('TxProposals model', function() {
|
|||
|
||||
it('#merge, merge signatures case 2', function() {
|
||||
|
||||
var o1 ={ extendedPrivateKeyString: 'tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {} };
|
||||
var o2 ={ extendedPrivateKeyString: 'tprv8ZgxMBicQKsPdVeB5RzuxS9JQcACueZYgUaM5eWzaEBkHjW5Pg6Mqez1APSqoUP1jUdbT8WVG7ZJYTXvUL7XtPzFYBXjmdKuwSor1dcNQ8j',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {} };
|
||||
var o3 ={ extendedPrivateKeyString: 'tprv8ZgxMBicQKsPeHWNrPVZtQVgcCtXBr5TACNbDQ56rwqNJce9MEc64US6DJKxpWsrebEomxxWZFDtkvkZGkzA43uLvdF4XHiWqoNaL6Dq2Gd',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {} };
|
||||
var o1 = {
|
||||
extendedPrivateKeyString: 'tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {}
|
||||
};
|
||||
var o2 = {
|
||||
extendedPrivateKeyString: 'tprv8ZgxMBicQKsPdVeB5RzuxS9JQcACueZYgUaM5eWzaEBkHjW5Pg6Mqez1APSqoUP1jUdbT8WVG7ZJYTXvUL7XtPzFYBXjmdKuwSor1dcNQ8j',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {}
|
||||
};
|
||||
var o3 = {
|
||||
extendedPrivateKeyString: 'tprv8ZgxMBicQKsPeHWNrPVZtQVgcCtXBr5TACNbDQ56rwqNJce9MEc64US6DJKxpWsrebEomxxWZFDtkvkZGkzA43uLvdF4XHiWqoNaL6Dq2Gd',
|
||||
networkName: 'testnet',
|
||||
privateKeyCache: {}
|
||||
};
|
||||
|
||||
|
||||
var priv = PrivateKey.fromObj(o1);
|
||||
|
|
|
|||
|
|
@ -450,13 +450,13 @@ describe('Wallet model', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('#getBalance should return values in bits', function(done) {
|
||||
it('#getBalance should return values in satoshis', function(done) {
|
||||
var w = createW2();
|
||||
w.generateAddress();
|
||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||
balance.should.equal(25000100.00);
|
||||
safeBalance.should.equal(25000100.00);
|
||||
balanceByAddr.mji7zocy8QzYywQakwWf99w9bCT6orY1C1.should.equal(25000100.00);
|
||||
balance.should.equal(2500010000);
|
||||
safeBalance.should.equal(2500010000);
|
||||
balanceByAddr.mji7zocy8QzYywQakwWf99w9bCT6orY1C1.should.equal(2500010000);
|
||||
Object.keys(balanceByAddr).length.should.equal(1);
|
||||
done();
|
||||
});
|
||||
|
|
@ -464,19 +464,19 @@ describe('Wallet model', function() {
|
|||
|
||||
var roundErrorChecks = [{
|
||||
unspent: [1.0001],
|
||||
balance: 1000100
|
||||
balance: 100010000
|
||||
}, {
|
||||
unspent: [1.0002, 1.0003, 1.0004],
|
||||
balance: 3000900
|
||||
balance: 300090000
|
||||
}, {
|
||||
unspent: [0.000002, 1.000003, 2.000004],
|
||||
balance: 3000009
|
||||
balance: 300000900
|
||||
}, {
|
||||
unspent: [0.0001, 0.0003],
|
||||
balance: 400
|
||||
balance: 40000
|
||||
}, {
|
||||
unspent: [0.0001, 0.0003, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0002],
|
||||
balance: 1100
|
||||
balance: 110000
|
||||
},
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@ describe("Unit: Testing Directives", function() {
|
|||
|
||||
beforeEach(module('copayApp.directives'));
|
||||
|
||||
|
||||
describe('Check config', function() {
|
||||
it('unit should be set to BITS in config.js', function() {
|
||||
expect(config.unitToSatoshi).to.equal(100);
|
||||
expect(config.unitName).to.equal('bits');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Validate Address', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
|
|
@ -15,8 +23,10 @@ describe("Unit: Testing Directives", function() {
|
|||
'<form name="form">' +
|
||||
'<input type="text" id="address" name="address" placeholder="Send to" ng-model="address" valid-address required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = { address: null };
|
||||
);
|
||||
$scope.model = {
|
||||
address: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
|
|
@ -35,42 +45,47 @@ describe("Unit: Testing Directives", function() {
|
|||
describe('Validate Amount', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
$rootScope.availableBalance = 0.101;
|
||||
$rootScope.availableBalance = 1000;
|
||||
var element = angular.element(
|
||||
'<form name="form">' +
|
||||
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.0001" max="10000000" enough-amount required>' +
|
||||
'</form>'
|
||||
);
|
||||
$scope.model = { amount: null };
|
||||
);
|
||||
$scope.model = {
|
||||
amount: null
|
||||
};
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
form = $scope.form;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
it('should validate', function() {
|
||||
form.amount.$setViewValue(0.1);
|
||||
form.amount.$setViewValue(100);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
form.amount.$setViewValue(0.1009);
|
||||
form.amount.$setViewValue(900);
|
||||
expect(form.amount.$invalid).to.equal(false);
|
||||
});
|
||||
|
||||
it('should not validate', function() {
|
||||
form.amount.$setViewValue(0);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(9999999999);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(2.1);
|
||||
form.amount.$setViewValue(901);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
form.amount.$setViewValue(0.10091);
|
||||
form.amount.$setViewValue(1000);
|
||||
expect(form.amount.$invalid).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Password strength', function() {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$scope = $rootScope;
|
||||
var element = angular.element(
|
||||
'<input type="password" name="password" ng-model="password" check-strength="passwordStrength" value="asd" required>'
|
||||
);
|
||||
);
|
||||
$compile(element)($scope);
|
||||
$scope.$digest();
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
//
|
||||
// test/unit/services/servicesSpec.js
|
||||
//
|
||||
//
|
||||
//
|
||||
describe('Check config', function() {
|
||||
it('unit should be set to BITS in config.js', function() {
|
||||
expect(config.unitToSatoshi).to.equal(100);
|
||||
expect(config.unitName).to.equal('bits');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Unit: Socket Service", function() {
|
||||
beforeEach(angular.mock.module('copayApp.services'));
|
||||
|
||||
|
|
@ -20,9 +30,9 @@ describe("Unit: Socket Service", function() {
|
|||
|
||||
|
||||
it('Socket should add handlers with #on', inject(function(Socket) {
|
||||
Socket.on('a', function (){});
|
||||
Socket.on('b', function (){});
|
||||
Socket.sysOn('c', function (){});
|
||||
Socket.on('a', function() {});
|
||||
Socket.on('b', function() {});
|
||||
Socket.sysOn('c', function() {});
|
||||
var ret = Socket.getListeners();
|
||||
expect(ret.a).to.be.equal(1);
|
||||
expect(ret.b).to.be.equal(1);
|
||||
|
|
@ -30,9 +40,9 @@ describe("Unit: Socket Service", function() {
|
|||
}));
|
||||
|
||||
it('Socket should support #removeAllListeners', inject(function(Socket) {
|
||||
Socket.on('a', function (){});
|
||||
Socket.on('b', function (){});
|
||||
Socket.sysOn('c', function (){});
|
||||
Socket.on('a', function() {});
|
||||
Socket.on('b', function() {});
|
||||
Socket.sysOn('c', function() {});
|
||||
var ret = Socket.getListeners();
|
||||
expect(Object.keys(ret)).to.have.length(2);
|
||||
Socket.removeAllListeners();
|
||||
|
|
@ -57,16 +67,19 @@ describe("Unit: controllerUtils", function() {
|
|||
expect(controllerUtils.updateBalance).not.to.equal(null);
|
||||
scope = $rootScope.$new();
|
||||
|
||||
$rootScope.wallet=new FakeWallet();
|
||||
$rootScope.wallet = new FakeWallet();
|
||||
var addr = '1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC';
|
||||
var a = {}; a[addr]=100;
|
||||
$rootScope.wallet.set(1000000,900000,a);
|
||||
var a = {};
|
||||
a[addr] = 100;
|
||||
//SATs
|
||||
$rootScope.wallet.set(100000001, 90000002, a);
|
||||
|
||||
//retuns values in DEFAULT UNIT(bits)
|
||||
controllerUtils.updateBalance(function() {
|
||||
expect($rootScope.totalBalance).to.be.equal(1000000);
|
||||
expect($rootScope.totalBalanceBTC).to.be.equal('1.000');
|
||||
expect($rootScope.availableBalance).to.be.equal(900000);
|
||||
expect($rootScope.availableBalanceBTC).to.be.equal('0.900');
|
||||
expect($rootScope.totalBalanceBTC).to.be.equal('1.0000');
|
||||
expect($rootScope.availableBalanceBTC).to.be.equal('0.9000');
|
||||
expect($rootScope.totalBalance).to.be.equal(1000000.01);
|
||||
expect($rootScope.availableBalance).to.be.equal(900000.02);
|
||||
expect($rootScope.addrInfos).not.to.equal(null);
|
||||
expect($rootScope.addrInfos[0].address).to.equal(addr);
|
||||
});
|
||||
|
|
@ -74,4 +87,3 @@ describe("Unit: controllerUtils", function() {
|
|||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue