Skip to content

Commit

Permalink
fix(backend): resolve breaking build after main rebase (#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie authored Oct 23, 2023
1 parent 572dd09 commit b9ca3e6
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('Payment', (): void => {

const outgoingPayment = await createOutgoingPayment(deps, {
walletAddressId: outWalletAddressId,
method: 'ilp',
receiver: `${Config.publicHost}/${uuid()}`,
debitAmount: {
value: BigInt(56),
Expand Down Expand Up @@ -151,6 +152,7 @@ describe('Payment', (): void => {

const outgoingPayment = await createOutgoingPayment(deps, {
walletAddressId: outWalletAddressId,
method: 'ilp',
...baseOutgoingPayment
})

Expand All @@ -159,6 +161,7 @@ describe('Payment', (): void => {
})
await createOutgoingPayment(deps, {
walletAddressId: outWalletAddressId2,
method: 'ilp',
...baseOutgoingPayment
})

Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/graphql/resolvers/liquidity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@ describe('Liquidity Resolvers', (): void => {
})
payment = await createOutgoingPayment(deps, {
walletAddressId,
method: 'ilp',
receiver: `${Config.publicHost}/${uuid()}/incoming-payments/${uuid()}`,
debitAmount: {
value: BigInt(456),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('OutgoingPayment Resolvers', (): void => {
}): Promise<OutgoingPaymentModel> => {
return await createOutgoingPayment(deps, {
...options,
method: 'ilp',
receiver: `${Config.publicHost}/${uuid()}`,
debitAmount: {
value: BigInt(56),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export function initIocContainer(
'paymentMethodHandlerService'
),
peerService: await deps.use('peerService'),
paymentPointerService: await deps.use('paymentPointerService')
walletAddressService: await deps.use('walletAddressService')
})
})
container.singleton('outgoingPaymentRoutes', async (deps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('Combined Payment Service', (): void => {

const outgoingPayment = await createOutgoingPayment(deps, {
walletAddressId: sendWalletAddressId,
method: 'ilp',
receiver: receiverUrl,
debitAmount: {
value: BigInt(123),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('Outgoing Payment Routes', (): void => {
return await createOutgoingPayment(deps, {
...options,
walletAddressId: walletAddress.id,
method: 'ilp',
receiver: `${receivingWalletAddress}/incoming-payments/${uuid()}`,
debitAmount: {
value: BigInt(56),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import {
WalletAddressService,
WalletAddressSubresourceService
} from '../../wallet_address/service'
import {
IlpPlugin,
IlpPluginOptions
} from '../../../payment-method/ilp/ilp_plugin'
import { sendWebhookEvent } from './lifecycle'
import * as worker from './worker'
import { Interval } from 'luxon'
Expand All @@ -56,7 +52,7 @@ export interface ServiceDependencies extends BaseService {
accountingService: AccountingService
receiverService: ReceiverService
peerService: PeerService
makeIlpPlugin: (options: IlpPluginOptions) => IlpPlugin
paymentMethodHandlerService: PaymentMethodHandlerService
walletAddressService: WalletAddressService
}

Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/payment-method/handler/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ describe('PaymentMethodHandlerService', (): void => {
describe('pay', (): void => {
test('calls ilpPaymentService for ILP payment type', async (): Promise<void> => {
const asset = await createAsset(deps)
const paymentPointer = await createPaymentPointer(deps, {
const walletAddress = await createWalletAddress(deps, {
assetId: asset.id
})
const { receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingPaymentPointer: paymentPointer,
receivingPaymentPointer: paymentPointer,
sendingWalletAddress: walletAddress,
receivingWalletAddress: walletAddress,
method: 'ilp',
quoteOptions: {
debitAmount: {
assetCode: paymentPointer.asset.code,
assetScale: paymentPointer.asset.scale,
assetCode: walletAddress.asset.code,
assetScale: walletAddress.asset.scale,
value: 100n
}
}
Expand Down
29 changes: 18 additions & 11 deletions packages/backend/src/payment-method/ilp/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@ describe('IlpPaymentService', (): void => {
[incomingAssetCode]: exchangeRate
}))

const receivingPaymentPointer =
const receivingWalletAddress =
walletAddressMap[incomingAssetCode]
const sendingWalletAddress = walletAddressMap[debitAssetCode]

const options: StartQuoteOptions = {
walletAddress: sendingWalletAddress,
receiver: await createReceiver(deps, receivingPaymentPointer),
receiver: await createReceiver(deps, receivingWalletAddress),
debitAmount: {
assetCode: sendingWalletAddress.asset.code,
assetScale: sendingWalletAddress.asset.scale,
Expand All @@ -391,8 +391,8 @@ describe('IlpPaymentService', (): void => {
value: debitAmountValue
},
receiveAmount: {
assetCode: receivingPaymentPointer.asset.code,
assetScale: receivingPaymentPointer.asset.scale,
assetCode: receivingWalletAddress.asset.code,
assetScale: receivingWalletAddress.asset.scale,
value: expectedReceiveAmount
}
})
Expand Down Expand Up @@ -447,7 +447,8 @@ describe('IlpPaymentService', (): void => {
const { incomingPayment, receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down Expand Up @@ -476,7 +477,8 @@ describe('IlpPaymentService', (): void => {
const { incomingPayment, receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
exchangeRate: 1,
debitAmount: {
Expand Down Expand Up @@ -525,7 +527,8 @@ describe('IlpPaymentService', (): void => {
const { incomingPayment, receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down Expand Up @@ -563,7 +566,8 @@ describe('IlpPaymentService', (): void => {
const { incomingPayment, receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down Expand Up @@ -601,7 +605,8 @@ describe('IlpPaymentService', (): void => {
const { receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down Expand Up @@ -636,7 +641,8 @@ describe('IlpPaymentService', (): void => {
const { receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down Expand Up @@ -675,7 +681,8 @@ describe('IlpPaymentService', (): void => {
const { receiver, outgoingPayment } =
await createOutgoingPaymentWithReceiver(deps, {
sendingWalletAddress: walletAddressMap['USD'],
receivingPaymentPointer: walletAddressMap['USD'],
receivingWalletAddress: walletAddressMap['USD'],
method: 'ilp',
quoteOptions: {
debitAmount: {
value: 100n,
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/shared/pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('Pagination', (): void => {
const payment = await createOutgoingPayment(deps, {
walletAddressId: defaultWalletAddress.id,
receiver: secondaryWalletAddress.url,
method: 'ilp',
debitAmount,
validDestination: false
})
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/tests/combinedPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function createCombinedPayment(
})
: await createOutgoingPayment(deps, {
walletAddressId: sendWalletAddressId,
method: 'ilp',
receiver: `${Config.publicHost}/${uuid()}`,
validDestination: false
})
Expand Down
14 changes: 9 additions & 5 deletions packages/backend/src/tests/outgoingPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import assert from 'assert'

type CreateTestQuoteAndOutgoingPaymentOptions = Omit<
CreateOutgoingPaymentOptions & CreateTestQuoteOptions,
'quoteId' | 'method'
'quoteId'
>

export async function createOutgoingPayment(
Expand All @@ -29,7 +29,7 @@ export async function createOutgoingPayment(
receiver: options.receiver,
validDestination: options.validDestination,
exchangeRate: options.exchangeRate,
method: 'ilp'
method: options.method
}
if (options.debitAmount) quoteOptions.debitAmount = options.debitAmount
if (options.receiveAmount) quoteOptions.receiveAmount = options.receiveAmount
Expand Down Expand Up @@ -78,6 +78,7 @@ export async function createOutgoingPayment(

interface CreateOutgoingPaymentWithReceiverArgs {
receivingWalletAddress: WalletAddress
method: 'ilp',
incomingPaymentOptions?: Partial<CreateIncomingPaymentOptions>
quoteOptions?: Partial<
Pick<
Expand Down Expand Up @@ -115,16 +116,19 @@ export async function createOutgoingPaymentWithReceiver(
walletAddressId: args.receivingWalletAddress.id
})

const connectionService = await deps.use('connectionService')
const streamServer = await deps.use('streamServer')
const streamCredentials = streamServer.generateCredentials()

const receiver = new Receiver(
incomingPayment.toOpenPaymentsType(
incomingPayment.toOpenPaymentsTypeWithMethods(
args.receivingWalletAddress,
connectionService.get(incomingPayment)!
streamCredentials
)
)

const outgoingPayment = await createOutgoingPayment(deps, {
walletAddressId: args.sendingWalletAddress.id,
method: args.method,
receiver: receiver.incomingPayment!.id!,
...args.quoteOptions
})
Expand Down

0 comments on commit b9ca3e6

Please sign in to comment.