This commit is contained in:
hatim boufnichel 2024-04-25 19:35:02 +02:00
parent 2b99225d29
commit 4ac236d56e
2 changed files with 29 additions and 6 deletions

View 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")
}

View file

@ -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 }[] = []