Skip to content

Commit

Permalink
Merge pull request bcoin-org#776 from nodar-chkuaselidze/blockstore-m…
Browse files Browse the repository at this point in the history
…inor

blockstore-test: use try/catch instead of promise.catch/finally.
  • Loading branch information
braydonf committed May 18, 2019
2 parents 4c49b08 + 1fceb14 commit c2c16e2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/blockstore-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,17 +813,20 @@ describe('BlockStore', function() {
// Accidentally don't use `await` and attempt to
// write multiple blocks in parallel and at the
// same file position.
const promise = store.write(hash, block);
promise.catch((e) => {
err = e;
}).finally(() => {
finished += 1;
if (finished >= 16) {
assert(err);
assert(err.message, 'Already writing.');
done();
(async () => {
try {
await store.write(hash, block);
} catch (e) {
err = e;
} finally {
finished += 1;
if (finished >= 16) {
assert(err);
assert(err.message, 'Already writing.');
done();
}
}
});
})();
}
});

Expand Down

0 comments on commit c2c16e2

Please sign in to comment.