diff --git a/src/lib/core.ts b/src/lib/core.ts index 15f3b6a..5973ad6 100644 --- a/src/lib/core.ts +++ b/src/lib/core.ts @@ -28,6 +28,7 @@ export class CoreDaemon extends EventEmitter { readonly _client : CoreClient readonly _opt : CoreConfig readonly params : string[] + readonly tasks : RunMethod[] _closing : boolean _faucet : CoreWallet | null @@ -51,6 +52,7 @@ export class CoreDaemon extends EventEmitter { this._closing = false this._faucet = null this._ready = false + this.tasks = [] this.params = [ `-chain=${opt.network}`, @@ -163,6 +165,7 @@ export class CoreDaemon extends EventEmitter { bal = await this.faucet.balance } } + await Promise.all(this.tasks.map(t => t(this.client))) } async startup (params : string[] = []) { diff --git a/test/src/base.test.ts b/test/src/base.test.ts index 2398240..137d950 100644 --- a/test/src/base.test.ts +++ b/test/src/base.test.ts @@ -1,6 +1,8 @@ import { Test } from 'tape' import { CoreClient } from '../../src/index.js' +import './util.js' + const { DEBUG = false } = process.env export default function ( diff --git a/test/src/util.ts b/test/src/util.ts new file mode 100644 index 0000000..831f342 --- /dev/null +++ b/test/src/util.ts @@ -0,0 +1 @@ +import { core } from '../tape.js' \ No newline at end of file diff --git a/test/tape.ts b/test/tape.ts index 7195d7e..6478cc3 100644 --- a/test/tape.ts +++ b/test/tape.ts @@ -4,17 +4,22 @@ import { CoreDaemon } from '../src/index.js' import base_test from './src/base.test.js' import send_test from './src/send.test.js' -tape('Core Command test suite.', async t => { +export const core = new CoreDaemon({ + corepath : 'test/bin/bitcoind', + clipath : 'test/bin/bitcoin-cli', + confpath : 'test/bitcoin.conf', + datapath : 'test/data', + debug : true, + isolated : true, + network : 'regtest' +}) - const core = new CoreDaemon({ - corepath : 'test/bin/bitcoind', - clipath : 'test/bin/bitcoin-cli', - confpath : 'test/bitcoin.conf', - datapath : 'test/data', - debug : true, - isolated : true, - network : 'regtest' - }) +core.tasks.push(async (client) => { + console.log('startup task:') + console.log(await client.chain_info) +}) + +tape('Core Command test suite.', async t => { const client = await core.startup()