Skip to content

Commit

Permalink
feat(3114): fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
koekiebox committed Dec 11, 2024
1 parent b5a1667 commit f29862a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ describe('Incoming Payment Service', (): void => {

beforeEach(async (): Promise<void> => {
asset = await createAsset(deps)
const address = await createWalletAddress(deps, { assetId: asset.id })
const address = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: asset.id
})
walletAddressId = address.id
client = address.url
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@ describe('OutgoingPaymentService', (): void => {
const { id: sendAssetId } = await createAsset(deps, asset)
assetId = sendAssetId
const walletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: sendAssetId
})
walletAddressId = walletAddress.id
client = walletAddress.url
const { id: destinationAssetId } = await createAsset(deps, destinationAsset)
receiverWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: destinationAssetId,
mockServerPort: appContainer.openPaymentsPort
})
Expand Down Expand Up @@ -408,8 +410,12 @@ describe('OutgoingPaymentService', (): void => {
let outgoingPayment: OutgoingPayment
let otherOutgoingPayment: OutgoingPayment
beforeEach(async (): Promise<void> => {
otherSenderWalletAddress = await createWalletAddress(deps, { assetId })
otherSenderWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId
})
otherReceiverWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId
})
const incomingPayment = await createIncomingPayment(deps, {
Expand Down Expand Up @@ -974,7 +980,9 @@ describe('OutgoingPaymentService', (): void => {
validDestination: false,
method: 'ilp'
})
const walletAddress = await createWalletAddress(deps)
const walletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId
})
const walletAddressUpdated = await WalletAddress.query(
knex
).patchAndFetchById(walletAddress.id, { deactivatedAt: new Date() })
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/open_payments/quote/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ describe('QuoteService', (): void => {
scale: debitAmount.assetScale
})
sendingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: sendAssetId
})
const { id: destinationAssetId } = await createAsset(deps, destinationAsset)
receivingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: destinationAssetId,
mockServerPort: appContainer.openPaymentsPort
})
Expand Down Expand Up @@ -525,9 +527,11 @@ describe('QuoteService', (): void => {
scale: 2
})
sendingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: asset.id
})
receivingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: asset.id
})
})
Expand Down Expand Up @@ -633,9 +637,11 @@ describe('QuoteService', (): void => {
scale: 2
})
sendingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: sendAsset.id
})
receivingWalletAddress = await createWalletAddress(deps, {
tenantId: config.operatorTenantId,
assetId: receiveAsset.id
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('Wallet Address Routes', (): void => {
assetScale: walletAddress.asset.scale,
// Ensure the tenant id is returned for auth and resource server:
authServer: `${config.authServerGrantUrl}/${config.operatorTenantId}`,
resourceServer: `${config.openPaymentsUrl}/${config.operatorTenantId}`,
resourceServer: `${config.openPaymentsUrl}/${config.operatorTenantId}`
})
})
})
Expand Down
6 changes: 1 addition & 5 deletions packages/backend/src/open_payments/wallet_address/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../../shared/pagination'
import { OpenPaymentsServerRouteError } from '../route-errors'
import { IAppConfig } from '../../config/app'
import { ensureTrailingSlash } from '../../shared/utils'

interface ServiceDependencies {
config: IAppConfig
Expand Down Expand Up @@ -65,11 +66,6 @@ export async function getWalletAddress(
})
}

function ensureTrailingSlash(str: string): string {
if (!str.endsWith('/')) return `${str}/`
return str
}

interface ListSubresourceOptions<M extends WalletAddressSubresource> {
ctx: ListContext
getWalletAddressPage: WalletAddressSubresourceService<M>['getWalletAddressPage']
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,8 @@ export async function verifyApiSignature(

return verifyApiSignatureDigest(signature as string, ctx.request, config)
}

export function ensureTrailingSlash(str: string): string {
if (!str.endsWith('/')) return `${str}/`
return str
}
1 change: 1 addition & 0 deletions packages/backend/src/tests/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export async function createQuote(
const withGraphFetchedArray = [
'asset',
'walletAddress',
'walletAddress.tenant',
'walletAddress.asset'
]
if (withFee) {
Expand Down

0 comments on commit f29862a

Please sign in to comment.