diff --git a/src/tests/externalPayment.spec.ts b/src/tests/externalPayment.spec.ts index f5524ed1..f3cfef52 100644 --- a/src/tests/externalPayment.spec.ts +++ b/src/tests/externalPayment.spec.ts @@ -1,11 +1,13 @@ import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js' import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalance, SetupTest, TestBase } from './testBase.js' +import * as Types from '../../proto/autogenerated/ts/types.js' export const ignore = false export const dev = false export default async (T: TestBase) => { await safelySetUserBalance(T, T.user1, 2000) await testSuccessfulExternalPayment(T) await testFailedExternalPayment(T) + await testSuccesfulReceivedExternalChainPayment(T) await runSanityCheck(T) } @@ -44,4 +46,24 @@ const testFailedExternalPayment = async (T: TestBase) => { const owner = await T.main.storage.userStorage.GetUser(application.owner.user_id) expect(owner.balance_sats).to.be.equal(3) T.d("app balance is still 3 sats") -} \ No newline at end of file +} + +const testSuccesfulReceivedExternalChainPayment = async (T: TestBase) => { + T.d("starting testSuccesfulReceivedExternalChainPayment") + const balanceBefore = await T.main.storage.userStorage.GetUser(T.user1.userId) + expect(balanceBefore.balance_sats).to.be.equal(0) + const user2Address = await T.main.paymentManager.NewAddress({ app_id: T.app.appId, app_user_id: T.user2.appUserIdentifier, user_id: T.user2.userId }, { addressType: Types.AddressType.WITNESS_PUBKEY_HASH }) + expect(user2Address.address).to.startWith("bc1") + T.d("generated external chain address for user2") + 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") + 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") + + + + + +}