-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added getGov and setGov * update masternode.md
- Loading branch information
1 parent
da1f467
commit bc99c1d
Showing
6 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/jellyfish-api-core/__tests__/category/masternode/getGov.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BigNumber, RpcApiError } from '@defichain/jellyfish-api-core' | ||
import { MasterNodeRegTestContainer } from '@defichain/testcontainers' | ||
import { createPoolPair, createToken } from '@defichain/testing' | ||
import { ContainerAdapterClient } from '../../container_adapter_client' | ||
|
||
describe('Masternode', () => { | ||
const container = new MasterNodeRegTestContainer() | ||
const client = new ContainerAdapterClient(container) | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
await container.waitForReady() | ||
await container.waitForWalletCoinbaseMaturity() | ||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
it('should getGov LP_DAILY_DFI_REWARD', async () => { | ||
const gov = await client.masternode.getGov('LP_DAILY_DFI_REWARD') | ||
expect(gov.LP_DAILY_DFI_REWARD instanceof BigNumber).toStrictEqual(true) | ||
}) | ||
|
||
it('should getGov LP_SPLITS', async () => { | ||
await createToken(container, 'CAT') | ||
await createToken(container, 'DOG') | ||
await createPoolPair(container, 'CAT', 'DFI') | ||
await createPoolPair(container, 'DOG', 'DFI') | ||
|
||
const hash = await client.masternode.setGov({ LP_SPLITS: { 3: 0.2, 4: 0.8 } }) | ||
expect(hash.length).toStrictEqual(64) | ||
await container.generate(1) | ||
|
||
const gov = await client.masternode.getGov('LP_SPLITS') | ||
expect(gov.LP_SPLITS['3'].toString()).toStrictEqual('0.2') | ||
expect(gov.LP_SPLITS['4'].toString()).toStrictEqual('0.8') | ||
}) | ||
|
||
it('should be failed as variable REWARD is not registered', async () => { | ||
const promise = client.masternode.getGov('REWARD') | ||
await expect(promise).rejects.toThrow(RpcApiError) | ||
await expect(promise).rejects.toThrow('Variable \'REWARD\' not registered') | ||
}) | ||
}) |
42 changes: 42 additions & 0 deletions
42
packages/jellyfish-api-core/__tests__/category/masternode/setGov.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { RpcApiError } from '@defichain/jellyfish-api-core' | ||
import { MasterNodeRegTestContainer } from '@defichain/testcontainers' | ||
import { createPoolPair, createToken } from '@defichain/testing' | ||
import { ContainerAdapterClient } from '../../container_adapter_client' | ||
|
||
describe('Masternode', () => { | ||
const container = new MasterNodeRegTestContainer() | ||
const client = new ContainerAdapterClient(container) | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
await container.waitForReady() | ||
await container.waitForWalletCoinbaseMaturity() | ||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
it('should setGov LP_SPLITS', async () => { | ||
const govBefore = await client.masternode.getGov('LP_SPLITS') | ||
expect(Object.keys(govBefore.LP_SPLITS).length).toStrictEqual(0) | ||
|
||
await createToken(container, 'CAT') | ||
await createToken(container, 'DOG') | ||
await createPoolPair(container, 'CAT', 'DFI') | ||
await createPoolPair(container, 'DOG', 'DFI') | ||
|
||
await client.masternode.setGov({ LP_SPLITS: { 3: 0.2, 4: 0.8 } }) | ||
await container.generate(1) | ||
|
||
const govAfter = await client.masternode.getGov('LP_SPLITS') | ||
expect(govAfter.LP_SPLITS['3'].toString()).toStrictEqual('0.2') | ||
expect(govAfter.LP_SPLITS['4'].toString()).toStrictEqual('0.8') | ||
}) | ||
|
||
it('should be failed to setGov LP_REWARD as manually set after Eunos hard fork is not allowed', async () => { | ||
const promise = client.masternode.setGov({ LP_DAILY_DFI_REWARD: 999.00293001 }) | ||
await expect(promise).rejects.toThrow(RpcApiError) | ||
await expect(promise).rejects.toThrow('LP_DAILY_DFI_REWARD: Cannot be set manually after Eunos hard fork') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters