Skip to content

Commit

Permalink
fix(tests): some of them
Browse files Browse the repository at this point in the history
  • Loading branch information
golobitch committed Mar 2, 2025
1 parent 6f72bf7 commit f33bb85
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 82 deletions.
10 changes: 5 additions & 5 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 32 additions & 32 deletions packages/backend/src/graphql/generated/graphql.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/backend/src/graphql/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions packages/backend/src/graphql/resolvers/wallet_address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ describe('Wallet Address Resolvers', (): void => {
const newWalletAddress = await walletAddressService.create({
assetId: (newAsset as Asset).id,
tenantId: newTenant!.id,
url: 'https://alice.me/.well-known/pay-2'
address: 'https://alice.me/.well-known/pay-2'
})
const id = (newWalletAddress as WalletAddressModel).id

Expand Down Expand Up @@ -824,7 +824,7 @@ describe('Wallet Address Resolvers', (): void => {
code: walletAddress.asset.code,
scale: walletAddress.asset.scale
},
url: walletAddress.url,
address: walletAddress.address,
publicName: publicName ?? null,
additionalProperties: [
{
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('Wallet Address Resolvers', (): void => {
publicName,
createLiquidityAccount: true
})
const args = { url: walletAddress.url }
const args = { url: walletAddress.address }
const query = await appContainer.apolloClient
.query({
query: gql`
Expand All @@ -868,7 +868,7 @@ describe('Wallet Address Resolvers', (): void => {
code
scale
}
url
address
publicName
additionalProperties {
key
Expand Down Expand Up @@ -897,7 +897,7 @@ describe('Wallet Address Resolvers', (): void => {
code: walletAddress.asset.code,
scale: walletAddress.asset.scale
},
url: walletAddress.url,
address: walletAddress.address,
publicName: publicName ?? null,
additionalProperties: []
})
Expand Down Expand Up @@ -967,7 +967,7 @@ describe('Wallet Address Resolvers', (): void => {
code
scale
}
url
address
publicName
}
cursor
Expand Down Expand Up @@ -996,7 +996,7 @@ describe('Wallet Address Resolvers', (): void => {
code: walletAddress.asset.code,
scale: walletAddress.asset.scale
},
url: walletAddress.url,
address: walletAddress.address,
publicName: walletAddress.publicName
})
})
Expand All @@ -1022,7 +1022,7 @@ describe('Wallet Address Resolvers', (): void => {
code
scale
}
url
address
publicName
}
cursor
Expand Down Expand Up @@ -1054,7 +1054,7 @@ describe('Wallet Address Resolvers', (): void => {
code: walletAddress.asset.code,
scale: walletAddress.asset.scale
},
url: walletAddress.url,
address: walletAddress.address,
publicName: walletAddress.publicName
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/graphql/resolvers/wallet_address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const createWalletAddress: MutationResolvers<ForTenantIdContext>['createW
tenantId,
additionalProperties: addProps,
publicName: args.input.publicName,
url: args.input.url
address: args.input.address
}

const walletAddressOrError = await walletAddressService.create(options)
Expand Down Expand Up @@ -206,7 +206,7 @@ export function walletAddressToGraphql(
): SchemaWalletAddress {
return {
id: walletAddress.id,
url: walletAddress.url,
address: walletAddress.address,
asset: assetToGraphql(walletAddress.asset),
publicName: walletAddress.publicName ?? undefined,
createdAt: new Date(+walletAddress.createdAt).toISOString(),
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@ type WalletAddress implements Model {
"Current amount of liquidity available for this wallet address."
liquidity: UInt64

"Wallet Address URL."
url: String!
"Wallet Address."
address: String!

"Public name associated with the wallet address. This is visible to anyone with the wallet address URL."
publicName: String
Expand Down Expand Up @@ -1298,8 +1298,8 @@ input CreateWalletAddressInput {
tenantId: ID
"Unique identifier of the asset associated with the wallet address. This cannot be changed."
assetId: String!
"Wallet address URL. This cannot be changed."
url: String!
"Wallet address. This cannot be changed."
address: String!
"Public name associated with the wallet address. This is visible to anyone with the wallet address URL."
publicName: String
"Unique key to ensure duplicate or retried requests are processed only once. For more information, refer to [idempotency](https://rafiki.dev/apis/graphql/admin-api-overview/#idempotency)."
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/open_payments/payment/incoming/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class IncomingPayment
}

public getUrl(walletAddress: WalletAddress): string {
const url = new URL(walletAddress.url)
const url = new URL(walletAddress.address)
return `${url.origin}/${walletAddress.tenantId}${IncomingPayment.urlPath}/${this.id}`
}

Expand Down Expand Up @@ -225,7 +225,7 @@ export class IncomingPayment
): OpenPaymentsIncomingPayment {
return {
id: this.getUrl(walletAddress),
walletAddress: walletAddress.url,
walletAddress: walletAddress.address,
incomingAmount: this.incomingAmount
? serializeAmount(this.incomingAmount)
: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/open_payments/quote/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Quote Routes', (): void => {
tenantId,
assetId
})
baseUrl = new URL(walletAddress.url).origin
baseUrl = new URL(walletAddress.address).origin
})

afterEach(async (): Promise<void> => {
Expand Down
19 changes: 16 additions & 3 deletions packages/backend/src/tests/walletAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { isWalletAddressError } from '../open_payments/wallet_address/errors'
import { WalletAddress } from '../open_payments/wallet_address/model'
import { CreateOptions as BaseCreateOptions } from '../open_payments/wallet_address/service'
import { LiquidityAccountType } from '../accounting/service'
import { createTenantSettings } from './tenantSettings'
import { TenantSettingKeys } from '../tenants/settings/model'

const nock = (global as unknown as { nock: typeof import('nock') }).nock

Expand All @@ -31,14 +33,25 @@ export async function createWalletAddress(
): Promise<MockWalletAddress> {
const walletAddressService = await deps.use('walletAddressService')
const tenantIdToUse = options.tenantId || (await createTenant(deps)).id

const baseWalletAddressUrl = new URL(
options.address || `https://${faker.internet.domainName()}`
)
await createTenantSettings(deps, {
tenantId: tenantIdToUse,
setting: [
{
key: TenantSettingKeys.WALLET_ADDRESS_URL.name,
value: baseWalletAddressUrl.origin
}
]
})
const walletAddressOrError = (await walletAddressService.create({
...options,
assetId:
options.assetId || (await createAsset(deps, undefined, tenantIdToUse)).id,
tenantId: tenantIdToUse,
address:
options.address ||
`https://${faker.internet.domainName()}/.well-known/pay`
address: options.address || `${baseWalletAddressUrl.origin}/.well-known/pay`
})) as MockWalletAddress
if (isWalletAddressError(walletAddressOrError)) {
throw new Error(walletAddressOrError)
Expand Down
Loading

0 comments on commit f33bb85

Please sign in to comment.