up
This commit is contained in:
parent
2b99225d29
commit
4ac236d56e
2 changed files with 29 additions and 6 deletions
27
src/tests/prepareNetwork.ts
Normal file
27
src/tests/prepareNetwork.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { LoadTestSettingsFromEnv } from "../services/main/settings.js"
|
||||||
|
import { BitcoinCoreWrapper } from "./bitcoinCore.js"
|
||||||
|
import LND from '../services/lnd/lnd.js'
|
||||||
|
export const prepareNetwork = async () => {
|
||||||
|
|
||||||
|
const settings = LoadTestSettingsFromEnv()
|
||||||
|
const core = new BitcoinCoreWrapper(settings)
|
||||||
|
await core.InitAddress()
|
||||||
|
await core.Mine(1)
|
||||||
|
const lnd = new LND(settings.lndSettings, () => { }, () => { }, () => { }, () => { })
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
try {
|
||||||
|
const info = await lnd.GetInfo()
|
||||||
|
if (!info.syncedToChain) {
|
||||||
|
throw new Error("not synced to chain")
|
||||||
|
}
|
||||||
|
if (!info.syncedToGraph) {
|
||||||
|
throw new Error("not synced to graph")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} catch (e) {
|
||||||
|
console.log("waiting for lnd to be ready")
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("lnd is not ready after 10 seconds")
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { globby } from 'globby'
|
import { globby } from 'globby'
|
||||||
import { LoadTestSettingsFromEnv } from '../services/main/settings.js'
|
|
||||||
import { BitcoinCoreWrapper } from './bitcoinCore.js'
|
|
||||||
import { setupNetwork } from './networkSetup.js'
|
import { setupNetwork } from './networkSetup.js'
|
||||||
|
import { prepareNetwork } from './prepareNetwork.js'
|
||||||
import { Describe, SetupTest, teardown, TestBase } from './testBase.js'
|
import { Describe, SetupTest, teardown, TestBase } from './testBase.js'
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,10 +24,7 @@ const start = async () => {
|
||||||
if (process.argv[2] === 'setup_network') {
|
if (process.argv[2] === 'setup_network') {
|
||||||
await setupNetwork()
|
await setupNetwork()
|
||||||
} else {
|
} else {
|
||||||
const core = new BitcoinCoreWrapper(LoadTestSettingsFromEnv())
|
await prepareNetwork()
|
||||||
await core.InitAddress()
|
|
||||||
await core.Mine(1)
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
||||||
}
|
}
|
||||||
const files = await globby(["**/*.spec.js", "!**/node_modules/**"])
|
const files = await globby(["**/*.spec.js", "!**/node_modules/**"])
|
||||||
const modules: { file: string, module: TestModule }[] = []
|
const modules: { file: string, module: TestModule }[] = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue