Sync address book with all copayer
This commit is contained in:
parent
21baa103bd
commit
4aa3915381
6 changed files with 117 additions and 35 deletions
|
|
@ -63,6 +63,19 @@ describe('Wallet model', function() {
|
|||
c.network = new Network(config.network);
|
||||
c.blockchain = new Blockchain(config.blockchain);
|
||||
|
||||
c.addressBook = {
|
||||
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ' : {
|
||||
label: 'John',
|
||||
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
||||
createdTs: 1403102115,
|
||||
},
|
||||
'2MtP8WyiwG7ZdVWM96CVsk2M1N8zyfiVQsY' : {
|
||||
label: 'Jennifer',
|
||||
copayerId: '032991f836543a492bd6d0bb112552bfc7c5f3b7d5388fcbcbf2fbb893b44770d7',
|
||||
createdTs: 1403103115,
|
||||
}
|
||||
};
|
||||
|
||||
c.networkName = config.networkName;
|
||||
c.verbose = config.verbose;
|
||||
c.version = '0.0.1';
|
||||
|
|
@ -594,27 +607,30 @@ describe('Wallet model', function() {
|
|||
w.getNetworkName().should.equal('testnet');
|
||||
});
|
||||
|
||||
var contacts = [{
|
||||
address: '2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ',
|
||||
label: 'John'
|
||||
}, {
|
||||
address: '2MtP8WyiwG7ZdVWM96CVsk2M1N8zyfiVQsY',
|
||||
label: 'Jennifer'
|
||||
}];
|
||||
var contacts = [
|
||||
{
|
||||
label: 'Charles',
|
||||
address: '2N8pJWpXCAxmNLHKVEhz3TtTcYCtHd43xWU ',
|
||||
},
|
||||
{
|
||||
label: 'Linda',
|
||||
address: '2N4Zq92goYGrf5J4F4SZZq7jnPYbCiyRYT2 ',
|
||||
}
|
||||
];
|
||||
|
||||
it('should create new entry for address book', function() {
|
||||
var w = createW();
|
||||
contacts.forEach(function(c) {
|
||||
w.setAddressBook(c);
|
||||
w.setAddressBook(c.address, c.label);
|
||||
});
|
||||
w.addressBook.length.should.equal(2);
|
||||
Object.keys(w.addressBook).length.should.equal(4);
|
||||
});
|
||||
|
||||
it('should fail if create a duplicate address', function() {
|
||||
var w = createW();
|
||||
w.setAddressBook(contacts[0]);
|
||||
w.setAddressBook(contacts[0].address, contacts[0].label);
|
||||
(function() {
|
||||
w.setAddressBook(contacts[0]);
|
||||
w.setAddressBook(contacts[0].address, contacts[0].label);
|
||||
}).should.
|
||||
throw();
|
||||
});
|
||||
|
|
@ -622,11 +638,12 @@ describe('Wallet model', function() {
|
|||
it('should delete an entry for address book', function() {
|
||||
var w = createW();
|
||||
contacts.forEach(function(c) {
|
||||
w.setAddressBook(c);
|
||||
w.setAddressBook(c.address, c.label);
|
||||
});
|
||||
w.addressBook.length.should.equal(2);
|
||||
w.deleteAddressBook(contacts[0]);
|
||||
w.addressBook.length.should.equal(1);
|
||||
Object.keys(w.addressBook).length.should.equal(4);
|
||||
var key = contacts[0].address;
|
||||
w.deleteAddressBook(key);
|
||||
w.addressBook[key].copayerId.should.equal(-1);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue