Skip to content

Commit

Permalink
test(backend): asset and peer resolver + ilp
Browse files Browse the repository at this point in the history
  • Loading branch information
golobitch committed Nov 7, 2024
1 parent 9ceb81d commit f8a4d1d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
9 changes: 6 additions & 3 deletions packages/backend/src/graphql/resolvers/asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ describe('Asset Resolvers', (): void => {
const asset = await assetService.create({
...randomAsset(),
withdrawalThreshold: BigInt(10),
liquidityThresholdLow: BigInt(100)
liquidityThresholdLow: BigInt(100),
liquidityThresholdHigh: BigInt(1000)
})
assert.ok(!isAssetError(asset))
assert.ok(asset.withdrawalThreshold)
Expand Down Expand Up @@ -293,7 +294,8 @@ describe('Asset Resolvers', (): void => {
const asset = await assetService.create({
...randomAsset(),
withdrawalThreshold: BigInt(10),
liquidityThresholdLow: BigInt(100)
liquidityThresholdLow: BigInt(100),
liquidityThresholdHigh: BigInt(1000),
})
assert.ok(!isAssetError(asset))
assert.ok(asset.withdrawalThreshold)
Expand All @@ -309,7 +311,8 @@ describe('Asset Resolvers', (): void => {
scale
liquidity
withdrawalThreshold
liquidityThreshold
liquidityThresholdLow
liquidityThresholdHigh
createdAt
}
}
Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/graphql/resolvers/peer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ describe('Peer Resolvers', (): void => {
staticIlpAddress
liquidity
name
liquidityThreshold
liquidityThresholdLow
liquidityThresholdHigh
}
}
`,
Expand Down Expand Up @@ -407,7 +408,8 @@ describe('Peer Resolvers', (): void => {
maxPacketAmount: peer.maxPacketAmount?.toString(),
liquidity: '0',
name: peer.name,
liquidityThreshold: '100'
liquidityThresholdLow: '100',
liquidityThresholdHigh: '2000'
})

await accountingService.createDeposit({
Expand Down Expand Up @@ -435,7 +437,8 @@ describe('Peer Resolvers', (): void => {
maxPacketAmount: peer.maxPacketAmount?.toString(),
liquidity: '100',
name: peer.name,
liquidityThreshold: '100'
liquidityThresholdLow: '100',
liquidityThresholdHigh: '2000'
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('Auto Peering Service', (): void => {
},
maxPacketAmount: args.maxPacketAmount,
name: peerDetails.name,
liquidityThreshold: args.liquidityThresholdLow
liquidityThresholdLow: args.liquidityThresholdLow
})

scope.done()
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/payment-method/ilp/peer/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Models', (): void => {
maxPacketAmount: BigInt(100),
staticIlpAddress: 'test.' + uuid(),
name: faker.person.fullName(),
liquidityThreshold: BigInt(100)
liquidityThresholdLow: BigInt(100),
}
const peerOrError = await peerService.create(options)
if (!isPeerError(peerOrError)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/payment-method/ilp/peer/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Peer

if (isThresholdCrossed) {
await PeerEvent.query().insert({
assetId: this.id,
peerId: this.id,
type: eventType,
data: {
id: this.id,
Expand Down
10 changes: 5 additions & 5 deletions packages/backend/src/payment-method/ilp/peer/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('Peer Service', (): void => {

describe('Create/Get Peer', (): void => {
test.each`
liquidityThreshold
liquidityThresholdLow
${undefined}
${BigInt(1000)}
`(
'A peer can be created and fetched, liquidityThreshold: $liquidityThreshold',
async ({ liquidityThreshold }): Promise<void> => {
'A peer can be created and fetched, liquidityThresholdLow: $liquidityThresholdLow',
async ({ liquidityThresholdLow }): Promise<void> => {
const options = {
assetId: asset.id,
http: {
Expand All @@ -81,7 +81,7 @@ describe('Peer Service', (): void => {
},
staticIlpAddress: 'test.' + uuid(),
name: faker.person.fullName(),
liquidityThreshold
liquidityThresholdLow
}
const peer = await peerService.create(options)
assert.ok(!isPeerError(peer))
Expand All @@ -92,7 +92,7 @@ describe('Peer Service', (): void => {
},
staticIlpAddress: options.staticIlpAddress,
name: options.name,
liquidityThreshold: liquidityThreshold || null
liquidityThresholdLow: liquidityThresholdLow || null
})
const retrievedPeer = await peerService.get(peer.id)
if (!retrievedPeer) throw new Error('peer not found')
Expand Down

0 comments on commit f8a4d1d

Please sign in to comment.