-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client -> tx pool: improved pool closing, added basic unit test setup
- Loading branch information
Showing
2 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import tape from 'tape-catch' | ||
import { Config } from '../../lib/config' | ||
|
||
tape('[TxPool]', async (t) => { | ||
const { TxPool } = await import('../../lib/service/txpool') | ||
|
||
t.test('should initialize correctly', (t) => { | ||
const config = new Config({ transports: [], loglevel: 'error' }) | ||
const pool = new TxPool({ config }) | ||
t.equal(pool.pool.size, 0, 'pool empty') | ||
t.notOk((pool as any).opened, 'pool not opened yet') | ||
t.end() | ||
}) | ||
|
||
t.test('should open/close', async (t) => { | ||
t.plan(3) | ||
const config = new Config({ transports: [], loglevel: 'error' }) | ||
const pool = new TxPool({ config }) | ||
|
||
await pool.open() | ||
t.ok((pool as any).opened, 'pool opened') | ||
t.equals(await pool.open(), false, 'already opened') | ||
await pool.close() | ||
t.notOk((pool as any).opened, 'closed') | ||
t.end() | ||
}) | ||
}) |