Skip to content

Commit

Permalink
fix invalid owner address test
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Feb 22, 2024
1 parent dcd4d2b commit e334b37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions apps/whale-api/src/module.api/address.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Testing } from '@defichain/jellyfish-testing'
import { ForbiddenException } from '@nestjs/common'
import BigNumber from 'bignumber.js'
import { RegTestFoundationKeys } from '@defichain/jellyfish-network'
import { RpcApiError } from '@defichain/jellyfish-api-core/dist/index'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
Expand Down Expand Up @@ -1077,7 +1078,15 @@ describe('listTokens', () => {
})

it('should return empty and page undefined while listTokens with invalid address', async () => {
const tokens = await controller.listTokens('invalid', { size: 30 })
expect(tokens).toStrictEqual(expect.objectContaining({ data: [], page: undefined }))
try {
await controller.listTokens('invalid', { size: 30 })
} catch (err) {
expect(err).toBeInstanceOf(RpcApiError)
expect(err.payload).toStrictEqual({
code: -5,
message: 'Invalid owner address',
method: 'getaccount'
})
}
})
})
13 changes: 11 additions & 2 deletions apps/whale-api/src/module.api/address.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Testing } from '@defichain/jellyfish-testing'
import BigNumber from 'bignumber.js'
import { createTestingApp, stopTestingApp } from '../e2e.module'
import { NestFastifyApplication } from '@nestjs/platform-fastify'
import { RpcApiError } from '@defichain/jellyfish-api-core/dist/index'

const container = new MasterNodeRegTestContainer()
const testing = Testing.create(container)
Expand Down Expand Up @@ -175,7 +176,15 @@ describe('listTokens', () => {
})

it('should return empty and page undefined while listTokens with invalid address', async () => {
const tokens = await controller.listTokens('invalid', { size: 30 })
expect(tokens).toStrictEqual(expect.objectContaining({ data: [], page: undefined }))
try {
await controller.listTokens('invalid', { size: 30 })
} catch (err) {
expect(err).toBeInstanceOf(RpcApiError)
expect(err.payload).toStrictEqual({
code: -5,
message: 'Invalid owner address',
method: 'getaccount'
})
}
})
})

0 comments on commit e334b37

Please sign in to comment.