Merge pull request #776 from nodar-chkuaselidze/blockstore-minor

blockstore-test: use try/catch instead of promise.catch/finally.
This commit is contained in:
Braydon Fuller 2019-05-18 08:55:22 -07:00
commit c2c16e2dd3
No known key found for this signature in database
GPG Key ID: F24F232D108B3AD4

View File

@ -813,17 +813,20 @@ describe('BlockStore', function() {
// Accidentally don't use `await` and attempt to // Accidentally don't use `await` and attempt to
// write multiple blocks in parallel and at the // write multiple blocks in parallel and at the
// same file position. // same file position.
const promise = store.write(hash, block); (async () => {
promise.catch((e) => { try {
await store.write(hash, block);
} catch (e) {
err = e; err = e;
}).finally(() => { } finally {
finished += 1; finished += 1;
if (finished >= 16) { if (finished >= 16) {
assert(err); assert(err);
assert(err.message, 'Already writing.'); assert(err.message, 'Already writing.');
done(); done();
} }
}); }
})();
} }
}); });