up
This commit is contained in:
parent
97be3089e8
commit
98d8561963
8 changed files with 30 additions and 15 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, TestBase } from './testBase.js'
|
||||
import * as Types from '../../proto/autogenerated/ts/types.js'
|
||||
export const ignore = false
|
||||
export const dev = false
|
||||
|
|
@ -58,6 +58,8 @@ const testSuccesfulReceivedExternalChainPayment = async (T: TestBase) => {
|
|||
const payment = await T.externalAccessToOtherLnd.PayAddress(user2Address.address, 1000, 3, "test", { from: 'system', useProvider: false })
|
||||
expect(payment.txid).to.not.be.undefined
|
||||
T.d("paid 1000 sats to user2's external chain address")
|
||||
await T.chainTools.mine(2)
|
||||
T.d("mined 2 blocks to confirm the payment")
|
||||
const u2 = await T.main.storage.userStorage.GetUser(T.user2.userId)
|
||||
expect(u2.balance_sats).to.be.equal(1000)
|
||||
T.d("user2 balance is now 1000")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, TestBase } from './testBase.js'
|
||||
export const ignore = false
|
||||
|
||||
export default async (T: TestBase) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@ import { BitcoinCoreWrapper } from "./bitcoinCore.js"
|
|||
import LND from '../services/lnd/lnd.js'
|
||||
import { LiquidityProvider } from "../services/main/liquidityProvider.js"
|
||||
import { Utils } from "../services/helpers/utilsWrapper.js"
|
||||
export const setupNetwork = async () => {
|
||||
|
||||
export type ChainTools = {
|
||||
mine: (amount: number) => Promise<void>
|
||||
}
|
||||
|
||||
export const setupNetwork = async (): Promise<ChainTools> => {
|
||||
const settings = LoadTestSettingsFromEnv()
|
||||
const core = new BitcoinCoreWrapper(settings)
|
||||
await core.InitAddress()
|
||||
|
|
@ -51,6 +56,7 @@ export const setupNetwork = async () => {
|
|||
|
||||
alice.Stop()
|
||||
bob.Stop()
|
||||
return { mine: (amount: number) => core.Mine(amount) }
|
||||
}
|
||||
|
||||
const tryUntil = async <T>(fn: (attempt: number) => Promise<T>, maxTries: number, interval: number) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { disableLoggers } from '../services/helpers/logger.js'
|
||||
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, TestBase } from './testBase.js'
|
||||
export const ignore = false
|
||||
|
||||
export default async (T: TestBase) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { disableLoggers } from '../services/helpers/logger.js'
|
||||
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, TestBase } from './testBase.js'
|
||||
import * as Types from '../../proto/autogenerated/ts/types.js'
|
||||
export const ignore = false
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { LiquidityProvider } from '../services/main/liquidityProvider.js'
|
|||
import { Utils } from '../services/helpers/utilsWrapper.js'
|
||||
import { AdminManager } from '../services/main/adminManager.js'
|
||||
import { TlvStorageFactory } from '../services/storage/tlv/tlvFilesStorageFactory.js'
|
||||
import { ChainTools } from './networkSetup.js'
|
||||
chai.use(chaiString)
|
||||
export const expect = chai.expect
|
||||
export type Describe = (message: string, failure?: boolean) => void
|
||||
|
|
@ -34,6 +35,7 @@ export type TestBase = {
|
|||
externalAccessToThirdLnd: LND
|
||||
adminManager: AdminManager
|
||||
d: Describe
|
||||
chainTools: ChainTools
|
||||
}
|
||||
|
||||
export type StorageTestBase = {
|
||||
|
|
@ -58,7 +60,7 @@ export const teardownStorageTest = async (T: StorageTestBase) => {
|
|||
T.storage.Stop()
|
||||
}
|
||||
|
||||
export const SetupTest = async (d: Describe): Promise<TestBase> => {
|
||||
export const SetupTest = async (d: Describe, chainTools: ChainTools): Promise<TestBase> => {
|
||||
const settings = LoadTestSettingsFromEnv()
|
||||
const initialized = await initMainHandler(getLogger({ component: "mainForTest" }), settings)
|
||||
if (!initialized) {
|
||||
|
|
@ -89,7 +91,8 @@ export const SetupTest = async (d: Describe): Promise<TestBase> => {
|
|||
user1, user2,
|
||||
externalAccessToMainLnd, externalAccessToOtherLnd, externalAccessToThirdLnd,
|
||||
d,
|
||||
adminManager: initialized.adminManager
|
||||
adminManager: initialized.adminManager,
|
||||
chainTools
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//import whyIsNodeRunning from 'why-is-node-running'
|
||||
import { globby } from 'globby'
|
||||
import { setupNetwork } from './networkSetup.js'
|
||||
import { ChainTools, setupNetwork } from './networkSetup.js'
|
||||
import { Describe, SetupTest, teardown, TestBase, StorageTestBase, setupStorageTest, teardownStorageTest } from './testBase.js'
|
||||
type TestModule = {
|
||||
ignore?: boolean
|
||||
|
|
@ -38,17 +38,18 @@ const start = async () => {
|
|||
if (devModule !== -1) {
|
||||
console.log("running dev module")
|
||||
const { file, module } = modules[devModule]
|
||||
let chainTools: ChainTools | undefined
|
||||
if (module.requires === 'storage') {
|
||||
console.log("dev module requires only storage, skipping network setup")
|
||||
} else {
|
||||
await setupNetwork()
|
||||
chainTools = await setupNetwork()
|
||||
}
|
||||
await runTestFile(file, module)
|
||||
await runTestFile(file, module, chainTools)
|
||||
} else {
|
||||
console.log("running all tests")
|
||||
await setupNetwork()
|
||||
const chainTools = await setupNetwork()
|
||||
for (const { file, module } of modules) {
|
||||
await runTestFile(file, module)
|
||||
await runTestFile(file, module, chainTools)
|
||||
}
|
||||
}
|
||||
console.log(failures)
|
||||
|
|
@ -62,7 +63,7 @@ const start = async () => {
|
|||
|
||||
}
|
||||
|
||||
const runTestFile = async (fileName: string, mod: TestModule) => {
|
||||
const runTestFile = async (fileName: string, mod: TestModule, chainTools?: ChainTools) => {
|
||||
console.log(fileName)
|
||||
const d = getDescribe(fileName)
|
||||
if (mod.ignore) {
|
||||
|
|
@ -78,7 +79,10 @@ const runTestFile = async (fileName: string, mod: TestModule) => {
|
|||
T = await setupStorageTest(d)
|
||||
} else {
|
||||
d("-----requires all-----")
|
||||
T = await SetupTest(d)
|
||||
if (!chainTools) {
|
||||
throw new Error("chainTools are required for this test")
|
||||
}
|
||||
T = await SetupTest(d, chainTools)
|
||||
}
|
||||
try {
|
||||
d("test starting")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js'
|
||||
import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, TestBase } from './testBase.js'
|
||||
export const ignore = false
|
||||
export const dev = false
|
||||
export default async (T: TestBase) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue