-
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.
feat(jellyfish-api-core): add getAnchorTeams to rpc_masternode (#923)
* add getAnchorTeams to rpc_masternode * edit spelling * remove redundant test * add in missing block generate
- Loading branch information
1 parent
74e2c02
commit d04d874
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
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
75 changes: 75 additions & 0 deletions
75
packages/jellyfish-api-core/__tests__/category/masternode/getAnchorTeams.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,75 @@ | ||
import { RegTestFoundationKeys } from '@defichain/jellyfish-network' | ||
import { TestingGroup } from '@defichain/jellyfish-testing' | ||
import { MasterNodeRegTestContainer } from '@defichain/testcontainers' | ||
|
||
describe('Masternode', () => { | ||
const tGroup = TestingGroup.create(1) | ||
|
||
beforeAll(async () => { | ||
await tGroup.start() | ||
}) | ||
|
||
afterAll(async () => { | ||
await tGroup.stop() | ||
}) | ||
|
||
it('should be empty when block is not 15', async () => { | ||
for (let i = 0; i < 14; i++) { | ||
await tGroup.get(0).generate(1) | ||
await tGroup.waitForSync() | ||
const blockNumber = await tGroup.get(0).rpc.blockchain.getBlockCount() | ||
expect(blockNumber).toBeLessThan(15) | ||
|
||
const anchorTeams = await tGroup.get(0).rpc.masternode.getAnchorTeams() | ||
expect(anchorTeams.auth).toHaveLength(0) | ||
expect(anchorTeams.confirm).toHaveLength(0) | ||
} | ||
}) | ||
|
||
it('should getAnchorTeams', async () => { | ||
await tGroup.get(0).container.waitForBlockHeight(14) // wait for block height nore than 14 | ||
const blockNumber = await tGroup.get(0).rpc.blockchain.getBlockCount() | ||
expect(blockNumber).toEqual(15) | ||
|
||
const anchorTeams = await tGroup.get(0).rpc.masternode.getAnchorTeams() | ||
expect(anchorTeams.auth).toStrictEqual([RegTestFoundationKeys[0].operator.address]) | ||
expect(anchorTeams.confirm).toStrictEqual([RegTestFoundationKeys[0].operator.address]) | ||
}) | ||
|
||
it('should getAnchorTeams correctly when a new anchor team has been added', async () => { | ||
// add another Test container | ||
const newTestContainer = new MasterNodeRegTestContainer(RegTestFoundationKeys[1]) | ||
await newTestContainer.start() | ||
|
||
await tGroup.add(newTestContainer) | ||
await tGroup.waitForSync() | ||
|
||
await tGroup.get(1).generate(15) | ||
await tGroup.waitForSync() | ||
const anchorTeams = await tGroup.get(1).rpc.masternode.getAnchorTeams() | ||
expect(anchorTeams.auth).toHaveLength(2) | ||
expect(anchorTeams.confirm).toHaveLength(2) | ||
expect(anchorTeams.auth).toEqual( | ||
expect.arrayContaining( | ||
[RegTestFoundationKeys[0].operator.address, | ||
RegTestFoundationKeys[1].operator.address] | ||
) | ||
) | ||
expect(anchorTeams.confirm).toEqual( | ||
expect.arrayContaining( | ||
[RegTestFoundationKeys[0].operator.address, | ||
RegTestFoundationKeys[1].operator.address] | ||
) | ||
) | ||
}) | ||
|
||
it('should getAnchorTeams correctly when blockheight is passed in', async () => { | ||
const anchorTeamsBeforeFirst = await tGroup.get(0).rpc.masternode.getAnchorTeams(14) | ||
expect(anchorTeamsBeforeFirst.auth).toHaveLength(0) | ||
expect(anchorTeamsBeforeFirst.confirm).toHaveLength(0) | ||
|
||
const anchorTeamsBeforeSecond = await tGroup.get(0).rpc.masternode.getAnchorTeams(29) | ||
expect(anchorTeamsBeforeSecond.auth).toStrictEqual([RegTestFoundationKeys[0].operator.address]) | ||
expect(anchorTeamsBeforeSecond.confirm).toStrictEqual([RegTestFoundationKeys[0].operator.address]) | ||
}) | ||
}) |
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