test: refactor walletdb usage.

This commit is contained in:
Christopher Jeffrey 2017-07-25 15:56:02 -07:00
parent 87d664784c
commit 9c87804b08
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 106 additions and 107 deletions

View File

@ -11,16 +11,16 @@ const MTX = require('../lib/primitives/mtx');
const HTTP = require('../lib/http'); const HTTP = require('../lib/http');
const FullNode = require('../lib/node/fullnode'); const FullNode = require('../lib/node/fullnode');
const pkg = require('../lib/pkg'); const pkg = require('../lib/pkg');
const plugin = require('../lib/wallet/plugin');
describe('HTTP', function() { describe('HTTP', function() {
let node, wallet, walletdb, addr, hash; let node, wallet, wdb, addr, hash;
node = new FullNode({ node = new FullNode({
network: 'regtest', network: 'regtest',
apiKey: 'foo', apiKey: 'foo',
walletAuth: true, walletAuth: true,
db: 'memory' db: 'memory',
plugins: [require('../lib/wallet/plugin')]
}); });
wallet = new HTTP.Wallet({ wallet = new HTTP.Wallet({
@ -28,9 +28,7 @@ describe('HTTP', function() {
apiKey: 'foo' apiKey: 'foo'
}); });
walletdb = node.use(plugin); wdb = node.require('walletdb');
node.on('error', () => {});
this.timeout(15000); this.timeout(15000);
@ -85,7 +83,7 @@ describe('HTTP', function() {
details = d; details = d;
}); });
await walletdb.addTX(tx); await wdb.addTX(tx);
await co.timeout(300); await co.timeout(300);
assert(receive); assert(receive);

View File

@ -10,22 +10,23 @@ const FullNode = require('../lib/node/fullnode');
const MTX = require('../lib/primitives/mtx'); const MTX = require('../lib/primitives/mtx');
const TX = require('../lib/primitives/tx'); const TX = require('../lib/primitives/tx');
const Address = require('../lib/primitives/address'); const Address = require('../lib/primitives/address');
const plugin = require('../lib/wallet/plugin');
describe('Node', function() { describe('Node', function() {
let node = new FullNode({ let node, chain, wdb, miner;
db: 'memory',
apiKey: 'foo',
network: 'regtest',
workers: true
});
let chain = node.chain;
let walletdb = node.use(plugin);
let miner = node.miner;
let wallet, tip1, tip2, cb1, cb2; let wallet, tip1, tip2, cb1, cb2;
let tx1, tx2; let tx1, tx2;
node.on('error', () => {}); node = new FullNode({
db: 'memory',
apiKey: 'foo',
network: 'regtest',
workers: true,
plugins: [require('../lib/wallet/plugin')]
});
chain = node.chain;
miner = node.miner;
wdb = node.require('walletdb');
this.timeout(5000); this.timeout(5000);
@ -60,7 +61,7 @@ describe('Node', function() {
}); });
it('should open walletdb', async () => { it('should open walletdb', async () => {
wallet = await walletdb.create(); wallet = await wdb.create();
miner.addresses.length = 0; miner.addresses.length = 0;
miner.addAddress(wallet.getReceive()); miner.addAddress(wallet.getReceive());
}); });
@ -118,7 +119,7 @@ describe('Node', function() {
it('should handle a reorg', async () => { it('should handle a reorg', async () => {
let entry, block, forked; let entry, block, forked;
assert.equal(walletdb.state.height, chain.height); assert.equal(wdb.state.height, chain.height);
assert.equal(chain.height, 11); assert.equal(chain.height, 11);
entry = await chain.db.getEntry(tip2.hash); entry = await chain.db.getEntry(tip2.hash);
@ -242,7 +243,7 @@ describe('Node', function() {
assert(wallet.account.receiveDepth >= 7); assert(wallet.account.receiveDepth >= 7);
assert(wallet.account.changeDepth >= 6); assert(wallet.account.changeDepth >= 6);
assert.equal(walletdb.state.height, chain.height); assert.equal(wdb.state.height, chain.height);
txs = await wallet.getHistory(); txs = await wallet.getHistory();
assert.equal(txs.length, 45); assert.equal(txs.length, 45);
@ -265,7 +266,7 @@ describe('Node', function() {
it('should rescan for transactions', async () => { it('should rescan for transactions', async () => {
let total = 0; let total = 0;
await chain.db.scan(0, walletdb.filter, (block, txs) => { await chain.db.scan(0, wdb.filter, (block, txs) => {
total += txs.length; total += txs.length;
return Promise.resolve(); return Promise.resolve();
}); });
@ -450,7 +451,7 @@ describe('Node', function() {
}); });
it('should rescan for transactions', async () => { it('should rescan for transactions', async () => {
await walletdb.rescan(0); await wdb.rescan(0);
assert.equal(wallet.txdb.state.confirmed, 1289250000000); assert.equal(wallet.txdb.state.confirmed, 1289250000000);
}); });

View File

@ -53,10 +53,10 @@ function dummy(hash) {
} }
describe('Wallet', function() { describe('Wallet', function() {
let walletdb, wallet, ewallet, ekey; let wdb, wallet, ewallet, ekey;
let doubleSpendWallet, doubleSpend; let doubleSpendWallet, doubleSpend;
walletdb = new WalletDB({ wdb = new WalletDB({
name: 'wallet-test', name: 'wallet-test',
db: 'memory', db: 'memory',
verify: true verify: true
@ -66,11 +66,11 @@ describe('Wallet', function() {
it('should open walletdb', async () => { it('should open walletdb', async () => {
consensus.COINBASE_MATURITY = 0; consensus.COINBASE_MATURITY = 0;
await walletdb.open(); await wdb.open();
}); });
it('should generate new key and address', async () => { it('should generate new key and address', async () => {
let w = await walletdb.create(); let w = await wdb.create();
let addr = w.getAddress('string'); let addr = w.getAddress('string');
assert(addr); assert(addr);
assert(Address.fromString(addr)); assert(Address.fromString(addr));
@ -89,10 +89,10 @@ describe('Wallet', function() {
it('should create and get wallet', async () => { it('should create and get wallet', async () => {
let w1, w2; let w1, w2;
w1 = await walletdb.create(); w1 = await wdb.create();
await w1.destroy(); await w1.destroy();
w2 = await walletdb.get(w1.id); w2 = await wdb.get(w1.id);
assert(w1 !== w2); assert(w1 !== w2);
assert(w1.master !== w2.master); assert(w1.master !== w2.master);
@ -106,7 +106,7 @@ describe('Wallet', function() {
let flags = Script.flags.STANDARD_VERIFY_FLAGS; let flags = Script.flags.STANDARD_VERIFY_FLAGS;
let w, addr, src, tx; let w, addr, src, tx;
w = await walletdb.create({ witness: witness }); w = await wdb.create({ witness: witness });
addr = Address.fromString(w.getAddress('string')); addr = Address.fromString(w.getAddress('string'));
@ -145,7 +145,7 @@ describe('Wallet', function() {
it('should multisign/verify TX', async () => { it('should multisign/verify TX', async () => {
let w, k, script, src, tx, maxSize; let w, k, script, src, tx, maxSize;
w = await walletdb.create({ w = await wdb.create({
type: 'multisig', type: 'multisig',
m: 1, m: 1,
n: 2 n: 2
@ -180,8 +180,8 @@ describe('Wallet', function() {
}); });
it('should handle missed and invalid txs', async () => { it('should handle missed and invalid txs', async () => {
let w = await walletdb.create(); let w = await wdb.create();
let f = await walletdb.create(); let f = await wdb.create();
let t1, t2, t3, t4, f1, fake, balance, txs; let t1, t2, t3, t4, f1, fake, balance, txs;
// Coinbase // Coinbase
@ -242,29 +242,29 @@ describe('Wallet', function() {
fake = fake.toTX(); fake = fake.toTX();
// Fake TX should temporarily change output. // Fake TX should temporarily change output.
await walletdb.addTX(fake); await wdb.addTX(fake);
await walletdb.addTX(t4); await wdb.addTX(t4);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 22500); assert.equal(balance.unconfirmed, 22500);
await walletdb.addTX(t1); await wdb.addTX(t1);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 72500); assert.equal(balance.unconfirmed, 72500);
await walletdb.addTX(t2); await wdb.addTX(t2);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 46500); assert.equal(balance.unconfirmed, 46500);
await walletdb.addTX(t3); await wdb.addTX(t3);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 22000); assert.equal(balance.unconfirmed, 22000);
await walletdb.addTX(f1); await wdb.addTX(f1);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 11000); assert.equal(balance.unconfirmed, 11000);
@ -305,7 +305,7 @@ describe('Wallet', function() {
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 11000); assert.equal(balance.unconfirmed, 11000);
await walletdb.addTX(tx); await wdb.addTX(tx);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 6000); assert.equal(balance.unconfirmed, 6000);
@ -320,18 +320,18 @@ describe('Wallet', function() {
}); });
it('should handle missed txs without resolution', async () => { it('should handle missed txs without resolution', async () => {
let walletdb, w, f, t1, t2, t3, t4, f1, balance, txs; let wdb, w, f, t1, t2, t3, t4, f1, balance, txs;
walletdb = new WalletDB({ wdb = new WalletDB({
name: 'wallet-test', name: 'wallet-test',
db: 'memory', db: 'memory',
verify: false verify: false
}); });
await walletdb.open(); await wdb.open();
w = await walletdb.create(); w = await wdb.create();
f = await walletdb.create(); f = await wdb.create();
// Coinbase // Coinbase
t1 = new MTX(); t1 = new MTX();
@ -389,29 +389,29 @@ describe('Wallet', function() {
// fake = fake.toTX(); // fake = fake.toTX();
// Fake TX should temporarly change output // Fake TX should temporarly change output
// await walletdb.addTX(fake); // await wdb.addTX(fake);
await walletdb.addTX(t4); await wdb.addTX(t4);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 22000); assert.equal(balance.unconfirmed, 22000);
await walletdb.addTX(t1); await wdb.addTX(t1);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 73000); assert.equal(balance.unconfirmed, 73000);
await walletdb.addTX(t2); await wdb.addTX(t2);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 47000); assert.equal(balance.unconfirmed, 47000);
await walletdb.addTX(t3); await wdb.addTX(t3);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 22000); assert.equal(balance.unconfirmed, 22000);
await walletdb.addTX(f1); await wdb.addTX(f1);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 11000); assert.equal(balance.unconfirmed, 11000);
@ -429,13 +429,13 @@ describe('Wallet', function() {
return wtx.tx.hash('hex') === f1.hash('hex'); return wtx.tx.hash('hex') === f1.hash('hex');
})); }));
await walletdb.addTX(t2); await wdb.addTX(t2);
await walletdb.addTX(t3); await wdb.addTX(t3);
await walletdb.addTX(t4); await wdb.addTX(t4);
await walletdb.addTX(f1); await wdb.addTX(f1);
balance = await w.getBalance(); balance = await w.getBalance();
assert.equal(balance.unconfirmed, 11000); assert.equal(balance.unconfirmed, 11000);
@ -445,8 +445,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with inputs', async () => { it('should fill tx with inputs', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let view, t1, t2, t3, err; let view, t1, t2, t3, err;
// Coinbase // Coinbase
@ -459,7 +459,7 @@ describe('Wallet', function() {
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Create new transaction // Create new transaction
t2 = new MTX(); t2 = new MTX();
@ -490,8 +490,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with inputs with accurate fee', async () => { it('should fill tx with inputs with accurate fee', async () => {
let w1 = await walletdb.create({ master: KEY1 }); let w1 = await wdb.create({ master: KEY1 });
let w2 = await walletdb.create({ master: KEY2 }); let w2 = await wdb.create({ master: KEY2 });
let view, t1, t2, t3, balance, err; let view, t1, t2, t3, balance, err;
// Coinbase // Coinbase
@ -503,7 +503,7 @@ describe('Wallet', function() {
t1.addOutput(w1.getAddress(), 5460); t1.addOutput(w1.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Create new transaction // Create new transaction
t2 = new MTX(); t2 = new MTX();
@ -531,7 +531,7 @@ describe('Wallet', function() {
balance = b; balance = b;
}); });
await walletdb.addTX(t2); await wdb.addTX(t2);
// Create new transaction // Create new transaction
t3 = new MTX(); t3 = new MTX();
@ -549,9 +549,9 @@ describe('Wallet', function() {
}); });
it('should sign multiple inputs using different keys', async () => { it('should sign multiple inputs using different keys', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let to = await walletdb.create(); let to = await wdb.create();
let t1, t2, tx, cost, total, coins1, coins2; let t1, t2, tx, cost, total, coins1, coins2;
// Coinbase // Coinbase
@ -572,8 +572,8 @@ describe('Wallet', function() {
t2.addOutput(w2.getAddress(), 5460); t2.addOutput(w2.getAddress(), 5460);
t2 = t2.toTX(); t2 = t2.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
await walletdb.addTX(t2); await wdb.addTX(t2);
// Create our tx with an output // Create our tx with an output
tx = new MTX(); tx = new MTX();
@ -631,10 +631,10 @@ describe('Wallet', function() {
n: 3 n: 3
}; };
w1 = await walletdb.create(options); w1 = await wdb.create(options);
w2 = await walletdb.create(options); w2 = await wdb.create(options);
w3 = await walletdb.create(options); w3 = await wdb.create(options);
receive = await walletdb.create(); receive = await wdb.create();
await w1.addSharedKey(w2.account.accountKey); await w1.addSharedKey(w2.account.accountKey);
await w1.addSharedKey(w3.account.accountKey); await w1.addSharedKey(w3.account.accountKey);
@ -680,7 +680,7 @@ describe('Wallet', function() {
assert.equal(w1.account[depth], 1); assert.equal(w1.account[depth], 1);
await walletdb.addBlock(block, [utx]); await wdb.addBlock(block, [utx]);
assert.equal(w1.account[depth], 2); assert.equal(w1.account[depth], 2);
@ -718,7 +718,7 @@ describe('Wallet', function() {
// Simulate a confirmation // Simulate a confirmation
block = nextBlock(); block = nextBlock();
await walletdb.addBlock(block, [send]); await wdb.addBlock(block, [send]);
assert.equal(w1.account[depth], 2); assert.equal(w1.account[depth], 2);
assert.equal(w1.account.changeDepth, 2); assert.equal(w1.account.changeDepth, 2);
@ -755,8 +755,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with account 1', async () => { it('should fill tx with account 1', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let account, accounts, rec, t1, t2, t3, err; let account, accounts, rec, t1, t2, t3, err;
account = await w1.createAccount({ name: 'foo' }); account = await w1.createAccount({ name: 'foo' });
@ -778,7 +778,7 @@ describe('Wallet', function() {
t1.addInput(dummy()); t1.addInput(dummy());
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Create new transaction // Create new transaction
t2 = new MTX(); t2 = new MTX();
@ -810,7 +810,7 @@ describe('Wallet', function() {
}); });
it('should fail to fill tx with account 1', async () => { it('should fail to fill tx with account 1', async () => {
let w = await walletdb.create(); let w = await wdb.create();
let acc, account, t1, t2, err; let acc, account, t1, t2, err;
wallet = w; wallet = w;
@ -842,7 +842,7 @@ describe('Wallet', function() {
t1.addInput(dummy()); t1.addInput(dummy());
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Should fill from `foo` and fail // Should fill from `foo` and fail
t2 = new MTX(); t2 = new MTX();
@ -867,7 +867,7 @@ describe('Wallet', function() {
t1.addOutput(account.receive.getAddress(), 5460); t1.addOutput(account.receive.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Should fill from `foo` and succeed // Should fill from `foo` and succeed
t2 = new MTX(); t2 = new MTX();
@ -876,12 +876,12 @@ describe('Wallet', function() {
}); });
it('should create two accounts (multiple encryption)', async () => { it('should create two accounts (multiple encryption)', async () => {
let w = await walletdb.create({ id: 'foobar', passphrase: 'foo' }); let w = await wdb.create({ id: 'foobar', passphrase: 'foo' });
let account; let account;
await w.destroy(); await w.destroy();
w = await walletdb.get('foobar'); w = await wdb.get('foobar');
account = await w.createAccount({ name: 'foo1' }, 'foo'); account = await w.createAccount({ name: 'foo1' }, 'foo');
assert(account); assert(account);
@ -890,7 +890,7 @@ describe('Wallet', function() {
}); });
it('should fill tx with inputs when encrypted', async () => { it('should fill tx with inputs when encrypted', async () => {
let w = await walletdb.create({ passphrase: 'foo' }); let w = await wdb.create({ passphrase: 'foo' });
let t1, t2, err; let t1, t2, err;
w.master.stop(); w.master.stop();
@ -905,7 +905,7 @@ describe('Wallet', function() {
t1.addOutput(w.getAddress(), 5460); t1.addOutput(w.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Create new transaction // Create new transaction
t2 = new MTX(); t2 = new MTX();
@ -928,8 +928,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with inputs with subtract fee (1)', async () => { it('should fill tx with inputs with subtract fee (1)', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let t1, t2; let t1, t2;
// Coinbase // Coinbase
@ -941,7 +941,7 @@ describe('Wallet', function() {
t1.addOutput(w1.getAddress(), 5460); t1.addOutput(w1.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Create new transaction // Create new transaction
t2 = new MTX(); t2 = new MTX();
@ -957,8 +957,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with inputs with subtract fee (2)', async () => { it('should fill tx with inputs with subtract fee (2)', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let options, t1, t2; let options, t1, t2;
// Coinbase // Coinbase
@ -970,7 +970,7 @@ describe('Wallet', function() {
t1.addOutput(w1.getAddress(), 5460); t1.addOutput(w1.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
options = { options = {
subtractFee: true, subtractFee: true,
@ -991,8 +991,8 @@ describe('Wallet', function() {
}); });
it('should fill tx with smart coin selection', async () => { it('should fill tx with smart coin selection', async () => {
let w1 = await walletdb.create(); let w1 = await wdb.create();
let w2 = await walletdb.create(); let w2 = await wdb.create();
let found = false; let found = false;
let total = 0; let total = 0;
let i, options, t1, t2, t3, block, coins, coin; let i, options, t1, t2, t3, block, coins, coin;
@ -1006,7 +1006,7 @@ describe('Wallet', function() {
t1.addOutput(w1.getAddress(), 5460); t1.addOutput(w1.getAddress(), 5460);
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
// Coinbase // Coinbase
t2 = new MTX(); t2 = new MTX();
@ -1019,7 +1019,7 @@ describe('Wallet', function() {
block = nextBlock(); block = nextBlock();
await walletdb.addBlock(block, [t2]); await wdb.addBlock(block, [t2]);
coins = await w1.getSmartCoins(); coins = await w1.getSmartCoins();
assert.equal(coins.length, 4); assert.equal(coins.length, 4);
@ -1119,7 +1119,7 @@ describe('Wallet', function() {
it('should import privkey', async () => { it('should import privkey', async () => {
let key = KeyRing.generate(); let key = KeyRing.generate();
let w = await walletdb.create({ passphrase: 'test' }); let w = await wdb.create({ passphrase: 'test' });
let options, k, t1, t2, wtx; let options, k, t1, t2, wtx;
await w.importKey('default', key, 'test'); await w.importKey('default', key, 'test');
@ -1138,7 +1138,7 @@ describe('Wallet', function() {
t1.addInput(dummy()); t1.addInput(dummy());
t1 = t1.toTX(); t1 = t1.toTX();
await walletdb.addTX(t1); await wdb.addTX(t1);
wtx = await w.getTX(t1.hash('hex')); wtx = await w.getTX(t1.hash('hex'));
assert(wtx); assert(wtx);
@ -1163,7 +1163,7 @@ describe('Wallet', function() {
it('should import pubkey', async () => { it('should import pubkey', async () => {
let priv = KeyRing.generate(); let priv = KeyRing.generate();
let key = new KeyRing(priv.publicKey); let key = new KeyRing(priv.publicKey);
let w = await walletdb.create({ watchOnly: true }); let w = await wdb.create({ watchOnly: true });
let k; let k;
await w.importKey('default', key); await w.importKey('default', key);
@ -1178,7 +1178,7 @@ describe('Wallet', function() {
it('should import address', async () => { it('should import address', async () => {
let key = KeyRing.generate(); let key = KeyRing.generate();
let w = await walletdb.create({ watchOnly: true }); let w = await wdb.create({ watchOnly: true });
let k; let k;
await w.importAddress('default', key.getAddress()); await w.importAddress('default', key.getAddress());
@ -1248,18 +1248,18 @@ describe('Wallet', function() {
}); });
it('should recover from a missed tx', async () => { it('should recover from a missed tx', async () => {
let walletdb, alice, addr, bob, t1, t2, t3; let wdb, alice, addr, bob, t1, t2, t3;
walletdb = new WalletDB({ wdb = new WalletDB({
name: 'wallet-test', name: 'wallet-test',
db: 'memory', db: 'memory',
verify: false verify: false
}); });
await walletdb.open(); await wdb.open();
alice = await walletdb.create({ master: KEY1 }); alice = await wdb.create({ master: KEY1 });
bob = await walletdb.create({ master: KEY1 }); bob = await wdb.create({ master: KEY1 });
addr = alice.getAddress(); addr = alice.getAddress();
// Coinbase // Coinbase
@ -1312,18 +1312,18 @@ describe('Wallet', function() {
}); });
it('should recover from a missed tx and double spend', async () => { it('should recover from a missed tx and double spend', async () => {
let walletdb, alice, addr, bob, t1, t2, t3, t2a; let wdb, alice, addr, bob, t1, t2, t3, t2a;
walletdb = new WalletDB({ wdb = new WalletDB({
name: 'wallet-test', name: 'wallet-test',
db: 'memory', db: 'memory',
verify: false verify: false
}); });
await walletdb.open(); await wdb.open();
alice = await walletdb.create({ master: KEY1 }); alice = await wdb.create({ master: KEY1 });
bob = await walletdb.create({ master: KEY1 }); bob = await wdb.create({ master: KEY1 });
addr = alice.getAddress(); addr = alice.getAddress();
// Coinbase // Coinbase