test: add more wallet double spend tests.

This commit is contained in:
Christopher Jeffrey 2017-10-19 14:53:10 -07:00
parent bd4367a2d1
commit 175f169504
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -479,6 +479,29 @@ describe('Wallet', function() {
}
});
it('should handle double-spend (not our input)', async () => {
const wallet = await wdb.create();
const t1 = new MTX();
const input = dummyInput();
t1.addInput(input);
t1.addOutput(await wallet.receiveAddress(), 50000);
await wdb.addTX(t1.toTX());
assert.strictEqual((await wallet.getBalance()).unconfirmed, 50000);
let conflict = false;
wallet.on('conflict', () => {
conflict = true;
});
const t2 = new MTX();
t2.addInput(input);
t2.addOutput(new Address(), 5000);
await wdb.addTX(t2.toTX());
assert(conflict);
assert.strictEqual((await wallet.getBalance()).unconfirmed, 0);
});
it('should handle more missed txs', async () => {
const alice = await wdb.create();
const bob = await wdb.create();