Skip to content

Commit

Permalink
Update @defichain/testcontainers to 1.7.0 (#184)
Browse files Browse the repository at this point in the history
Co-authored-by: Fuxing Loh <[email protected]>
  • Loading branch information
monstrobishi and fuxingloh authored May 26, 2021
1 parent 159c913 commit 5c63ca0
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('masternode', () => {
expect(mn1.masternodestate).toStrictEqual('ENABLED')
expect(mn1.generate).toStrictEqual(true)
expect(mn1.mintedblocks).toStrictEqual(0)
expect(mn1.lastblockcreationattempt).toStrictEqual('0')
expect(mn1.lastblockcreationattempt).not.toStrictEqual('0')

expect(info.networkhashps).toBeGreaterThan(0)
expect(info.pooledtx).toStrictEqual(0)
Expand Down
12 changes: 8 additions & 4 deletions packages/jellyfish-api-core/__tests__/category/token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ describe('masternode', () => {
await client.token.updateToken(tokenDABCId, { mintable: false })
await container.generate(1)

const { [tokenDABCId]: tokenAfter } = await client.token.getToken(`DABC#${tokenDABCId}`)
expect(tokenAfter.mintable).toStrictEqual(false)
await waitForExpect(async () => {
const { [tokenDABCId]: tokenAfter } = await client.token.getToken(`DABC#${tokenDABCId}`)
expect(tokenAfter.mintable).toStrictEqual(false)
})
})

it('should updateToken by creationTx', async () => {
Expand All @@ -324,8 +326,10 @@ describe('masternode', () => {
await client.token.updateToken(creationTx, { tradeable: false })
await container.generate(1)

const { [tokenDABCId]: tokenAfter } = await client.token.getToken(`DABC#${tokenDABCId}`)
expect(tokenAfter.tradeable).toStrictEqual(false)
await waitForExpect(async () => {
const { [tokenDABCId]: tokenAfter } = await client.token.getToken(`DABC#${tokenDABCId}`)
expect(tokenAfter.tradeable).toStrictEqual(false)
})
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ beforeEach(async () => {
builder = new P2WPKHTransactionBuilder(providers.fee, providers.prevout, providers.elliptic)

// Fund 10 DFI TOKEN
await fundEllipticPair(container, providers.ellipticPair, 10)
await providers.setupMocks() // required to move utxos
await utxosToAccount(container, 10, { address: await providers.getAddress() })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ describe('DFI to DOG', () => {
})

it('should poolSwap from DFI to DOG', async () => {
// Fund 10 DFI UTXO
await fundEllipticPair(container, providers.ellipticPair, 10)
// Fund 10 DFI TOKEN
// Fund 100 DFI TOKEN
await providers.setupMocks() // required to move utxos
await utxosToAccount(container, 100, { address: await providers.getAddress() })
// Fund 10 DOG TOKEN
await sendTokensToAddress(container, await providers.getAddress(), 10, 'DOG')

// Fund 10 DFI UTXO
await fundEllipticPair(container, providers.ellipticPair, 10)

// Perform SWAP
const script = await providers.elliptic.script()
const txn = await builder.dex.poolSwap({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ beforeEach(async () => {
builder = new P2WPKHTransactionBuilder(providers.fee, providers.prevout, providers.elliptic)

// Fund 100 DFI TOKEN
await fundEllipticPair(container, providers.ellipticPair, 100)
await providers.setupMocks() // required to move utxos
await utxosToAccount(container, 100, { address: await providers.getAddress() })

Expand Down
6 changes: 3 additions & 3 deletions packages/testcontainers/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ describe('regtest', () => {
})

describe('regtest: override docker image', () => {
const container = new RegTestContainer('defi/defichain:1.6.0')
const container = new TestNetContainer('defi/defichain:1.6.4')

afterAll(async () => {
await container.stop()
})

it('should be able to getmintinginfo and chain should be regtest', async () => {
it('should be able to getmintinginfo and chain should be test', async () => {
await container.start()
await container.waitForReady()
const { chain } = await container.getMintingInfo()
expect(chain).toStrictEqual('regtest')
expect(chain).toStrictEqual('test')
})
})
2 changes: 1 addition & 1 deletion packages/testcontainers/src/chains/defid_container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface StartOptions {
export abstract class DeFiDContainer extends DockerContainer {
/* eslint-disable @typescript-eslint/no-non-null-assertion, no-void */
public static readonly PREFIX = 'defichain-testcontainers-'
public static readonly image = 'defi/defichain:1.6.4'
public static readonly image = 'defi/defichain:1.7.0'

public static readonly DefaultStartOptions = {
user: 'testcontainers-user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export class RegTestContainer extends DeFiDContainer {
'-bayfrontgardensheight=2',
'-clarkequayheight=3',
'-dakotaheight=4',
'-dakotacrescentheight=5'
'-dakotacrescentheight=5',
'-eunosheight=6'
]
}

Expand Down
1 change: 1 addition & 0 deletions packages/testing/__tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('accountToAccount', () => {
await mintTokens(container, symbol)

const to = await container.call('getnewaddress')
await container.fundAddress(from, 1)
await accountToAccount(container, symbol, 6, { from, to })

const accounts = await container.call('listaccounts')
Expand Down
7 changes: 5 additions & 2 deletions packages/testing/__tests__/poolpair.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
import { createToken, createPoolPair, addPoolLiquidity, mintTokens, utxosToAccount, removePoolLiquidity } from '../src'
import waitForExpect from 'wait-for-expect'

const container = new MasterNodeRegTestContainer()

Expand Down Expand Up @@ -60,7 +61,9 @@ describe('add/remove pool pair liquidity', () => {
tokenLP: 'DFI-LPT'
})

const shares: Record<string, any> = await container.call('listpoolshares')
expect(Object.keys(shares).length).toStrictEqual(0)
await waitForExpect(async () => {
const shares: Record<string, any> = await container.call('listpoolshares')
expect(Object.keys(shares).length).toStrictEqual(0)
})
})
})

0 comments on commit 5c63ca0

Please sign in to comment.