Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd committed Oct 1, 2023
1 parent 6e68d2a commit 27edf98
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`,
Expand Down Expand Up @@ -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[] = []) {
Expand Down
2 changes: 2 additions & 0 deletions test/src/base.test.ts
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
1 change: 1 addition & 0 deletions test/src/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { core } from '../tape.js'
25 changes: 15 additions & 10 deletions test/tape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 27edf98

Please sign in to comment.