From 8e3198f3e7dc1beecdb36535302c53eba5a39238 Mon Sep 17 00:00:00 2001 From: boufni95 Date: Wed, 26 Nov 2025 17:10:29 +0000 Subject: [PATCH] fix tests --- src/tests/externalPayment.spec.ts | 8 ++++---- src/tests/internalPayment.spec.ts | 8 ++++---- src/tests/liquidityProvider.spec.ts | 18 +++++++++--------- src/tests/spamExternalPayments.spec.ts | 7 +++---- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/tests/externalPayment.spec.ts b/src/tests/externalPayment.spec.ts index a92d0054..70f61117 100644 --- a/src/tests/externalPayment.spec.ts +++ b/src/tests/externalPayment.spec.ts @@ -24,10 +24,10 @@ const testSuccessfulExternalPayment = async (T: TestBase) => { T.d("paid 500 sats invoice from user1") const u1 = await T.main.storage.userStorage.GetUser(T.user1.userId) const owner = await T.main.storage.userStorage.GetUser(application.owner.user_id) - expect(u1.balance_sats).to.be.equal(1496) - T.d("user1 balance is now 1496 (2000 - (500 + 3 fee + 1 routing))") - expect(owner.balance_sats).to.be.equal(3) - T.d("app balance is 3 sats") + expect(u1.balance_sats).to.be.equal(1490) + T.d("user1 balance is now 1490 (2000 - (500 + 10fee))") + expect(owner.balance_sats).to.be.equal(9) + T.d("app balance is 9 sats") } diff --git a/src/tests/internalPayment.spec.ts b/src/tests/internalPayment.spec.ts index f94bb994..80b35675 100644 --- a/src/tests/internalPayment.spec.ts +++ b/src/tests/internalPayment.spec.ts @@ -23,10 +23,10 @@ const testSuccessfulInternalPayment = async (T: TestBase) => { const owner = await T.main.storage.userStorage.GetUser(application.owner.user_id) expect(u2.balance_sats).to.be.equal(1000) T.d("user2 balance is 1000") - expect(u1.balance_sats).to.be.equal(994) - T.d("user1 balance is 994 cuz he paid 6 sats fee") - expect(owner.balance_sats).to.be.equal(6) - T.d("app balance is 6 sats") + expect(u1.balance_sats).to.be.equal(990) + T.d("user1 balance is 990 cuz he paid 10 sats fee") + expect(owner.balance_sats).to.be.equal(10) + T.d("app balance is 10 sats") } const testFailedInternalPayment = async (T: TestBase) => { diff --git a/src/tests/liquidityProvider.spec.ts b/src/tests/liquidityProvider.spec.ts index 30b9f37d..fa2bb767 100644 --- a/src/tests/liquidityProvider.spec.ts +++ b/src/tests/liquidityProvider.spec.ts @@ -21,30 +21,30 @@ export default async (T: TestBase) => { const testInboundPaymentFromProvider = async (T: TestBase, bootstrapped: Main, bUser: TestUserData) => { T.d("starting testInboundPaymentFromProvider") - const invoiceRes = await bootstrapped.appUserManager.NewInvoice({ app_id: bUser.appId, user_id: bUser.userId, app_user_id: bUser.appUserIdentifier }, { amountSats: 2000, memo: "liquidityTest" }) + const invoiceRes = await bootstrapped.appUserManager.NewInvoice({ app_id: bUser.appId, user_id: bUser.userId, app_user_id: bUser.appUserIdentifier }, { amountSats: 3000, memo: "liquidityTest" }) - await T.externalAccessToOtherLnd.PayInvoice(invoiceRes.invoice, 0, 100, 2000, { from: 'system', useProvider: false }) + await T.externalAccessToOtherLnd.PayInvoice(invoiceRes.invoice, 0, 100, 3000, { from: 'system', useProvider: false }) await new Promise((resolve) => setTimeout(resolve, 200)) const userBalance = await bootstrapped.appUserManager.GetUserInfo({ app_id: bUser.appId, user_id: bUser.userId, app_user_id: bUser.appUserIdentifier }) - T.expect(userBalance.balance).to.equal(2000) - T.d("user balance is 2000") + T.expect(userBalance.balance).to.equal(3000) + T.d("user balance is 3000") const providerBalance = await bootstrapped.liquidityProvider.GetLatestBalance() - T.expect(providerBalance).to.equal(2000) - T.d("provider balance is 2000") + T.expect(providerBalance).to.equal(3000) + T.d("provider balance is 3000") T.d("testInboundPaymentFromProvider done") } const testOutboundPaymentFromProvider = async (T: TestBase, bootstrapped: Main, bootstrappedUser: TestUserData) => { T.d("starting testOutboundPaymentFromProvider") - const invoice = await T.externalAccessToOtherLnd.NewInvoice(1000, "", 60 * 60, { from: 'system', useProvider: false }) + const invoice = await T.externalAccessToOtherLnd.NewInvoice(2000, "", 60 * 60, { from: 'system', useProvider: false }) const ctx = { app_id: bootstrappedUser.appId, user_id: bootstrappedUser.userId, app_user_id: bootstrappedUser.appUserIdentifier } const res = await bootstrapped.appUserManager.PayInvoice(ctx, { invoice: invoice.payRequest, amount: 0 }) const userBalance = await bootstrapped.appUserManager.GetUserInfo(ctx) - T.expect(userBalance.balance).to.equal(986) // 2000 - (1000 + 6(x2) + 2) + T.expect(userBalance.balance).to.equal(988) // 3000 - (2000 + 12) const providerBalance = await bootstrapped.liquidityProvider.GetLatestBalance() - T.expect(providerBalance).to.equal(992) // 2000 - (1000 + 6 +2) + T.expect(providerBalance).to.equal(998) // 3000 - (2000 + 12) T.d("testOutboundPaymentFromProvider done") } \ No newline at end of file diff --git a/src/tests/spamExternalPayments.spec.ts b/src/tests/spamExternalPayments.spec.ts index e7956632..df4d018f 100644 --- a/src/tests/spamExternalPayments.spec.ts +++ b/src/tests/spamExternalPayments.spec.ts @@ -29,16 +29,15 @@ const testSpamExternalPayment = async (T: TestBase) => { const failedPayments = res.filter(r => !r.success) console.log(failedPayments) failedPayments.forEach(f => expect(f.err).to.be.equal("not enough balance to decrement")) - successfulPayments.forEach(s => expect(s.result).to.contain({ amount_paid: 500, network_fee: 1, service_fee: 3 })) + successfulPayments.forEach(s => expect(s.result).to.contain({ amount_paid: 500, network_fee: 1, service_fee: 10 })) expect(successfulPayments.length).to.be.equal(3) expect(failedPayments.length).to.be.equal(7) T.d("3 payments succeeded, 7 failed as expected") const u = await T.main.storage.userStorage.GetUser(T.user1.userId) const owner = await T.main.storage.userStorage.GetUser(application.owner.user_id) - expect(u.balance_sats).to.be.equal(488) - T.d("user1 balance is now 488 (2000 - (500 + 3 fee + 1 routing) * 3)") + expect(u.balance_sats).to.be.equal(470) + T.d("user1 balance is now 470 (2000 - (500 + 10 fee) * 3)") expect(owner.balance_sats).to.be.equal(9) T.d("app balance is 9 sats") - }