-
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 masternode clearMempool RPC (#1801)
What this PR does / why we need it: /kind feature Which issue(s) does this PR fixes?: Fixes part of #48 - Implements `clearmempool` type for RPC.
- Loading branch information
1 parent
02d87fc
commit 48dd22b
Showing
3 changed files
with
47 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
30 changes: 30 additions & 0 deletions
30
packages/jellyfish-api-core/__tests__/category/masternode/clearMempool.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,30 @@ | ||
import { MasterNodeRegTestContainer } from '@defichain/testcontainers' | ||
import { Testing } from '@defichain/jellyfish-testing' | ||
|
||
describe('clear mempool', () => { | ||
const container = new MasterNodeRegTestContainer() | ||
const testing = Testing.create(container) | ||
|
||
beforeAll(async () => { | ||
await testing.container.start() | ||
await testing.container.waitForWalletCoinbaseMaturity() | ||
}) | ||
|
||
afterAll(async () => { | ||
await testing.container.stop() | ||
}) | ||
|
||
it('should clear mempool and return the removed transaction ids', async () => { | ||
const createdTxId = await testing.rpc.wallet.sendToAddress('mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU', 0.003) | ||
|
||
const txIdsInMempoolBefore = await testing.rpc.blockchain.getRawMempool(false) | ||
expect(txIdsInMempoolBefore.length).toStrictEqual(1) | ||
|
||
const removedTxIds = await testing.rpc.masternode.clearMempool() | ||
|
||
expect(removedTxIds).toContain(createdTxId) | ||
|
||
const txIdsInMempoolAfter = await testing.rpc.blockchain.getRawMempool(false) | ||
expect(txIdsInMempoolAfter.length).toStrictEqual(0) | ||
}) | ||
}) |
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