Gathering detailed insights and metrics for @defichain/testcontainers
Gathering detailed insights and metrics for @defichain/testcontainers
DeFiChain Jellyfish SDK & Ecosystem for building modern lite DeFi Applications at scale.
npm install @defichain/testcontainers
Typescript
Module System
Node Version
NPM Version
60
Supply Chain
92.2
Quality
74.9
Maintenance
100
Vulnerability
96.1
License
TypeScript (99.77%)
JavaScript (0.13%)
Solidity (0.06%)
CSS (0.02%)
Dockerfile (0.01%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
461,564
Last Day
1
Last Week
344
Last Month
438
Last Year
83,964
MIT License
104 Stars
1,557 Commits
37 Forks
8 Watchers
122 Branches
46 Contributors
Updated on Jan 03, 2025
Minified
Minified + Gzipped
Latest Version
4.0.7
Package Id
@defichain/testcontainers@4.0.7
Unpacked Size
190.96 kB
Size
36.84 kB
File Count
78
NPM Version
8.19.4
Node Version
16.20.2
Published on
Feb 23, 2024
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
1,086.2%
344
Compared to previous week
Last Month
-59.6%
438
Compared to previous month
Last Year
-63.5%
83,964
Compared to previous year
2
2
Similar to testcontainers in the Java ecosystem, this package provides a lightweight,
throwaway instances of regtest
, testnet
or mainnet
provisioned automatically in Docker container.
@defichain/testcontainers
encapsulate on top of defi/defichain:v1.x
and directly interface with the Docker REST API.
With @defichain/testcontainers
, it allows the JS developers to:
@defichain/jellyfish-*
implementation with 100% day 1 compatibility (mono repo!)Install as dev only as you don't need this in production. Please don't use this in production!
1npm i defichain 2npm i -D @defichain/testcontainers
Use your favourite jest runner and start building dApps!
RegTestContainer
setup1import { RegTestDocker } from '@defichain/testcontainers' 2 3describe('reg test container', () => { 4 const container = new RegTestContainer() 5 6 beforeEach(async () => { 7 await container.start() 8 await container.waitForReady() 9 }) 10 11 afterEach(async () => { 12 await container.stop() 13 }) 14 15 it('should getmininginfo and chain should be regtest', async () => { 16 // Using node.call('method', []), the built-in minimalistic rpc call 17 const result = await container.call('getmininginfo', []) 18 expect(result.chain).toStrictEqual('regtest') 19 }) 20})
MasterNodeRegTestContainer
with auto-minting1import { MasterNodeRegTestContainer } from '@defichain/testcontainers' 2import waitForExpect from "wait-for-expect"; 3 4describe('master node pos minting', () => { 5 const container = new MasterNodeRegTestContainer() 6 7 beforeEach(async () => { 8 await container.start() 9 await container.waitForReady() 10 }) 11 12 afterEach(async () => { 13 await container.stop() 14 }) 15 16 it('should wait until coinbase maturity with spendable balance', async () => { 17 await container.waitForWalletCoinbaseMaturity() 18 19 await waitForExpect(async () => { 20 const info = await container.getMiningInfo() 21 expect(info.blocks).toBeGreaterThan(100) 22 }) 23 24 // perform utxostoaccount rpc 25 const address = await container.getNewAddress() 26 const payload: { [key: string]: string } = {} 27 payload[address] = "100@0" 28 await container.call("utxostoaccount", [payload]) 29 }) 30})
1const container = new MasterNodeRegTestContainer() 2const rpcURL = await container.getCachedRpcUrl() 3 4// they are dynmaically assigned to host, you can run multiple concurrent tests! 5const port = await container.getPort('8555/tcp')
container.call('method', [])
for convenience RPC calls1const container = new MasterNodeRegTestContainer() 2await container.start() 3await container.waitForReady() 4 5// raw universal calls 6const { blocks } = await container.call('getmininginfo') 7const address = await container.call('getnewaddress', ['label', 'legacy']) 8 9// basic included types 10const count = await container.getBlockCount() 11const info = await container.getMiningInfo() 12const newAddress = await container.getNewAddress()
No vulnerabilities found.
No security vulnerabilities found.