Skip to content

Commit

Permalink
update e2e to compact defid
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Dec 14, 2023
1 parent d7222a6 commit fee0f70
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 25 deletions.
1 change: 1 addition & 0 deletions apps/whale-api/src/e2e.defid.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export class DefidBin {
readonly oracleController: DOracleController,
readonly poolPairController: DPoolPairController,
readonly priceController: DPriceController,
readonly rawTxController: DRawTxController,
readonly statsController: DStatsController,
readonly transactionController: DTransactionController,
readonly tokenController: DTokenController
Expand Down
4 changes: 3 additions & 1 deletion apps/whale-api/src/e2e.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
DPriceController,
DStatsController,
DTransactionController,
DTokenController
DTokenController,
DRawTxController
} from './e2e.defid.module'

/**
Expand All @@ -48,6 +49,7 @@ export async function createTestingApp (container: MasterNodeRegTestContainer):
new DOracleController(),
new DPoolPairController(),
new DPriceController(),
new DRawTxController(),
new DStatsController(),
new DTransactionController(),
new DTokenController()
Expand Down
41 changes: 29 additions & 12 deletions apps/whale-api/src/module.api/masternode.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ import { MasternodeController } from './masternode.controller'
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
import { MasternodeState } from '@defichain/whale-api-client/dist/api/masternodes'
import { MasternodeTimeLock } from '@defichain/jellyfish-api-core/dist/category/masternode'
import { DefidBin, DMasternodeController } from '../e2e.defid.module'

describe('list', () => {
const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: MasternodeController
let app: NestFastifyApplication | DefidBin
let controller: MasternodeController | DMasternodeController
let client: JsonRpcClient

beforeAll(async () => {
await container.start()

app = await createTestingApp(container)
client = new JsonRpcClient(await container.getCachedRpcUrl())
controller = app.get(MasternodeController)
if (app instanceof DefidBin) {
controller = app.masternodeController
} else {
controller = app.get(MasternodeController)
}

await container.generate(1)
const height = await client.blockchain.getBlockCount()
Expand Down Expand Up @@ -58,16 +63,20 @@ describe('list', () => {

describe('get', () => {
const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: MasternodeController
let app: NestFastifyApplication | DefidBin
let controller: MasternodeController | DMasternodeController
let client: JsonRpcClient

beforeAll(async () => {
await container.start()

app = await createTestingApp(container)
client = new JsonRpcClient(await container.getCachedRpcUrl())
controller = app.get(MasternodeController)
if (app instanceof DefidBin) {
controller = app.masternodeController
} else {
controller = app.get(MasternodeController)
}

await container.generate(1)
const height = await client.blockchain.getBlockCount()
Expand Down Expand Up @@ -105,8 +114,8 @@ describe('get', () => {

describe('resign', () => {
const container = new DelayedEunosPayaTestContainer()
let app: NestFastifyApplication
let controller: MasternodeController
let app: NestFastifyApplication | DefidBin
let controller: MasternodeController | DMasternodeController
let client: JsonRpcClient

beforeAll(async () => {
Expand All @@ -115,7 +124,11 @@ describe('resign', () => {

app = await createTestingApp(container)
client = new JsonRpcClient(await container.getCachedRpcUrl())
controller = app.get(MasternodeController)
if (app instanceof DefidBin) {
controller = app.masternodeController
} else {
controller = app.get(MasternodeController)
}

await container.generate(1)
const height = await client.blockchain.getBlockCount()
Expand Down Expand Up @@ -154,8 +167,8 @@ describe('resign', () => {

describe('timelock', () => {
const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: MasternodeController
let app: NestFastifyApplication | DefidBin
let controller: MasternodeController | DMasternodeController
let client: JsonRpcClient

beforeAll(async () => {
Expand All @@ -164,7 +177,11 @@ describe('timelock', () => {

app = await createTestingApp(container)
client = new JsonRpcClient(await container.getCachedRpcUrl())
controller = app.get(MasternodeController)
if (app instanceof DefidBin) {
controller = app.masternodeController
} else {
controller = app.get(MasternodeController)
}

await container.generate(1)
const height = await client.blockchain.getBlockCount()
Expand Down
11 changes: 8 additions & 3 deletions apps/whale-api/src/module.api/poolpair.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { DeFiDCache } from './cache/defid.cache'
import { CachePrefix } from '@defichain-apps/libs/caches'
import { Cache } from 'cache-manager'
import { TokenInfo } from '@defichain/jellyfish-api-core/dist/category/token'
import { DefidBin, DPoolPairController } from '../e2e.defid.module'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: PoolPairController
let app: NestFastifyApplication | DefidBin
let controller: PoolPairController | DPoolPairController

beforeAll(async () => {
await container.start()
Expand All @@ -21,7 +22,11 @@ beforeAll(async () => {
await setup()

app = await createTestingApp(container)
controller = app.get(PoolPairController)
if (app instanceof DefidBin) {
controller = app.poolPairController
} else {
controller = app.get(PoolPairController)
}
const cache = app.get<Cache>(CACHE_MANAGER)
const defiCache = app.get(DeFiDCache)

Expand Down
11 changes: 8 additions & 3 deletions apps/whale-api/src/module.api/rawtx.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ import { NestFastifyApplication } from '@nestjs/platform-fastify'
import { createTestingApp, stopTestingApp } from '../e2e.module'
import { RawtxController } from './rawtx.controller'
import { NotFoundException } from '@nestjs/common'
import { DRawTxController, DefidBin } from '../e2e.defid.module'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: RawtxController
let app: NestFastifyApplication | DefidBin
let controller: RawtxController | DRawTxController

beforeAll(async () => {
await container.start()
await container.waitForWalletCoinbaseMaturity()
await container.waitForWalletBalanceGTE(100)

app = await createTestingApp(container)
controller = app.get<RawtxController>(RawtxController)
if (app instanceof DefidBin) {
controller = app.rawTxController
} else {
controller = app.get<RawtxController>(RawtxController)
}
})

afterAll(async () => {
Expand Down
11 changes: 8 additions & 3 deletions apps/whale-api/src/module.api/token.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ import { NestFastifyApplication } from '@nestjs/platform-fastify'
import { createTestingApp, stopTestingApp, waitForIndexedHeight } from '../e2e.module'
import { createPoolPair, createToken } from '@defichain/testing'
import { NotFoundException } from '@nestjs/common'
import { DTokenController, DefidBin } from '../e2e.defid.module'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: TokenController
let app: NestFastifyApplication | DefidBin
let controller: TokenController | DTokenController

beforeAll(async () => {
await container.start()
await container.waitForWalletCoinbaseMaturity()
await container.waitForWalletBalanceGTE(100)

app = await createTestingApp(container)
controller = app.get(TokenController)
if (app instanceof DefidBin) {
controller = app.tokenController
} else {
controller = app.get(TokenController)
}

await waitForIndexedHeight(app, 100)

Expand Down
11 changes: 8 additions & 3 deletions apps/whale-api/src/module.api/transaction.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { TransactionController } from './transaction.controller'
import { NestFastifyApplication } from '@nestjs/platform-fastify'
import { createTestingApp, stopTestingApp, waitForIndexedHeight } from '../e2e.module'
import { NotFoundException } from '@nestjs/common'
import { DTransactionController, DefidBin } from '../e2e.defid.module'

const container = new MasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: TransactionController
let app: NestFastifyApplication | DefidBin
let controller: TransactionController | DTransactionController
let client: JsonRpcClient

beforeAll(async () => {
Expand All @@ -16,7 +17,11 @@ beforeAll(async () => {
await container.waitForWalletBalanceGTE(100)

app = await createTestingApp(container)
controller = app.get<TransactionController>(TransactionController)
if (app instanceof DefidBin) {
controller = app.transactionController
} else {
controller = app.get<TransactionController>(TransactionController)
}
client = new JsonRpcClient(await container.getCachedRpcUrl())

await waitForIndexedHeight(app, 100)
Expand Down

0 comments on commit fee0f70

Please sign in to comment.