wdb: fix hasAccount

This commit is contained in:
Nodar Chkuaselidze 2018-03-18 20:40:23 -07:00 committed by Christopher Jeffrey
parent 5f47b23736
commit 179c53d97f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 32 additions and 1 deletions

View File

@ -762,7 +762,7 @@ class Wallet extends EventEmitter {
if (index === -1)
return false;
return this.db.hasAccount(this.wid, index);
return this.wdb.hasAccount(this.wid, index);
}
/**

View File

@ -804,6 +804,37 @@ describe('Wallet', function() {
await testP2SH(true, true);
});
it('should create account', async () => {
const wallet = await wdb.create();
const account = await wallet.createAccount({
name: 'foo'
});
assert(account);
assert(account.initialized);
assert.strictEqual(account.name, 'foo');
assert.strictEqual(account.accountIndex, 1);
assert.strictEqual(account.m, 1);
assert.strictEqual(account.n, 1);
});
it('should fail to create duplicate account', async () => {
const wallet = await wdb.create();
const name = 'foo';
await wallet.createAccount({ name });
let err;
try {
await wallet.createAccount({ name });
} catch (e) {
err = e;
}
assert(err);
assert.strictEqual(err.message, 'Account already exists.');
});
it('should fill tx with account 1', async () => {
const alice = await wdb.create();
const bob = await wdb.create();