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(apps/whale-api): support whale test suite for defid ocean #2177

Draft
wants to merge 124 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
1cc12cb
add e2e.defid.module.ts
canonbrother Jan 26, 2024
5d9f896
duplicate e2e to defid-e2e
canonbrother Jan 26, 2024
8d4beff
defid.waitForExpect
canonbrother Jan 26, 2024
4f1f317
defid.tx.ctrl.e2e
canonbrother Jan 26, 2024
2ebc3e1
fix blocks/highest
canonbrother Jan 26, 2024
d49f145
fix defid ocean api return data
canonbrother Jan 26, 2024
cad5606
defid.block.ctrl.e2e
canonbrother Jan 26, 2024
e960e84
defid.fee.ctrl.e2e
canonbrother Jan 26, 2024
7fba1ad
add testing + jf_testig utils into e2e.defid.mod
canonbrother Jan 29, 2024
d6acf31
fix addr.ctrl.e2e
canonbrother Jan 29, 2024
293c677
fix block.fee.tx.ctrl.e2e
canonbrother Jan 29, 2024
1f2cf40
fix mn.ctrl.e2e
canonbrother Jan 29, 2024
93e96af
fix stats.ctrl.e2e
canonbrother Jan 29, 2024
df1dfdc
fix token.ctrl.e2e
canonbrother Jan 29, 2024
b627a06
fix tx.ctrl wrong api
canonbrother Jan 29, 2024
408a42f
fix pp.ctrl.e2e
canonbrother Jan 29, 2024
8b53954
fix pp.ser.e2e
canonbrother Jan 29, 2024
da24014
add loanctrl apis
canonbrother Jan 29, 2024
d3c3abe
fix loan.col.ctrl.e2e
canonbrother Jan 29, 2024
af4770c
fix loan.scheme.ctrl.e2e
canonbrother Jan 29, 2024
3f4021a
fix loan.token.ctrl.e2e
canonbrother Jan 29, 2024
d57caf7
fix loan.vault.ctrl.e2e
canonbrother Jan 29, 2024
945f207
rm legacy.ctrl.e2e
canonbrother Jan 29, 2024
19db945
fix rawtx.ctrl.e2e
canonbrother Jan 29, 2024
4b85757
fix gov.ctrl.e2e
canonbrother Jan 29, 2024
44372ce
fix listProposalVotes api params
canonbrother Jan 29, 2024
5127f29
fix api return, no destructure data
canonbrother Jan 29, 2024
f35915e
support ocean port
canonbrother Jan 30, 2024
9e6a093
fix socket hang up err
canonbrother Jan 31, 2024
051a644
jest.defid.js
canonbrother Jan 31, 2024
0903dec
e2e -> defid
canonbrother Jan 31, 2024
cbd5751
rand rpcport n port
canonbrother Jan 31, 2024
3000fa3
rand min and max
canonbrother Jan 31, 2024
861380f
runInBand
canonbrother Jan 31, 2024
c1a33d5
onData getblocklist length
canonbrother Jan 31, 2024
76545e1
hide loan.auction.ctrl & history
canonbrother Jan 31, 2024
4e27b55
get tmpDir by default
canonbrother Feb 2, 2024
5bed3f0
rename api -> client
canonbrother Feb 5, 2024
08adcd5
ignore next undefined
canonbrother Feb 5, 2024
204f91d
data
canonbrother Feb 5, 2024
3aa1d17
tx ctrl missing id
canonbrother Feb 5, 2024
b2e39ca
refine path and client
canonbrother Feb 5, 2024
8183640
missing slash on post
canonbrother Feb 11, 2024
0ef6d84
handle res.error
canonbrother Feb 19, 2024
1a037b9
correct loan api res + refine try catch test
canonbrother Feb 20, 2024
97f5ef4
fix listSwappableTokens resp
canonbrother Feb 20, 2024
642e432
typo stats api
canonbrother Feb 20, 2024
2910deb
revert stats.defid
canonbrother Feb 20, 2024
6a44e11
rm blockHeight()
canonbrother Feb 20, 2024
ce308b0
use waitForBlockHeight as waitForIndexHeight
canonbrother Feb 20, 2024
846da8f
add prices.defid.ts
canonbrother Feb 21, 2024
97952c5
scan api pattern
canonbrother Feb 22, 2024
23ceb09
update tx get error test
canonbrother Feb 23, 2024
e7a0ead
transaction vin/vout api typo
canonbrother Feb 25, 2024
d651e1c
skip weird test
canonbrother Feb 26, 2024
10bce5c
token get err msg -> Token not found
canonbrother Feb 27, 2024
dfd0a27
getCollateral err msg update
canonbrother Feb 27, 2024
2d79709
typo getscheme api path
canonbrother Feb 27, 2024
b34cf54
add poolswaps(v) defid test
canonbrother Mar 6, 2024
d6c004b
add oracles.defid.ts
canonbrother Mar 18, 2024
5dc45d7
rename rpc -> client for DefidRpcClient
canonbrother Mar 18, 2024
021cc28
rename rpc -> client for DefidRpcClient
canonbrother Mar 18, 2024
69f049f
use containing check
canonbrother Apr 24, 2024
ffaa8ae
add poolpairs.defid.ts
canonbrother May 17, 2024
05dc53f
cleanup poolpairs.defid.ts
canonbrother May 20, 2024
c0e95ca
[prices.defid.ts] rm exta block gen
canonbrother May 28, 2024
ade41df
[prices.defid.ts] rm exta block gen #2
canonbrother May 28, 2024
7858f60
rm log
canonbrother May 31, 2024
c49d327
waitForPath
canonbrother May 31, 2024
e3bf9dc
fix poolswapverbose expect wrong type
canonbrother Jun 8, 2024
9c0a68d
rm only
canonbrother Jun 8, 2024
e3becbd
raiseiferror
canonbrother Jun 12, 2024
f4ec9af
refine api client kind error message, not ctrl
canonbrother Jun 12, 2024
293a5cd
refine rawtx fail test
canonbrother Jun 12, 2024
45aab70
reorg defid flags
canonbrother Jun 13, 2024
7a2c4fc
enable loan.auction.ctrl.defid.ts
canonbrother Jun 13, 2024
ff302ac
rawtx send badreq url
canonbrother Jun 21, 2024
5f57626
rawtx test badreq url
canonbrother Jun 24, 2024
329bff2
rand wsport and ethrpcport
canonbrother Jun 24, 2024
6d42c1c
rm unuse log
canonbrother Jun 24, 2024
92fd1a3
rm unuse log
canonbrother Jun 24, 2024
04842e7
waitForAddressTxCount
canonbrother Jun 27, 2024
2c13b5a
update address.ctrl.defid.ts
canonbrother Jun 27, 2024
4a1342c
fix listTokens err test
canonbrother Jul 2, 2024
50854f7
add flag -rpc-governance-accept-neutral=1
canonbrother Jul 3, 2024
79d93a2
regtest_jellyfish=1
canonbrother Jul 3, 2024
2b55479
fix governance.ctrl.defid.ts
canonbrother Jul 3, 2024
cc1285c
governance.ctrl.defid.ts rm only
canonbrother Jul 4, 2024
7014993
gov.ctrl.defid.ts rm log
canonbrother Jul 5, 2024
3ff2a6a
fix addr.ctrl.defid.ts
canonbrother Jul 9, 2024
4d29e64
refine loan.auction.ctrl.defid.ts
canonbrother Jul 9, 2024
0fde2bf
add address list vaults
canonbrother Jul 16, 2024
0d98ffa
add fail test on address list vault
canonbrother Jul 17, 2024
e5955b9
skip listacchistory
canonbrother Jul 19, 2024
c169171
oceanarchivebind
canonbrother Aug 12, 2024
e43995e
fix prices.defid.ts
canonbrother Aug 27, 2024
6b22e72
fix mn non-existent fail test
canonbrother Sep 3, 2024
8b74201
fix mn resign test
canonbrother Sep 3, 2024
41a565a
oceanarchiverest
canonbrother Sep 4, 2024
2fa9cd9
add poolpair.swap.split.defid.ts
canonbrother Sep 13, 2024
34df44d
dp refer rust ocean
canonbrother Sep 26, 2024
eec3994
small cp vaultstate in rust-ocean
canonbrother Sep 26, 2024
d8fe1a0
skip and note multinode test
canonbrother Sep 26, 2024
003403b
rm log
canonbrother Sep 26, 2024
2415d67
maxWorkers=100 and maxParallel=4
canonbrother Sep 26, 2024
9627fa6
oceanarchiverest -> oceanarchiveserver
canonbrother Oct 3, 2024
7d0fba0
cater rust undefined -> none
canonbrother Oct 3, 2024
1123265
cater rust undefined -> none #2 poolpair
canonbrother Oct 3, 2024
99cf850
fix wrong errmsg
canonbrother Oct 3, 2024
8756acf
update pp invalid-nonexist fail test
canonbrother Oct 3, 2024
e605196
rm only
canonbrother Oct 10, 2024
5c5599c
add rpc test
canonbrother Oct 10, 2024
bbb7f1d
rm default pp_agg
canonbrother Oct 25, 2024
177a89a
output activePrice
canonbrother Oct 25, 2024
d5557e2
add loan.auction.history.defid.ts
canonbrother Oct 28, 2024
3d23870
test UpdateOracle and RemoveOracle
canonbrother Nov 1, 2024
2488228
uncheck flaky
canonbrother Nov 4, 2024
5846c36
fix wrong type
canonbrother Nov 4, 2024
793401c
add prices.active.defid.ts
canonbrother Nov 19, 2024
05aeefd
return default activePrice
canonbrother Nov 19, 2024
e54b9f5
rm data wrapper on rpc api
canonbrother Nov 25, 2024
c4622ba
loan collateral active price undefined
canonbrother Nov 26, 2024
5d03d3c
default active price
canonbrother Nov 29, 2024
aeeb3db
update price test
canonbrother Dec 6, 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
1,068 changes: 1,068 additions & 0 deletions apps/whale-api/src/e2e.defid.module.ts

Large diffs are not rendered by default.

1,113 changes: 1,113 additions & 0 deletions apps/whale-api/src/module.api/__defid__/address.controller.defid.ts

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions apps/whale-api/src/module.api/__defid__/block.controller.defid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { parseHeight } from '../block.controller'
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
import { DBlockController, DefidBin, DefidRpc } from '../../e2e.defid.module'

let container: DefidRpc
let app: DefidBin
let controller: DBlockController
let client: JsonRpcClient

beforeAll(async () => {
app = new DefidBin()
await app.start()
controller = app.ocean.blockController
container = app.rpc
await app.waitForBlockHeight(101)
client = new JsonRpcClient(app.rpcUrl)

const address = await app.getNewAddress()
for (let i = 0; i < 4; i += 1) {
await app.call('sendtoaddress', [address, 0.1])
}

await container.generate(3)
await app.waitForBlockHeight(103)
})

afterAll(async () => {
await app.stop()
})

describe('get', () => {
it('should get block based on hash', async () => {
const blockHash = await app.call('getblockhash', [100])
const block = await controller.get(blockHash)
expect(block?.height).toStrictEqual(100)
expect(block?.hash).toStrictEqual(blockHash)
})

it('get should get block with height', async () => {
const block = await controller.get('100')
expect(block?.height).toStrictEqual(100)
})

it('should get undefined with invalid hash ', async () => {
const block = await controller.get('lajsdl;kfjljklj12lk34j')
expect(block).toStrictEqual(undefined)
})
})

describe('list', () => {
it('should return paginated list of blocks', async () => {
const firstPage = await controller.list({ size: 40 })

expect(firstPage.data.length).toStrictEqual(40)

expect(firstPage.data[0].height).toBeGreaterThanOrEqual(100)

const secondPage = await controller.list({ size: 40, next: firstPage.page?.next })

expect(secondPage.data.length).toStrictEqual(40)
expect(secondPage.data[0].height).toStrictEqual(firstPage.data[39].height - 1)

const lastPage = await controller.list({ size: 40, next: secondPage.page?.next })

expect(lastPage.data[0].height).toStrictEqual(secondPage.data[39].height - 1)
expect(lastPage.page?.next).toBeUndefined()
})

it('should return all the blocks if the size is out of range', async () => {
const paginatedBlocks = await controller.list({ size: 100000, next: '100' })

expect(paginatedBlocks.data.length).toStrictEqual(100)
expect(paginatedBlocks.data[0].height).toBeGreaterThanOrEqual(99)
})

it('list would return the latest set if next is outside of range', async () => {
const paginatedBlocks = await controller.list({ size: 30, next: '100000' })

expect(paginatedBlocks.data.length).toStrictEqual(30)
expect(paginatedBlocks.data[0].height).toBeGreaterThanOrEqual(100)
})

it('list would return the latest set if next is 0', async () => {
const paginatedBlocks = await controller.list({ size: 30, next: '0' })

expect(paginatedBlocks.data.length).toStrictEqual(0)
expect(paginatedBlocks?.page).toBeUndefined()
})
})

describe('getTransactions', () => {
it('should get transactions from a block by hash', async () => {
const blockHash = await app.call('getblockhash', [100])
const paginatedTransactions = await controller.getTransactions(blockHash, { size: 30 })

expect(paginatedTransactions.data.length).toBeGreaterThanOrEqual(1)
expect(paginatedTransactions.data[0].block.height).toStrictEqual(100)
})

it('getTransactions should not get transactions by height', async () => {
const paginatedTransactions = await controller.getTransactions('0', { size: 30 })

expect(paginatedTransactions.data.length).toStrictEqual(0)
})

it('getTransactions should get empty array when hash is not valid', async () => {
const paginatedTransactions = await controller.getTransactions('z1wadfsvq90qlkfalnklvm', { size: 30 })

expect(paginatedTransactions.data.length).toStrictEqual(0)
})

it('getTransactions should get empty array when height is not valid', async () => {
const paginatedTransactions = await controller.getTransactions('999999999999', { size: 30 })

expect(paginatedTransactions.data.length).toStrictEqual(0)
})

it('should list transactions in the right order', async () => {
const blockHash = await app.call('getblockhash', [103])
const paginatedTransactions = await controller.getTransactions(blockHash, { size: 30 })

expect(paginatedTransactions.data.length).toBeGreaterThanOrEqual(4)
expect(paginatedTransactions.data[0].block.height).toStrictEqual(103)

const rpcBlock = await client.blockchain.getBlock(blockHash, 2)
expect(paginatedTransactions.data[0].hash).toStrictEqual(rpcBlock.tx[0].hash)
expect(paginatedTransactions.data[1].hash).toStrictEqual(rpcBlock.tx[1].hash)
expect(paginatedTransactions.data[2].hash).toStrictEqual(rpcBlock.tx[2].hash)
expect(paginatedTransactions.data[3].hash).toStrictEqual(rpcBlock.tx[3].hash)
})
})

describe('parseHeight', () => {
it('should return undefined for negative integer', () => {
expect(parseHeight('-123')).toStrictEqual(undefined)
})

it('should return undefined for float', () => {
expect(parseHeight('123.32')).toStrictEqual(undefined)
})

it('should return number for positive integers', () => {
expect(parseHeight('123')).toStrictEqual(123)
})

it('should return undefined for empty string', () => {
expect(parseHeight('')).toStrictEqual(undefined)
})

it('should return undefined for undefined', () => {
expect(parseHeight(undefined)).toStrictEqual(undefined)
})

it('should return undefined for strings with characters', () => {
expect(parseHeight('123a')).toStrictEqual(undefined)
})
})
43 changes: 43 additions & 0 deletions apps/whale-api/src/module.api/__defid__/fee.controller.defid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { JsonRpcClient } from '@defichain/jellyfish-api-jsonrpc'
import { DFeeController, DefidBin, DefidRpc } from '../../e2e.defid.module'

let container: DefidRpc
let app: DefidBin
let controller: DFeeController
let client: JsonRpcClient

beforeAll(async () => {
app = new DefidBin()
await app.start()
controller = app.ocean.feeController
container = app.rpc
await app.waitForWalletCoinbaseMaturity()
await app.waitForWalletBalanceGTE(100)

client = new JsonRpcClient(app.rpcUrl)

await app.waitForBlockHeight(100)
})

afterAll(async () => {
await app.stop()
})

describe('fee/estimate', () => {
it('should have fee of 0.00005 and not 0.00005 after adding activity', async () => {
const before = await controller.estimate(10)
expect(before).toStrictEqual(0.00005000)

for (let i = 0; i < 10; i++) {
for (let x = 0; x < 20; x++) {
await client.wallet.sendToAddress('bcrt1qf5v8n3kfe6v5mharuvj0qnr7g74xnu9leut39r', 0.1, {
subtractFeeFromAmount: true,
avoidReuse: false
})
}
await container.generate(1)
}
const after = await controller.estimate(10)
expect(after).not.toStrictEqual(0.00005000)
})
})
Loading
Loading