Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): support whale test suite for defid ocean #2174

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b475a6b
wip
canonbrother Nov 30, 2023
41ac0c3
waitForIndexedHeight
canonbrother Dec 11, 2023
8115a1e
stub ctrls into DefidBin
canonbrother Dec 11, 2023
411fe85
unhide block.e2e
canonbrother Dec 13, 2023
99616ca
fix addr.ctrl func mapping
canonbrother Dec 13, 2023
11ba5ab
fix addr.ctrl func mapping
canonbrother Dec 13, 2023
a9859bd
return json
canonbrother Dec 13, 2023
1c59500
temp fix waitForAddressTxCount
canonbrother Dec 13, 2023
f1485f0
unhide address.e2e & update ctrl return mapping
canonbrother Dec 13, 2023
b5d08d9
map return type from addr -> rawtx
canonbrother Dec 13, 2023
29f861d
todo
canonbrother Dec 13, 2023
79d7d91
overload createTestingApp
canonbrother Dec 14, 2023
c009c3d
map return type from stats -> tx
canonbrother Dec 14, 2023
038474a
update stats e2e
canonbrother Dec 14, 2023
6199d96
typo
canonbrother Dec 14, 2023
b05021d
update fee e2e
canonbrother Dec 14, 2023
d7222a6
add governance defidbin api & update governance e2e
canonbrother Dec 14, 2023
fee0f70
update e2e to compact defid
canonbrother Dec 14, 2023
f6f1aa5
oceanarchive
canonbrother Jan 2, 2024
ae4febe
fix OceanProposalQuery
canonbrother Jan 2, 2024
277cc11
fix rawtx get
canonbrother Jan 3, 2024
7c17c0a
wait for ocean
canonbrother Jan 3, 2024
e593410
fix listProposalVotes
canonbrother Jan 3, 2024
e17804e
refine defid module from 2 objects ocean & blockchain -> 1 object (oc…
canonbrother Jan 25, 2024
b022c8e
add defid mod utils
canonbrother Jan 25, 2024
c7148fb
add defid utils
canonbrother Jan 25, 2024
601b8ba
refine token e2e
canonbrother Jan 25, 2024
dfcd165
fix block ctrl
canonbrother Jan 25, 2024
1819b10
add api blocks/highest
canonbrother Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add api blocks/highest
canonbrother committed Jan 25, 2024
commit 1819b10279206cc4e0f839c09cf47b6a850af5a3
4 changes: 4 additions & 0 deletions apps/whale-api/src/e2e.defid.module.ts
Original file line number Diff line number Diff line change
@@ -59,121 +59,125 @@
query?: OceanListQuery
}

class DefidOceanApi {
endpoint = 'http://127.0.0.1:3002'

Check warning on line 63 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L62-L63

Added lines #L62 - L63 were not covered by tests

async get (path: string): Promise<any> {
const res = await fetch(`${this.endpoint}${path}`, {

Check warning on line 66 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L65-L66

Added lines #L65 - L66 were not covered by tests
method: 'GET'
})
return await res.json()

Check warning on line 69 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L69

Added line #L69 was not covered by tests
}

async post (path: string, data?: any): Promise<any> {
const res = await fetch(`${this.endpoint}${path}`, {

Check warning on line 73 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L72-L73

Added lines #L72 - L73 were not covered by tests
method: 'POST',
body: JSON.stringify(data)
})
return await res.json()

Check warning on line 77 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L77

Added line #L77 was not covered by tests
}
}

export class DefidOceanController {
protected readonly api: DefidOceanApi = new DefidOceanApi()

Check warning on line 82 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L82

Added line #L82 was not covered by tests
}

export class DAddressController extends DefidOceanController {
async getAccountHistory (address: string, height: number, txno: number): Promise<AddressHistory> {
return await this.api.get(`/address/${address}/history/${height}/${txno}`)

Check warning on line 87 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L86-L87

Added lines #L86 - L87 were not covered by tests
}

async listAccountHistory (address: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<AddressHistory>> {
if (query.next !== undefined) {
return await this.api.get(`/address/${address}/history?size=${query.size}&next=${query.next}`)

Check warning on line 92 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L92

Added line #L92 was not covered by tests
}
return await this.api.get(`/address/${address}/history?size=${query.size}`)

Check warning on line 94 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L94

Added line #L94 was not covered by tests
}

async getBalance (address: string): Promise<string> {
return await this.api.get(`/address/${address}/balance`)

Check warning on line 98 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L97-L98

Added lines #L97 - L98 were not covered by tests
}

async getAggregation (address: string): Promise<ScriptAggregation | undefined> {
return await this.api.get(`/address/${address}/aggregation`)

Check warning on line 102 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L101-L102

Added lines #L101 - L102 were not covered by tests
}

async listTokens (address: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<AddressToken>> {
if (query.next !== undefined) {
return await this.api.get(`/address/${address}/tokens?size=${query.size}&next=${query.next}`)

Check warning on line 107 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L107

Added line #L107 was not covered by tests
}
return await this.api.get(`/address/${address}/tokens?size=${query.size}`)

Check warning on line 109 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L109

Added line #L109 was not covered by tests
}

async listVaults (address: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<LoanVaultActive | LoanVaultLiquidated>> {
if (query.next !== undefined) {
return await this.api.get(`/address/${address}/vaults?size=${query.size}&next=${query.next}`)

Check warning on line 114 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L114

Added line #L114 was not covered by tests
}
return await this.api.get(`/address/${address}/vaults?size=${query.size}`)

Check warning on line 116 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L116

Added line #L116 was not covered by tests
}

async listTransactions (address: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<ScriptActivity>> {
if (query.next !== undefined) {
return await this.api.get(`/address/${address}/transactions?size=${query.size}&next=${query.next}`)

Check warning on line 121 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L121

Added line #L121 was not covered by tests
}
return await this.api.get(`/address/${address}/transactions?size=${query.size}`)

Check warning on line 123 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L123

Added line #L123 was not covered by tests
}

async listTransactionsUnspent (address: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<ScriptUnspent>> {
if (query.next !== undefined) {
return await this.api.get(`/address/${address}/transactions/unspent?size=${query.size}&next=${query.next}`)

Check warning on line 128 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L128

Added line #L128 was not covered by tests
}
return await this.api.get(`/address/${address}/transactions/unspent?size=${query.size}`)

Check warning on line 130 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L130

Added line #L130 was not covered by tests
}
}

export class DBlockController extends DefidOceanController {
async list (query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<Block>> {
if (query.next !== undefined) {
const next = parseHeight(query.next)
return await this.api.get(`/blocks?size=${query.size}&next=${next}`)

Check warning on line 138 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L137-L138

Added lines #L137 - L138 were not covered by tests
}
return await this.api.get(`/blocks?size=${query.size}`)

Check warning on line 140 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L140

Added line #L140 was not covered by tests
}

async get (hashOrHeight: string): Promise<Block | undefined> {
const height = parseHeight(hashOrHeight)

Check warning on line 144 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L143-L144

Added lines #L143 - L144 were not covered by tests
if (height !== undefined) {
return await this.api.get(`/blocks/${height}`)

Check warning on line 146 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L146

Added line #L146 was not covered by tests
}
if (isSHA256Hash(hashOrHeight)) {
return await this.api.get(`/blocks/${hashOrHeight}`)

Check warning on line 149 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L149

Added line #L149 was not covered by tests
}
}

async getTransactions (hash: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<Transaction>> {
if (!isSHA256Hash(hash)) {
return ApiPagedResponse.empty()

Check warning on line 155 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L155

Added line #L155 was not covered by tests
}
if (query.next !== undefined) {
return await this.api.get(`/blocks/${hash}/transactions?size=${query.size}&next=${query.next}`)

Check warning on line 158 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L158

Added line #L158 was not covered by tests
}
return await this.api.get(`/blocks/${hash}/transactions?size=${query.size}`)

Check warning on line 160 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L160

Added line #L160 was not covered by tests
}

async getHighest (): Promise<Block | undefined> {
return await this.api.get('/blocks/highest')

Check warning on line 164 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L163-L164

Added lines #L163 - L164 were not covered by tests
}
}

export class DFeeController extends DefidOceanController {
async estimate (): Promise<number> {
return await this.api.get('/fee/estimate')

Check warning on line 170 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L169-L170

Added lines #L169 - L170 were not covered by tests
}
}

export class DGovernanceController extends DefidOceanController {
async listProposals (): Promise<ApiPagedResponse<GovernanceProposal>> {
return await this.api.get('/governance/proposals')

Check warning on line 176 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L175-L176

Added lines #L175 - L176 were not covered by tests
}

async getProposal (id: string): Promise<GovernanceProposal> {
return await this.api.get(`/governance/proposals/${id}`)

Check warning on line 180 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L179-L180

Added lines #L179 - L180 were not covered by tests
}

async listProposalVotes (
@@ -184,229 +188,229 @@
query: OceanListQuery = { size: 30 }
): Promise<ApiPagedResponse<ProposalVotesResult>> {
if (query.next !== undefined) {
return await this.api.get(`/governance/proposals/${id}/votes?masternode=${masternode}&cycle=${cycle}&all=${all}&size=${query.size}&next=${query.next}`)

Check warning on line 191 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L191

Added line #L191 was not covered by tests
}
return await this.api.get(`/governance/proposals/${id}/votes?masternode=${masternode}&cycle=${cycle}&all=${all}&size=${query.size}`)

Check warning on line 193 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L193

Added line #L193 was not covered by tests
}
}

export class DMasternodeController extends DefidOceanController {
async list (query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<MasternodeData>> {
if (query.next !== undefined) {
return await this.api.get(`/masternodes?size=${query.size}&next=${query.next}`)

Check warning on line 200 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L200

Added line #L200 was not covered by tests
}
return await this.api.get(`/masternodes?size=${query.size}`)

Check warning on line 202 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L202

Added line #L202 was not covered by tests
}

async get (id: string): Promise<MasternodeData> {
return await this.api.get(`/masternodes/${id}`)

Check warning on line 206 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L205-L206

Added lines #L205 - L206 were not covered by tests
}
}

export class DOracleController extends DefidOceanController {
async list (query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<Oracle>> {
if (query.next !== undefined) {
return await this.api.get(`/oracles?size=${query.size}&next=${query.next}`)

Check warning on line 213 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L213

Added line #L213 was not covered by tests
}
return await this.api.get(`/oracles?size=${query.size}`)

Check warning on line 215 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L215

Added line #L215 was not covered by tests
}

async getPriceFeed (id: string, key: string): Promise<ApiPagedResponse<OraclePriceFeed>> {
return await this.api.get(`/oracles/${id}/${key}/feed`)

Check warning on line 219 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L218-L219

Added lines #L218 - L219 were not covered by tests
}

async getOracleByAddress (address: string): Promise<Oracle> {
return await this.api.get(`/oracles/${address}`)

Check warning on line 223 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L222-L223

Added lines #L222 - L223 were not covered by tests
}
}

export class DPoolPairController extends DefidOceanController {
async list (query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<PoolPairData>> {
if (query.next !== undefined) {
return await this.api.get(`/poolpairs?size=${query.size}&next=${query.next}`)

Check warning on line 230 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L230

Added line #L230 was not covered by tests
}
return await this.api.get(`/poolpairs?size=${query.size}`)

Check warning on line 232 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L232

Added line #L232 was not covered by tests
}

async get (id: string): Promise<PoolPairData> {
return await this.api.get(`/poolpairs/${id}`)

Check warning on line 236 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L235-L236

Added lines #L235 - L236 were not covered by tests
}

async listPoolSwaps (id: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<PoolSwapData>> {
if (query.next !== undefined) {
return await this.api.get(`/poolpairs/${id}/swaps?size=${query.size}&next=${query.next}`)

Check warning on line 241 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L241

Added line #L241 was not covered by tests
}
return await this.api.get(`/poolpairs/${id}/swaps?size=${query.size}`)

Check warning on line 243 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L243

Added line #L243 was not covered by tests
}

async listPoolSwapsVerbose (id: string, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<PoolSwapData>> {
if (query.next !== undefined) {
return await this.api.get(`/poolpairs/${id}/swaps/verbose?size=${query.size}&next=${query.next}`)

Check warning on line 248 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L248

Added line #L248 was not covered by tests
}
return await this.api.get(`/poolpairs/${id}/swaps/verbose?size=${query.size}`)

Check warning on line 250 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L250

Added line #L250 was not covered by tests
}

async listPoolSwapsAggregate (id: string, interval: number, query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<PoolSwapAggregatedData>> {
if (query.next !== undefined) {
return await this.api.get(`/poolpairs/${id}/swaps/aggregate/${interval}?size=${query.size}&next=${query.next}`)

Check warning on line 255 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L255

Added line #L255 was not covered by tests
}
return await this.api.get(`/poolpairs/${id}/swaps/aggregate/${interval}?size=${query.size}`)

Check warning on line 257 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L257

Added line #L257 was not covered by tests
}

async listSwappableTokens (id: string): Promise<AllSwappableTokensResult> {
return await this.api.get(`/poolpairs/paths/swappable/${id}`)

Check warning on line 261 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L260-L261

Added lines #L260 - L261 were not covered by tests
}

async listPaths (fromTokenId: string, toTokenId: string): Promise<SwapPathsResult> {
return await this.api.get(`/poolpairs/paths/from/${fromTokenId}/to/${toTokenId}`)

Check warning on line 265 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L264-L265

Added lines #L264 - L265 were not covered by tests
}

async getBestPath (fromTokenId: string, toTokenId: string): Promise<BestSwapPathResult> {
return await this.api.get(`/poolpairs/paths/best/from/${fromTokenId}/to/${toTokenId}`)

Check warning on line 269 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L268-L269

Added lines #L268 - L269 were not covered by tests
}

async listDexPrices (denomination: string): Promise<DexPricesResult> {
return await this.api.get(`/poolpairs/dexprices?denomination=${denomination}`)

Check warning on line 273 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L272-L273

Added lines #L272 - L273 were not covered by tests
}
}

export class DPriceController extends DefidOceanController {
async list (query: OceanListQuery = { size: 30 }): Promise<ApiPagedResponse<PriceTicker>> {
if (query.next !== undefined) {
return await this.api.get(`/prices?size=${query.size}&next=${query.next}`)

Check warning on line 280 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L280

Added line #L280 was not covered by tests
}
return await this.api.get(`/prices?size=${query.size}`)

Check warning on line 282 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L282

Added line #L282 was not covered by tests
}

async get (id: string): Promise<PriceTicker | undefined> {
return await this.api.get(`/prices/${id}`)

Check warning on line 286 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L285-L286

Added lines #L285 - L286 were not covered by tests
}

async getFeed (id: string): Promise<ApiPagedResponse<OraclePriceAggregated>> {
return await this.api.get(`/prices/${id}/feed`)

Check warning on line 290 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L289-L290

Added lines #L289 - L290 were not covered by tests
}

async getFeedActive (id: string): Promise<ApiPagedResponse<OraclePriceActive>> {
return await this.api.get(`/prices/${id}/feed/active`)

Check warning on line 294 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L293-L294

Added lines #L293 - L294 were not covered by tests
}

async getFeedWithInterval (id: string, interval: number): Promise<ApiPagedResponse<PriceFeedInterval>> {
return await this.api.get(`/prices/${id}/feed/interval/${interval}`)

Check warning on line 298 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L297-L298

Added lines #L297 - L298 were not covered by tests
}

async listPriceOracles (id: string): Promise<ApiPagedResponse<PriceOracle>> {
return await this.api.get(`/prices/${id}/oracles`)

Check warning on line 302 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L301-L302

Added lines #L301 - L302 were not covered by tests
}
}

export class DRawTxController extends DefidOceanController {
async send (): Promise<string> {
return await this.api.post('/rawtx/send')

Check warning on line 308 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L307-L308

Added lines #L307 - L308 were not covered by tests
}

async test (): Promise<void> {
return await this.api.get('/rawtx/test')

Check warning on line 312 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L311-L312

Added lines #L311 - L312 were not covered by tests
}

async get (id: string, verbose = false): Promise<string | RawTransaction> {
return await this.api.get(`/rawtx/${id}?verbose=${verbose}`)

Check warning on line 316 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L316

Added line #L316 was not covered by tests
}
}

export class DStatsController extends DefidOceanController {
async get (): Promise<StatsData> {
return await this.api.get('/stats')

Check warning on line 322 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L321-L322

Added lines #L321 - L322 were not covered by tests
}

async getSupply (): Promise<SupplyData> {
return await this.api.get('/stats/supply')

Check warning on line 326 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L325-L326

Added lines #L325 - L326 were not covered by tests
}

async getBurn (): Promise<BurnData> {
return await this.api.get('/stats/burn')

Check warning on line 330 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L329-L330

Added lines #L329 - L330 were not covered by tests
}

async getRewardDistribution (): Promise<RewardDistributionData> {
return await this.api.get('/stats/reward/distribution')

Check warning on line 334 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L333-L334

Added lines #L333 - L334 were not covered by tests
}
}

export class DTokenController extends DefidOceanController {
async list (): Promise<ApiPagedResponse<TokenData>> {
return await this.api.get('/tokens')

Check warning on line 340 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L339-L340

Added lines #L339 - L340 were not covered by tests
}

async get (id: string): Promise<TokenData> {
return await this.api.get(`/tokens/${id}`)

Check warning on line 344 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L343-L344

Added lines #L343 - L344 were not covered by tests
}
}

export class DTransactionController extends DefidOceanController {
async get (id: string): Promise<Transaction> {
return await this.api.get(`/transactions/${id}`)

Check warning on line 350 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L349-L350

Added lines #L349 - L350 were not covered by tests
}

async getVins (id: string): Promise<ApiPagedResponse<TransactionVin>> {
return await this.api.get(`/transactions/${id}/vins`)

Check warning on line 354 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L353-L354

Added lines #L353 - L354 were not covered by tests
}

async getVouts (id: string): Promise<ApiPagedResponse<TransactionVout>> {
return await this.api.get(`/transactions/${id}/vouts`)

Check warning on line 358 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L357-L358

Added lines #L357 - L358 were not covered by tests
}
}

export class DefidOcean {
constructor (
readonly addressController: DAddressController,
readonly blockController: DBlockController,
readonly feeController: DFeeController,
readonly governanceController: DGovernanceController,
readonly masternodeController: DMasternodeController,
readonly oracleController: DOracleController,
readonly poolPairController: DPoolPairController,
readonly priceController: DPriceController,
readonly rawTxController: DRawTxController,
readonly statsController: DStatsController,
readonly transactionController: DTransactionController,
readonly tokenController: DTokenController

Check warning on line 375 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L364-L375

Added lines #L364 - L375 were not covered by tests
) {
}
}

export class DefidRpc {
rpcUrl = 'http://test:test@127.0.0.1:19554'

Check warning on line 381 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L381

Added line #L381 was not covered by tests

getCachedRpcUrl (): string {
return this.rpcUrl

Check warning on line 384 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L383-L384

Added lines #L383 - L384 were not covered by tests
}

async call (method: string, params: any = []): Promise<any> {
const body = JSON.stringify({

Check warning on line 388 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L388

Added line #L388 was not covered by tests
jsonrpc: '1.0',
id: Math.floor(Math.random() * 100000000000000),
method: method,
params: params
})

const text = await this.post(body)

Check warning on line 395 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L395

Added line #L395 was not covered by tests
const {
result,
error
} = JSON.parse(text)

Check warning on line 399 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L399

Added line #L399 was not covered by tests

if (error !== undefined && error !== null) {
throw new DeFiDRpcError(error)

Check warning on line 402 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L402

Added line #L402 was not covered by tests
}

return result

Check warning on line 405 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L405

Added line #L405 was not covered by tests
}

async post (body: string): Promise<string> {
const response = await fetch(this.rpcUrl, {

Check warning on line 409 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L408-L409

Added lines #L408 - L409 were not covered by tests
method: 'POST',
body: body
})
return await response.text()

Check warning on line 413 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L413

Added line #L413 was not covered by tests
}

async generate (
@@ -415,78 +419,78 @@
maxTries: number = 1000000
): Promise<void> {
if (address === undefined) {
address = await this.call('getnewaddress')

Check warning on line 422 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L422

Added line #L422 was not covered by tests
}
for (let minted = 0, tries = 0; minted < nblocks && tries < maxTries; tries++) {
const result = await this.call('generatetoaddress', [1, address, 1])

Check warning on line 425 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L425

Added line #L425 was not covered by tests
if (result === 1) {
minted += 1

Check warning on line 427 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L427

Added line #L427 was not covered by tests
}
}
}

async waitForBlockHeight (height: number, timeout = 590000): Promise<void> {
return await waitForCondition(async () => {
const count = await this.getBlockCount()

Check warning on line 434 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L433-L434

Added lines #L433 - L434 were not covered by tests
if (count > height) {
return true

Check warning on line 436 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L436

Added line #L436 was not covered by tests
}
await this.generate(1)
return false

Check warning on line 439 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L438-L439

Added lines #L438 - L439 were not covered by tests
}, timeout, 100, 'waitForBlockHeight')
}

async blockHeight (height: number, timeout: number = 590000): Promise<void> {
return await waitForCondition(async () => {
const count = await this.getBlockCount()

Check warning on line 445 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L444-L445

Added lines #L444 - L445 were not covered by tests
if (count > height) {
return true

Check warning on line 447 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L447

Added line #L447 was not covered by tests
}
await this.generate(1)
return false

Check warning on line 450 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L449-L450

Added lines #L449 - L450 were not covered by tests
}, timeout, 100, 'waitForBlockHeight')
}

async waitForWalletCoinbaseMaturity (timeout: number = 180000, mockTime: boolean = true): Promise<void> {
if (!mockTime) {
return await this.blockHeight(100, timeout)

Check warning on line 456 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L456

Added line #L456 was not covered by tests
}

let fakeTime: number = 1579045065
await this.call('setmocktime', [fakeTime])

Check warning on line 460 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L459-L460

Added lines #L459 - L460 were not covered by tests

const intervalId = setInterval(() => {
fakeTime += 3
void this.call('setmocktime', [fakeTime])

Check warning on line 464 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L462-L464

Added lines #L462 - L464 were not covered by tests
}, 200)

await this.blockHeight(100, timeout)

Check warning on line 467 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L467

Added line #L467 was not covered by tests

clearInterval(intervalId)
await this.call('setmocktime', [0])

Check warning on line 470 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L469-L470

Added lines #L469 - L470 were not covered by tests
}

async waitForWalletBalanceGTE (balance: number, timeout: number = 300000): Promise<void> {
return await waitForCondition(async () => {
const getbalance = await this.call('getbalance')

Check warning on line 475 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L474-L475

Added lines #L474 - L475 were not covered by tests
if (getbalance >= balance) {
return true

Check warning on line 477 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L477

Added line #L477 was not covered by tests
}
await this.generate(1)
return false

Check warning on line 480 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L479-L480

Added lines #L479 - L480 were not covered by tests
}, timeout, 100, 'waitForWalletBalanceGTE')
}

async getNewAddress (label: string = '', addressType: 'legacy' | 'p2sh-segwit' | 'bech32' | 'eth' | string = 'bech32'): Promise<string> {
return await this.call('getnewaddress', [label, addressType])

Check warning on line 485 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L485

Added line #L485 was not covered by tests
}

async getBlockCount (): Promise<number> {
return await this.call('getblockcount', [])

Check warning on line 489 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L488-L489

Added lines #L488 - L489 were not covered by tests
}

async createToken (symbol: string, options?: CreateTokenOptions): Promise<number> {
const metadata = {

Check warning on line 493 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L492-L493

Added lines #L492 - L493 were not covered by tests
symbol,
name: options?.name ?? symbol,
isDAT: options?.isDAT ?? true,
@@ -495,33 +499,33 @@
collateralAddress: options?.collateralAddress ?? await this.getNewAddress()
}

await this.waitForWalletBalanceGTE(101)
await this.call('create', [metadata])
await this.generate(1)

Check warning on line 504 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L502-L504

Added lines #L502 - L504 were not covered by tests

const res = await this.call('gettoken', [symbol])
return Number.parseInt(Object.keys(res)[0])

Check warning on line 507 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L506-L507

Added lines #L506 - L507 were not covered by tests
}

async createPoolPair (aToken: string, bToken: string, options?: CreatePoolPairOptions): Promise<string> {
const metadata = {

Check warning on line 511 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L510-L511

Added lines #L510 - L511 were not covered by tests
tokenA: aToken,
tokenB: bToken,
commission: options?.commission ?? 0,
status: options?.status ?? true,
ownerAddress: options?.ownerAddress ?? await this.getNewAddress()
}
const txid = await this.call('createpoolpair', [metadata, options?.utxos])
await this.generate(1)
return txid

Check warning on line 520 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L518-L520

Added lines #L518 - L520 were not covered by tests
}
}

export class DefidBin {
tmpDir: string = `/tmp/${uuidv4()}`
binary: ChildProcess | null = null
rpc = new DefidRpc()
ocean = new DefidOcean(

Check warning on line 528 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L525-L528

Added lines #L525 - L528 were not covered by tests
new DAddressController(),
new DBlockController(),
new DFeeController(),
@@ -536,14 +540,14 @@
new DTokenController()
)

async start (): Promise<void> {
fs.mkdirSync(this.tmpDir)

Check warning on line 544 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L543-L544

Added lines #L543 - L544 were not covered by tests

if (process.env.DEFID === undefined) {
throw new Error('`process.env.DEFID` is required')

Check warning on line 547 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L547

Added line #L547 was not covered by tests
}

const args = [

Check warning on line 550 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L550

Added line #L550 was not covered by tests
`-datadir=${this.tmpDir}`,
'-regtest',
'-printtoconsole',
@@ -563,7 +567,7 @@
'-oceanarchive'
]

const extraArgs = [

Check warning on line 570 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L570

Added line #L570 was not covered by tests
'-amkheight=0',
'-bayfrontheight=1',
'-bayfrontgardensheight=2',
@@ -585,79 +589,79 @@
'-metachainheight=18'
]

const binary = spawn(process.env.DEFID, args.concat(extraArgs))

Check warning on line 592 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L592

Added line #L592 was not covered by tests

binary.on('error', err => {

Check warning on line 594 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L594

Added line #L594 was not covered by tests
if ((err as any).errno === 'ENOENT') {
console.error('\x1b[31mMissing Defid binary.\nPlease compile the Defid\x1b[0m')
} else {
console.error(err)

Check warning on line 598 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L596-L598

Added lines #L596 - L598 were not covered by tests
}
process.exit(1)

Check warning on line 600 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L600

Added line #L600 was not covered by tests
})

const logs: string[] = []

Check warning on line 603 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L603

Added line #L603 was not covered by tests

await new Promise<void>((resolve, reject) => {
const timer = setTimeout(() => {
console.error('\x1b[31m Failed to start Defid node.\x1b[0m')
console.error(logs.map(chunk => chunk.toString()).join('\n'))
process.exit(1)

Check warning on line 609 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L605-L609

Added lines #L605 - L609 were not covered by tests
}, SPAWNING_TIME - 20_000)

const onData = async (chunk: any) => {
logs.push(chunk)

Check warning on line 613 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L612-L613

Added lines #L612 - L613 were not covered by tests

/* eslint-disable-next-line @typescript-eslint/strict-boolean-expressions */
if (chunk.toString().match(/addcon thread start/)) {
// wait for ocean
await new Promise((resolve) => setTimeout(resolve, 1000))

Check warning on line 618 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L618

Added line #L618 was not covered by tests

try {

Check warning on line 620 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L620

Added line #L620 was not covered by tests
// TODO(canonbrother): blockController.get(0)
const res = await this.ocean.blockController.list({ size: 1 })
console.log('[DefidBin.start()] blockController.list res: ', res)

Check warning on line 623 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L622-L623

Added lines #L622 - L623 were not covered by tests
} catch (err) {
console.log('[DefidBin.start()] blockController.get err: ', err)

Check warning on line 625 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L625

Added line #L625 was not covered by tests
}

clearTimeout(timer)

Check warning on line 628 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L628

Added line #L628 was not covered by tests

binary.stderr.off('data', onData)
binary.stdout.off('data', onData)

Check warning on line 631 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L630-L631

Added lines #L630 - L631 were not covered by tests

await this.rpc.call('importprivkey', [RegTestFoundationKeys[1].owner.privKey])
await this.rpc.call('importprivkey', [RegTestFoundationKeys[1].operator.privKey])

Check warning on line 634 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L633-L634

Added lines #L633 - L634 were not covered by tests

// setgov
// generate(2)

resolve()

Check warning on line 639 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L639

Added line #L639 was not covered by tests
}
}

binary.stderr.on('data', onData)
binary.stdout.on('data', onData)

Check warning on line 644 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L643-L644

Added lines #L643 - L644 were not covered by tests
})

this.binary = binary

Check warning on line 647 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L647

Added line #L647 was not covered by tests
}

async stop (): Promise<void> {
const interval = setInterval(() => {

Check warning on line 651 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L650-L651

Added lines #L650 - L651 were not covered by tests
if (this.binary?.pid !== undefined && !this.isRunning(this.binary?.pid)) {
clearInterval(interval)
fs.rmdirSync(this.tmpDir, { recursive: true })

Check warning on line 654 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L653-L654

Added lines #L653 - L654 were not covered by tests
}
}, 500)
this.binary?.kill()

Check warning on line 657 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L657

Added line #L657 was not covered by tests
}

private isRunning (pid: number): boolean {
try {
return process.kill(pid, 0)

Check warning on line 662 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L660-L662

Added lines #L660 - L662 were not covered by tests
} catch (err: any) {
return err.code === 'EPERM'

Check warning on line 664 in apps/whale-api/src/e2e.defid.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.defid.module.ts#L664

Added line #L664 was not covered by tests
}
}
}
7 changes: 3 additions & 4 deletions apps/whale-api/src/e2e.module.ts
Original file line number Diff line number Diff line change
@@ -85,11 +85,10 @@
*/
export async function waitForIndexedHeight (app: NestFastifyApplication | DefidBin, height: number, timeout: number = 30000): Promise<void> {
if (app instanceof DefidBin) {
await waitForExpect(async () => {
// TODO(canonbrother): ocean getblockcount
// const count = await app.ocean.getBlockCount()
// expect(count).toBeGreaterThan(height)
// await app.rpc.generate(1)
const block = await app.ocean.blockController.getHighest()
expect(block?.height).toBeGreaterThan(height)
await app.rpc.generate(1)

Check warning on line 91 in apps/whale-api/src/e2e.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.module.ts#L88-L91

Added lines #L88 - L91 were not covered by tests
}, timeout)
} else {
const blockMapper = app.get(BlockMapper)
@@ -118,7 +117,7 @@
// TODO(): handle DefidBin
export async function waitForAddressTxCount (app: NestFastifyApplication | DefidBin, address: string, txCount: number, timeout: number = 15000): Promise<void> {
if (app instanceof DefidBin) {
return

Check warning on line 120 in apps/whale-api/src/e2e.module.ts

Codecov / codecov/patch

apps/whale-api/src/e2e.module.ts#L120

Added line #L120 was not covered by tests
}
const hid = addressToHid('regtest', address)
const aggregationMapper = app.get(ScriptAggregationMapper)