better settings, 3rd node
This commit is contained in:
parent
a95becbfb6
commit
229cfa7a95
7 changed files with 57 additions and 19 deletions
|
|
@ -44,7 +44,7 @@ export const getLogger = (params: LoggerParams): PubLogger => {
|
||||||
if (params.userId) {
|
if (params.userId) {
|
||||||
toLog.push(params.userId)
|
toLog.push(params.userId)
|
||||||
}
|
}
|
||||||
const parsed = message.map(m => typeof m === 'object' ? JSON.stringify(m) : m)
|
const parsed = message.map(m => typeof m === 'object' ? JSON.stringify(m, (_, v) => typeof v === 'bigint' ? v.toString() : v) : m)
|
||||||
const final = `${toLog.join(" ")} >> ${parsed.join(" ")}`
|
const final = `${toLog.join(" ")} >> ${parsed.join(" ")}`
|
||||||
console.log(final)
|
console.log(final)
|
||||||
writers.forEach(w => w(final))
|
writers.forEach(w => w(final))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const LoadLndSettingsFromEnv = (): LndSettings => {
|
||||||
const feeRateLimit = EnvMustBeInteger("OUTBOUND_MAX_FEE_BPS") / 10000
|
const feeRateLimit = EnvMustBeInteger("OUTBOUND_MAX_FEE_BPS") / 10000
|
||||||
const feeFixedLimit = EnvMustBeInteger("OUTBOUND_MAX_FEE_EXTRA_SATS")
|
const feeFixedLimit = EnvMustBeInteger("OUTBOUND_MAX_FEE_EXTRA_SATS")
|
||||||
const mockLnd = EnvCanBeBoolean("MOCK_LND")
|
const mockLnd = EnvCanBeBoolean("MOCK_LND")
|
||||||
return { lndAddr, lndCertPath, lndMacaroonPath, feeRateLimit, feeFixedLimit, mockLnd, otherLndAddr: "", otherLndCertPath: "", otherLndMacaroonPath: "" }
|
return { mainNode: { lndAddr, lndCertPath, lndMacaroonPath }, feeRateLimit, feeFixedLimit, mockLnd }
|
||||||
}
|
}
|
||||||
export interface LightningHandler {
|
export interface LightningHandler {
|
||||||
Stop(): void
|
Stop(): void
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export default class {
|
||||||
this.invoicePaidCb = invoicePaidCb
|
this.invoicePaidCb = invoicePaidCb
|
||||||
this.newBlockCb = newBlockCb
|
this.newBlockCb = newBlockCb
|
||||||
this.htlcCb = htlcCb
|
this.htlcCb = htlcCb
|
||||||
const { lndAddr, lndCertPath, lndMacaroonPath } = this.settings
|
const { lndAddr, lndCertPath, lndMacaroonPath } = this.settings.mainNode
|
||||||
const lndCert = fs.readFileSync(lndCertPath);
|
const lndCert = fs.readFileSync(lndCertPath);
|
||||||
const macaroon = fs.readFileSync(lndMacaroonPath).toString('hex');
|
const macaroon = fs.readFileSync(lndMacaroonPath).toString('hex');
|
||||||
const sslCreds = credentials.createSsl(lndCert);
|
const sslCreds = credentials.createSsl(lndCert);
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
import { HtlcEvent } from "../../../proto/lnd/router"
|
import { HtlcEvent } from "../../../proto/lnd/router"
|
||||||
|
export type NodeSettings = {
|
||||||
export type LndSettings = {
|
|
||||||
lndAddr: string
|
lndAddr: string
|
||||||
lndCertPath: string
|
lndCertPath: string
|
||||||
lndMacaroonPath: string
|
lndMacaroonPath: string
|
||||||
|
}
|
||||||
|
export type LndSettings = {
|
||||||
|
mainNode: NodeSettings
|
||||||
feeRateLimit: number
|
feeRateLimit: number
|
||||||
feeFixedLimit: number
|
feeFixedLimit: number
|
||||||
mockLnd: boolean
|
mockLnd: boolean
|
||||||
|
|
||||||
otherLndAddr: string
|
otherNode?: NodeSettings
|
||||||
otherLndCertPath: string
|
thirdNode?: NodeSettings
|
||||||
otherLndMacaroonPath: string
|
|
||||||
}
|
}
|
||||||
type TxOutput = {
|
type TxOutput = {
|
||||||
hash: string
|
hash: string
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { LoadStorageSettingsFromEnv, StorageSettings } from '../storage/index.js'
|
import { LoadStorageSettingsFromEnv, StorageSettings } from '../storage/index.js'
|
||||||
import { LndSettings } from '../lnd/settings.js'
|
import { LndSettings, NodeSettings } from '../lnd/settings.js'
|
||||||
import { LoadWatchdogSettingsFromEnv, WatchdogSettings } from './watchdog.js'
|
import { LoadWatchdogSettingsFromEnv, WatchdogSettings } from './watchdog.js'
|
||||||
import { LoadLndSettingsFromEnv } from '../lnd/index.js'
|
import { LoadLndSettingsFromEnv } from '../lnd/index.js'
|
||||||
import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js'
|
import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js'
|
||||||
|
|
@ -44,7 +44,7 @@ export const LoadMainSettingsFromEnv = (): MainSettings => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LoadTestSettingsFromEnv = (): MainSettings => {
|
export const LoadTestSettingsFromEnv = (): MainSettings & { lndSettings: { otherNode: NodeSettings, thirdNode: NodeSettings } } => {
|
||||||
const eventLogPath = `logs/eventLogV2Test${Date.now()}.csv`
|
const eventLogPath = `logs/eventLogV2Test${Date.now()}.csv`
|
||||||
const settings = LoadMainSettingsFromEnv()
|
const settings = LoadMainSettingsFromEnv()
|
||||||
return {
|
return {
|
||||||
|
|
@ -52,9 +52,16 @@ export const LoadTestSettingsFromEnv = (): MainSettings => {
|
||||||
storageSettings: { dbSettings: { ...settings.storageSettings.dbSettings, databaseFile: ":memory:", metricsDatabaseFile: ":memory:" }, eventLogPath },
|
storageSettings: { dbSettings: { ...settings.storageSettings.dbSettings, databaseFile: ":memory:", metricsDatabaseFile: ":memory:" }, eventLogPath },
|
||||||
lndSettings: {
|
lndSettings: {
|
||||||
...settings.lndSettings,
|
...settings.lndSettings,
|
||||||
otherLndAddr: EnvMustBeNonEmptyString("LND_OTHER_ADDR"),
|
otherNode: {
|
||||||
otherLndCertPath: EnvMustBeNonEmptyString("LND_OTHER_CERT_PATH"),
|
lndAddr: EnvMustBeNonEmptyString("LND_OTHER_ADDR"),
|
||||||
otherLndMacaroonPath: EnvMustBeNonEmptyString("LND_OTHER_MACAROON_PATH")
|
lndCertPath: EnvMustBeNonEmptyString("LND_OTHER_CERT_PATH"),
|
||||||
|
lndMacaroonPath: EnvMustBeNonEmptyString("LND_OTHER_MACAROON_PATH")
|
||||||
|
},
|
||||||
|
thirdNode: {
|
||||||
|
lndAddr: EnvMustBeNonEmptyString("LND_THIRD_ADDR"),
|
||||||
|
lndCertPath: EnvMustBeNonEmptyString("LND_THIRD_CERT_PATH"),
|
||||||
|
lndMacaroonPath: EnvMustBeNonEmptyString("LND_THIRD_MACAROON_PATH")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
skipSanityCheck: true
|
skipSanityCheck: true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export type TestBase = {
|
||||||
user2: TestUserData
|
user2: TestUserData
|
||||||
externalAccessToMainLnd: LND
|
externalAccessToMainLnd: LND
|
||||||
externalAccessToOtherLnd: LND
|
externalAccessToOtherLnd: LND
|
||||||
|
externalAccessToThirdLnd: LND
|
||||||
d: Describe
|
d: Describe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,16 +46,21 @@ export const SetupTest = async (d: Describe): Promise<TestBase> => {
|
||||||
|
|
||||||
|
|
||||||
const externalAccessToMainLnd = new LND(settings.lndSettings, console.log, console.log, () => { }, () => { })
|
const externalAccessToMainLnd = new LND(settings.lndSettings, console.log, console.log, () => { }, () => { })
|
||||||
const otherLndSetting = { ...settings.lndSettings, lndCertPath: settings.lndSettings.otherLndCertPath, lndMacaroonPath: settings.lndSettings.otherLndMacaroonPath, lndAddr: settings.lndSettings.otherLndAddr }
|
|
||||||
const externalAccessToOtherLnd = new LND(otherLndSetting, console.log, console.log, () => { }, () => { })
|
|
||||||
await externalAccessToMainLnd.Warmup()
|
await externalAccessToMainLnd.Warmup()
|
||||||
|
|
||||||
|
const otherLndSetting = { ...settings.lndSettings, mainNode: settings.lndSettings.otherNode }
|
||||||
|
const externalAccessToOtherLnd = new LND(otherLndSetting, console.log, console.log, () => { }, () => { })
|
||||||
await externalAccessToOtherLnd.Warmup()
|
await externalAccessToOtherLnd.Warmup()
|
||||||
|
|
||||||
|
const thirdLndSetting = { ...settings.lndSettings, mainNode: settings.lndSettings.thirdNode }
|
||||||
|
const externalAccessToThirdLnd = new LND(thirdLndSetting, console.log, console.log, () => { }, () => { })
|
||||||
|
await externalAccessToThirdLnd.Warmup()
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
expect, main, app,
|
expect, main, app,
|
||||||
user1, user2,
|
user1, user2,
|
||||||
externalAccessToMainLnd, externalAccessToOtherLnd,
|
externalAccessToMainLnd, externalAccessToOtherLnd, externalAccessToThirdLnd,
|
||||||
d
|
d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,36 @@ import { Describe, SetupTest, teardown, TestBase } from './testBase.js'
|
||||||
|
|
||||||
type TestModule = {
|
type TestModule = {
|
||||||
ignore?: boolean
|
ignore?: boolean
|
||||||
|
dev?: boolean
|
||||||
default: (T: TestBase) => Promise<void>
|
default: (T: TestBase) => Promise<void>
|
||||||
}
|
}
|
||||||
let failures = 0
|
let failures = 0
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
|
|
||||||
const files = await globby("**/*.spec.js")
|
const files = await globby("**/*.spec.js")
|
||||||
|
const modules: { file: string, module: TestModule }[] = []
|
||||||
|
let devModule = -1
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
console.log(file)
|
|
||||||
const module = await import(`./${file.slice("build/src/tests/".length)}`) as TestModule
|
const module = await import(`./${file.slice("build/src/tests/".length)}`) as TestModule
|
||||||
await runTestFile(file, module)
|
modules.push({ module, file })
|
||||||
|
if (module.dev) {
|
||||||
|
if (devModule !== -1) {
|
||||||
|
console.error(redConsole, "there are multiple dev modules", resetConsole)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
devModule = modules.length - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (devModule !== -1) {
|
||||||
|
console.log("running dev module")
|
||||||
|
await runTestFile(modules[devModule].file, modules[devModule].module)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("running all tests")
|
||||||
|
for (const { file, module } of modules) {
|
||||||
|
await runTestFile(file, module)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (failures) {
|
if (failures) {
|
||||||
console.error(redConsole, "there have been", `${failures}`, "failures in all tests", resetConsole)
|
console.error(redConsole, "there have been", `${failures}`, "failures in all tests", resetConsole)
|
||||||
|
|
@ -24,11 +44,15 @@ const start = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const runTestFile = async (fileName: string, mod: TestModule) => {
|
const runTestFile = async (fileName: string, mod: TestModule) => {
|
||||||
|
console.log(fileName)
|
||||||
const d = getDescribe(fileName)
|
const d = getDescribe(fileName)
|
||||||
if (mod.ignore) {
|
if (mod.ignore) {
|
||||||
d("-----ignoring file-----")
|
d("-----ignoring this file-----")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (mod.dev) {
|
||||||
|
d("-----running only this file-----")
|
||||||
|
}
|
||||||
const T = await SetupTest(d)
|
const T = await SetupTest(d)
|
||||||
try {
|
try {
|
||||||
d("test starting")
|
d("test starting")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue