Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
boufni95 committed Apr 25, 2024
1 parent 755f353 commit 7411e1c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
27 changes: 27 additions & 0 deletions src/tests/prepareNetwork.ts
Original file line number Diff line number Diff line change
@@ -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")
}
8 changes: 2 additions & 6 deletions src/tests/testRunner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { globby } from 'globby'
import { LoadTestSettingsFromEnv } from '../services/main/settings.js'
import { BitcoinCoreWrapper } from './bitcoinCore.js'
import { setupNetwork } from './networkSetup.js'
import { prepareNetwork } from './prepareNetwork.js'
import { Describe, SetupTest, teardown, TestBase } from './testBase.js'


Expand All @@ -25,10 +24,7 @@ const start = async () => {
if (process.argv[2] === 'setup_network') {
await setupNetwork()
} else {
const core = new BitcoinCoreWrapper(LoadTestSettingsFromEnv())
await core.InitAddress()
await core.Mine(1)
await new Promise((resolve) => setTimeout(resolve, 1000))
await prepareNetwork()
}
const files = await globby(["**/*.spec.js", "!**/node_modules/**"])
const modules: { file: string, module: TestModule }[] = []
Expand Down

0 comments on commit 7411e1c

Please sign in to comment.