Skip to content

Commit

Permalink
fix(jellyfish-api-core, jellyfish-transaction-builder): Fix failed te…
Browse files Browse the repository at this point in the history
…sts for fortcanningcrunch (#1461)

* Change to the latest docker image

* Fix fail test

* Update masternode doc

* Add collateralTx

* Update docs

* Update test

* Fix failed tests

* Fix failed tests

* Fix failed tests

* Fix failed tests

* Fix failed tests

* Temporarily comment out failed test

* Minor

* Add back commented code

* Fix failed test

* Fixed withdrawFutureSwap failing tests.

* Fix block length

* Minor

* Minor

* Minor

* Fix failed test

* Fix failed test

* Fix failed test

* Fix failed test

* Updated to V3 latest image.

* Updated image to stock-splits only.

* Fixed placeAuctionBid.test.ts failing tests with stock-splits.

* Fixed withdrawFutureSwap.test.ts failing tests with stock-splits.

* Updated image to latest fortcanningspicegardenheight.

* Fixed failing tests.

* Updated image to latest master.

* Update packages/testcontainers/src/containers/RegTestContainer/index.ts

* Update docker image

* Fix failed tests

* fix pg setgov

rm extra code

* Fix failed tests

* Fix failed tests

* Don't use v3 code, revert to old code

* Remove activateAfterBlock test unit and defaulted the value to 0 for setCollateralToken DFTX

* Connect to the latest docker image

* Fix failed test

* Skip on-chain governance code

* Skip on-chain governance code

* Connect to latest docker image

* Fix failed test

* Fix failed test

* Fix failed test

* Connect to latest docker image

* add missing doc - poolpair dexfee

* Fix bad code after which is the result of "eslint --fix"

* Fix bad code after which is the result of "eslint --fix"

* Remove redundant now function.

* Use skip instead

* Fix flaky test. (Retrieve date from a global variable)

* Change variable name from currentTimestamp to now. (Which is the common variable name used in other files)

* Use unique date for this test only

* Set unique date for different oracle data

* Fix flaky test

* Temporarily skip this

* Skip the entire describe

* Skip and add comments

* Fix wrong description

* Improve code

* Revert back code

* Reverted changes to placeAuctionBid.test.ts file.

* Temporarily skip flaky test

* Updated to latest master image.

* Updated to latest master image.

* Updated the image to FCC.

Co-authored-by: “jingyi2811” <“[email protected]”>
Co-authored-by: jingyi2811 <[email protected]>
Co-authored-by: websterlcl <[email protected]>
  • Loading branch information
4 people authored May 30, 2022
1 parent 10cbb05 commit ee0609e
Show file tree
Hide file tree
Showing 56 changed files with 302 additions and 477 deletions.
56 changes: 53 additions & 3 deletions apps/playground-api/__tests__/modules/PlaygroundModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,81 @@ it('should have gov set', async () => {
const gov = await testing.container.call('getgov', ['ATTRIBUTES'])
expect(gov).toStrictEqual({
ATTRIBUTES: expect.objectContaining({
'v0/params/dfip2203/active': 'true',
'v0/params/dfip2203/reward_pct': '0.05',
'v0/params/dfip2203/block_period': '20',
'v0/token/0/fixed_interval_price_id': 'DFI/USD',
'v0/token/0/loan_collateral_enabled': 'true',
'v0/token/0/loan_collateral_factor': '1',
'v0/token/1/fixed_interval_price_id': 'BTC/USD',
'v0/token/1/loan_collateral_enabled': 'true',
'v0/token/1/loan_collateral_factor': '1',
'v0/token/2/fixed_interval_price_id': 'ETH/USD',
'v0/token/2/loan_collateral_enabled': 'true',
'v0/token/2/loan_collateral_factor': '0.7',
'v0/token/3/fixed_interval_price_id': 'USDT/USD',
'v0/token/3/loan_collateral_enabled': 'true',
'v0/token/3/loan_collateral_factor': '1',
'v0/token/5/fixed_interval_price_id': 'USDC/USD',
'v0/token/5/loan_collateral_enabled': 'true',
'v0/token/5/loan_collateral_factor': '1',
'v0/token/6/fixed_interval_price_id': 'CU10/USD',
'v0/token/6/loan_collateral_enabled': 'true',
'v0/token/6/loan_collateral_factor': '1',
'v0/token/7/fixed_interval_price_id': 'CD10/USD',
'v0/token/7/loan_collateral_enabled': 'true',
'v0/token/7/loan_collateral_factor': '1',
'v0/token/8/fixed_interval_price_id': 'CS25/USD',
'v0/token/8/loan_collateral_enabled': 'true',
'v0/token/8/loan_collateral_factor': '1',
'v0/token/9/fixed_interval_price_id': 'CR50/USD',
'v0/token/9/loan_collateral_enabled': 'true',
'v0/token/9/loan_collateral_factor': '1',
'v0/token/10/fixed_interval_price_id': 'ZERO/USD',
'v0/token/10/loan_collateral_enabled': 'true',
'v0/token/10/loan_collateral_factor': '1',
'v0/token/11/fixed_interval_price_id': 'OFF/USD',
'v0/token/11/loan_collateral_enabled': 'true',
'v0/token/11/loan_collateral_factor': '1',
'v0/token/12/payback_dfi': 'true',
'v0/token/12/payback_dfi_fee_pct': '0.01',
'v0/token/12/loan_payback/1': 'true',
'v0/token/12/loan_payback/14': 'true',
'v0/token/12/loan_payback_fee_pct/1': '0.01',
'v0/token/12/loan_payback_fee_pct/14': '0.01',
'v0/token/12/fixed_interval_price_id': 'DUSD/USD',
'v0/token/12/loan_collateral_enabled': 'true',
'v0/token/12/loan_collateral_factor': '0.99',
'v0/token/12/loan_minting_enabled': 'true',
'v0/token/12/loan_minting_interest': '0',
'v0/token/13/loan_payback/6': 'true',
'v0/token/13/loan_payback/12': 'true',
'v0/token/13/loan_payback_fee_pct/6': '0.01',
'v0/token/13/loan_payback_fee_pct/12': '0.01',
'v0/token/13/fixed_interval_price_id': 'TU10/USD',
'v0/token/13/loan_minting_enabled': 'true',
'v0/token/13/loan_minting_interest': '1',
'v0/token/14/loan_payback/1': 'true',
'v0/token/14/loan_payback/12': 'true',
'v0/token/14/loan_payback_fee_pct/1': '0.01',
'v0/token/14/loan_payback_fee_pct/12': '0.01',
'v0/token/14/fixed_interval_price_id': 'TD10/USD',
'v0/token/14/loan_minting_enabled': 'true',
'v0/token/14/loan_minting_interest': '1.5',
'v0/token/15/loan_payback/13': 'true',
'v0/token/15/loan_payback_fee_pct/13': '0.01',
'v0/token/15/fixed_interval_price_id': 'TS25/USD',
'v0/token/15/loan_minting_enabled': 'true',
'v0/token/15/loan_minting_interest': '2',
'v0/token/16/payback_dfi': 'true',
'v0/token/16/payback_dfi_fee_pct': '0.01',
'v0/token/16/loan_payback/12': 'true',
'v0/token/16/loan_payback/14': 'true',
'v0/token/16/loan_payback_fee_pct/12': '0.01',
'v0/token/16/loan_payback_fee_pct/14': '0.01',
'v0/params/dfip2203/active': 'true',
'v0/params/dfip2203/reward_pct': '0.05',
'v0/params/dfip2203/block_period': '20'
'v0/token/16/fixed_interval_price_id': 'TR50/USD',
'v0/token/16/loan_minting_enabled': 'true',
'v0/token/16/loan_minting_interest': '3'
})
})

Expand Down
7 changes: 1 addition & 6 deletions apps/playground-api/src/setups/setup.gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ export class SetupGov extends PlaygroundSetup<Record<string, any>> {
}

async has (each: any): Promise<boolean> {
const key = Object.keys(each)[0]
const gov = await this.client.masternode.getGov(key)
if (Object.keys(gov[key]).length > 0) {
return true
}
return false
return false // for just overwrite
}

async after (): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const container = new LoanMasterNodeRegTestContainer()
let app: NestFastifyApplication
let controller: LoanController

let collateralTokenId1: string

beforeAll(async () => {
await container.start()
await container.waitForWalletCoinbaseMaturity()
Expand Down Expand Up @@ -68,7 +66,7 @@ beforeAll(async () => {
})
await testing.generate(1)

collateralTokenId1 = await testing.rpc.loan.setCollateralToken({
await testing.rpc.loan.setCollateralToken({
token: 'AAPL',
factor: new BigNumber(0.1),
fixedIntervalPriceId: 'AAPL/USD'
Expand Down Expand Up @@ -109,7 +107,6 @@ describe('list', () => {
tokenId: expect.any(String),
fixedIntervalPriceId: expect.any(String),
factor: expect.any(String),
activateAfterBlock: expect.any(Number),
token: {
collateralAddress: expect.any(String),
creation: {
Expand Down Expand Up @@ -175,10 +172,9 @@ describe('get', () => {
const data = await controller.getCollateral('AAPL')
expect(data).toStrictEqual(
{
tokenId: collateralTokenId1,
tokenId: expect.stringMatching(/[0-f]{64}/),
fixedIntervalPriceId: 'AAPL/USD',
factor: '0.1',
activateAfterBlock: 108,
token: {
collateralAddress: expect.any(String),
creation: {
Expand Down
1 change: 0 additions & 1 deletion apps/whale-api/src/module.api/loan.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ export class LoanController {
tokenId: detail.tokenId,
token: mapTokenData(id, tokenInfo),
factor: detail.factor.toFixed(),
activateAfterBlock: detail.activateAfterBlock.toNumber(),
fixedIntervalPriceId: detail.fixedIntervalPriceId,
activePrice: await this.getActivePrice(detail.fixedIntervalPriceId)
}
Expand Down
26 changes: 19 additions & 7 deletions docs/node/CATEGORIES/06-poolpair.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,29 @@ interface PoolPairsResult {
interface PoolPairInfo {
symbol: string
name: string
status: string
status: boolean
idTokenA: string
idTokenB: string
dexFeePctTokenA?: BigNumber
dexFeeInPctTokenA?: BigNumber
dexFeeOutPctTokenA?: BigNumber
dexFeePctTokenB?: BigNumber
dexFeeInPctTokenB?: BigNumber
dexFeeOutPctTokenB?: BigNumber
reserveA: BigNumber
reserveB: BigNumber
commission: BigNumber
totalLiquidity: BigNumber
'reserveA/reserveB': BigNumber
'reserveB/reserveA': BigNumber
'reserveA/reserveB': BigNumber | string
'reserveB/reserveA': BigNumber | string
tradeEnabled: boolean
ownerAddress: string
blockCommissionA: BigNumber
blockCommissionB: BigNumber
rewardPct: BigNumber
customRewards?: string[]
creationTx: string
creationHeight: number
creationHeight: BigNumber
}

interface PoolPairPagination {
Expand Down Expand Up @@ -81,20 +87,26 @@ interface PoolPairInfo {
status: boolean
idTokenA: string
idTokenB: string
dexFeePctTokenA?: BigNumber
dexFeeInPctTokenA?: BigNumber
dexFeeOutPctTokenA?: BigNumber
dexFeePctTokenB?: BigNumber
dexFeeInPctTokenB?: BigNumber
dexFeeOutPctTokenB?: BigNumber
reserveA: BigNumber
reserveB: BigNumber
commission: BigNumber
totalLiquidity: BigNumber
'reserveA/reserveB': BigNumber
'reserveB/reserveA': BigNumber
'reserveA/reserveB': BigNumber | string
'reserveB/reserveA': BigNumber | string
tradeEnabled: boolean
ownerAddress: string
blockCommissionA: BigNumber
blockCommissionB: BigNumber
rewardPct: BigNumber
customRewards?: string[]
creationTx: string
creationHeight: number
creationHeight: BigNumber
}
```

Expand Down
8 changes: 4 additions & 4 deletions docs/node/CATEGORIES/08-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ enum DfTxType {
interface AccountHistory {
owner: string
blockHeight: number
blockHash: string
blockTime: number
blockHash?: string
blockTime?: number
type: string
txn: number
txid: string
Expand Down Expand Up @@ -254,8 +254,8 @@ interface account {
interface AccountHistory {
owner: string
blockHeight: number
blockHash: string
blockTime: number
blockHash?: string
blockTime?: number
type: string
txn: number
txid: string
Expand Down
14 changes: 10 additions & 4 deletions docs/node/CATEGORIES/11-masternode.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ interface MasternodePagination {
interface MasternodeInfo {
ownerAuthAddress: string
operatorAuthAddress: string
rewardAddress: string
creationHeight: number
resignHeight: number
resignTx: string
banHeight: number
banTx: string
collateralTx: string
state: MasternodeState
mintedBlocks: number
ownerIsMine: boolean
operatorIsMine: boolean
localMasternode: boolean
targetMultiplier?: number
targetMultipliers?: number[]
timelock?: number
}

interface MasternodeResult<T> {
Expand Down Expand Up @@ -118,16 +121,19 @@ enum MasternodeState {
interface MasternodeInfo {
ownerAuthAddress: string
operatorAuthAddress: string
rewardAddress: string
creationHeight: number
resignHeight: number
resignTx: string
banHeight: number
banTx: string
collateralTx: string
state: MasternodeState
mintedBlocks: number
ownerIsMine: boolean
operatorIsMine: boolean
localMasternode: boolean
targetMultiplier?: number
targetMultipliers?: number[]
timelock?: number
}

interface MasternodeResult<T> {
Expand Down
7 changes: 1 addition & 6 deletions docs/node/CATEGORIES/16-loan.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,7 @@ List collateral tokens.

```ts title="client.loan.listCollateralTokens()"
interface loan {
listCollateralTokens (collateralToken: ListCollateralTokens = {}): Promise<CollateralTokenDetail[]>
}

interface ListCollateralTokens {
height?: number
all?: boolean
listCollateralTokens (): Promise<CollateralTokenDetail[]>
}

interface CollateralTokenDetail {
Expand Down
7 changes: 6 additions & 1 deletion docs/ocean/REFERENCES/poolpairs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ await api.poolpairs.list()
"displaySymbol": "dBTC",
"id": "2",
"reserve": "3755.6649905",
"blockCommission": "0"
"blockCommission": "0",
"fee": {
"pct": "0.001",
"inPct": "0.001",
"outPct": "0.001",
}
},
"tokenB": {
"symbol": "DFI",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,25 @@ describe('Account', () => {
const accounts: Array<AccountResult<AccountOwner, string>> = await testing.rpc.account.listAccounts()

const { owner } = accounts[0]
const { hex, addresses } = owner
const { hex } = owner

const accountHistories = await testing.rpc.account.listAccountHistory(hex)

const referenceHistory = accountHistories[0]

const history = await testing.rpc.account.getAccountHistory(hex, referenceHistory.blockHeight, referenceHistory.txn)
expect(history.owner).toStrictEqual(referenceHistory.owner)
expect(history.blockHeight).toStrictEqual(referenceHistory.blockHeight)
expect(history.txn).toStrictEqual(referenceHistory.txn)
expect(history.txid).toStrictEqual(referenceHistory.txid)
expect(history.type).toStrictEqual(referenceHistory.type)
expect(history.blockHash).toStrictEqual(referenceHistory.blockHash)
expect(history.blockTime).toStrictEqual(referenceHistory.blockTime)
expect(history.amounts).toStrictEqual(referenceHistory.amounts)
expect(addresses.includes(history.owner)).toStrictEqual(true)
expect(history).toStrictEqual(
{
owner: referenceHistory.owner,
blockHeight: referenceHistory.blockHeight,
blockHash: expect.stringMatching(/[0-f]{64}/),
blockTime: expect.any(Number),
txn: referenceHistory.txn,
txid: referenceHistory.txid,
amounts: referenceHistory.amounts,
type: 'MintToken'
}
)
})

it('should getAccountHistory with owner address', async () => {
Expand All @@ -57,14 +60,18 @@ describe('Account', () => {
const referenceHistory = accountHistories[0]

const history = await testing.rpc.account.getAccountHistory(referenceHistory.owner, referenceHistory.blockHeight, referenceHistory.txn)
expect(history.owner).toStrictEqual(referenceHistory.owner)
expect(history.blockHeight).toStrictEqual(referenceHistory.blockHeight)
expect(history.txn).toStrictEqual(referenceHistory.txn)
expect(history.txid).toStrictEqual(referenceHistory.txid)
expect(history.type).toStrictEqual(referenceHistory.type)
expect(history.blockHash).toStrictEqual(referenceHistory.blockHash)
expect(history.blockTime).toStrictEqual(referenceHistory.blockTime)
expect(history.amounts).toStrictEqual(referenceHistory.amounts)
expect(history).toStrictEqual(
{
owner: referenceHistory.owner,
blockHeight: referenceHistory.blockHeight,
blockHash: expect.stringMatching(/[0-f]{64}/),
blockTime: expect.any(Number),
txn: referenceHistory.txn,
txid: referenceHistory.txid,
amounts: referenceHistory.amounts,
type: 'MintToken'
}
)
})

it('should not getAccountHistory when address is not valid', async () => {
Expand Down
Loading

0 comments on commit ee0609e

Please sign in to comment.