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

blockchain.getRawMempool, wallet.getNewAddress, wallet.getAddressInfo, wallet.validateAddress, wallet.listAddressGroupings, wallet.getWalletInfo, wallet.setWalletFlag, wallet.sendToAddress, wallet.createWallet #112

Merged
merged 15 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RegTestContainer, MasterNodeRegTestContainer } from '@defichain/testcontainers'
import { ContainerAdapterClient } from '../container_adapter_client'
import waitForExpect from 'wait-for-expect'
import { BigNumber, Block, Transaction } from '../../src'
import { BigNumber, Block, MempoolTx, Transaction, WalletFlag } from '../../src'

describe('non masternode', () => {
const container = new RegTestContainer()
Expand Down Expand Up @@ -50,6 +50,7 @@ describe('masternode', () => {
beforeAll(async () => {
await container.start()
await container.waitForReady()
await container.waitForWalletCoinbaseMaturity()
})

afterAll(async () => {
Expand Down Expand Up @@ -198,4 +199,67 @@ describe('masternode', () => {
expect(txOut.coinbase).toBe(true)
})
})

describe('getRawMempool', () => {
let transactionId = ''

beforeAll(async () => {
await client.wallet.setWalletFlag(WalletFlag.AVOID_REUSE)
transactionId = await client.wallet.sendToAddress('mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU', 0.00001)
})

it('should getRawMempool and return array of transaction ids', async () => {
const rawMempool: string[] = await client.blockchain.getRawMempool(false)

expect(rawMempool.length > 0).toBe(true)
expect(typeof rawMempool[0]).toBe('string')
})

it('should getRawMempool and return json object', async () => {
const rawMempool: MempoolTx = await client.blockchain.getRawMempool(true)

const data = rawMempool[transactionId]
expect(data.fees.base instanceof BigNumber).toBe(true)
expect(data.fees.modified instanceof BigNumber).toBe(true)
expect(data.fees.ancestor instanceof BigNumber).toBe(true)
expect(data.fees.descendant instanceof BigNumber).toBe(true)
expect(data.fees.base.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.fees.modified.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.fees.ancestor.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.fees.descendant.isGreaterThan(new BigNumber('0'))).toBe(true)

expect(data.fee instanceof BigNumber).toBe(true)
expect(data.fee.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.modifiedfee instanceof BigNumber).toBe(true)
expect(data.modifiedfee.isGreaterThan(new BigNumber('0'))).toBe(true)

expect(data.vsize instanceof BigNumber).toBe(true)
expect(data.weight instanceof BigNumber).toBe(true)
expect(data.height instanceof BigNumber).toBe(true)
expect(data.time instanceof BigNumber).toBe(true)
expect(data.vsize.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.weight.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.height.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.time.isGreaterThan(new BigNumber('0'))).toBe(true)

expect(typeof data.wtxid).toBe('string')
expect(data.depends.length >= 0).toBe(true)
expect(data.spentby.length >= 0).toBe(true)
expect(data['bip125-replaceable']).toBe(false)

expect(data.descendantcount instanceof BigNumber).toBe(true)
expect(data.descendantsize instanceof BigNumber).toBe(true)
expect(data.descendantfees instanceof BigNumber).toBe(true)
expect(data.descendantcount.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.descendantsize.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.descendantfees.isGreaterThan(new BigNumber('0'))).toBe(true)

expect(data.ancestorcount instanceof BigNumber).toBe(true)
expect(data.ancestorsize instanceof BigNumber).toBe(true)
expect(data.ancestorfees instanceof BigNumber).toBe(true)
expect(data.ancestorcount.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.ancestorsize.isGreaterThan(new BigNumber('0'))).toBe(true)
expect(data.ancestorfees.isGreaterThan(new BigNumber('0'))).toBe(true)
})
})
})
Loading