Skip to content

Commit

Permalink
teardown chains (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Oct 30, 2023
1 parent 1c7c3ee commit 6191b00
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
7 changes: 3 additions & 4 deletions packages/e2e/src/author.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import networks from './networks'

describe('author rpc', async () => {
const { alice, bob } = testingPairs()
const acala = await networks.acala()
const { api, dev } = acala
const { api, dev, teardown } = await networks.acala()

await acala.dev.setStorage({
await dev.setStorage({
System: {
Account: [
[[alice.address], { data: { free: 10 * 1e12 } }],
Expand All @@ -22,7 +21,7 @@ describe('author rpc', async () => {
})

afterAll(async () => {
await acala.teardown()
await teardown()
})

it('works', async () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/src/batch-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import networks from './networks'

describe('Batch request', async () => {
const acala = await networks.acala()
const { chain, url } = acala
const { chain, url, teardown } = await networks.acala()
const wsClient = new WebSocket(url)

beforeAll(async () => {
Expand All @@ -16,7 +15,7 @@ describe('Batch request', async () => {

afterAll(async () => {
wsClient.close()
await acala.teardown()
await teardown()
})

it('batch getStorage', async () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/src/block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { delay } from './helper'
import networks from './networks'

describe('block', async () => {
const acala = await networks.acala()
const { chain, dev } = acala
const { chain, dev, teardown } = await networks.acala()

afterAll(async () => {
await acala.teardown()
await teardown()
})

it('upcoming block works', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/e2e/src/dev-dry-run-dmp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import networks from './networks'

describe('dev_dryRun dmp', () => {
it('works', async () => {
const acala = await networks.acala({
const { ws, teardown } = await networks.acala({
blockHash: '0x1d9223c88161b512ebaac53c2c7df6dc6bd2731b12273b898f582af929cc5331',
})
const params = [
Expand All @@ -19,7 +19,8 @@ describe('dev_dryRun dmp', () => {
],
},
]
const resp = await acala.ws.send('dev_dryRun', params)
const resp = await ws.send('dev_dryRun', params)
expect(resp.new.system.events).toMatchSnapshot()
await teardown()
})
})
11 changes: 5 additions & 6 deletions packages/e2e/src/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import networks from './networks'
describe('dev rpc', async () => {
const { alice, bob } = testingPairs()

const acala = await networks.acala()
const { api, dev, ws } = acala
const { api, chain, dev, ws, teardown } = await networks.acala()

await acala.dev.setStorage({
await dev.setStorage({
System: {
Account: [[[alice.address], { data: { free: 10 * 1e12 } }]],
},
Expand All @@ -20,7 +19,7 @@ describe('dev rpc', async () => {
})

afterAll(async () => {
await acala.teardown()
await teardown()
})

it('setStorage', async () => {
Expand Down Expand Up @@ -98,8 +97,8 @@ describe('dev rpc', async () => {
})

it('setHead', async () => {
const blockNumber = acala.chain.head.number
const hash = acala.chain.head.hash
const blockNumber = chain.head.number
const hash = chain.head.hash
await dev.newBlock({ count: 3 })
await dev.setHead(hash)
expect((await api.rpc.chain.getBlockHash()).toHex()).toBe(hash)
Expand Down
5 changes: 2 additions & 3 deletions packages/e2e/src/relaychain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { afterAll, describe, expect, it } from 'vitest'
import networks from './networks'

describe('relaychain dev rpc', async () => {
const polkadot = await networks.polkadot()
const { dev } = polkadot
const { dev, teardown } = await networks.polkadot()

afterAll(async () => {
await polkadot.teardown()
await teardown()
})

it('build blocks', async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/e2e/src/resume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ describe('resume', async () => {

await matchSnapshot(polkadot.api.query.system.account(alice.address))
await matchSystemEvents(polkadot)

await acala.teardown()
await polkadot.teardown()
})
})
})
5 changes: 2 additions & 3 deletions packages/e2e/src/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import networks from './networks'

describe('upgrade', async () => {
const { alice, bob } = testingPairs()
const acala = await networks.acala({
const { api, dev, chain, teardown } = await networks.acala({
blockNumber: 2000000,
})
const { api, dev, chain } = acala

afterAll(async () => {
await acala.teardown()
await teardown()
})

it('setCode works', async () => {
Expand Down

0 comments on commit 6191b00

Please sign in to comment.