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

Fix/new gas price #104

Merged
merged 3 commits into from
Nov 21, 2022
Merged
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
36 changes: 32 additions & 4 deletions zp-relayer/test/worker-tests/poolWorker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ describe('poolWorker', () => {
let snapShotId: string
let eventsInit = false

before(async () => {})

beforeEach(async () => {
snapShotId = await evmSnapshot()

Expand Down Expand Up @@ -153,7 +151,7 @@ describe('poolWorker', () => {
await mintTokens(deposit.txTypeData.from as string, parseInt(deposit.txTypeData.amount))
await sentWorker.pause()

const mockPoolWorker = await createPoolTxWorker(gasPriceService, async () => {}, workerMutex, newConnection())
const mockPoolWorker = await createPoolTxWorker(gasPriceService, async () => { }, workerMutex, newConnection())
mockPoolWorker.run()
await mockPoolWorker.waitUntilReady()

Expand Down Expand Up @@ -182,7 +180,7 @@ describe('poolWorker', () => {
const [status2, , rescheduledIds2] = await sentJob2.waitUntilFinished(sentQueueEvents)
expect(status2).eq(SentTxState.REVERT)
expect(rescheduledIds2.length).eq(0)

const poolJob3 = (await poolTxQueue.getJob(rescheduledIds1[0])) as Job
const [[, sentId3]] = await poolJob3.waitUntilFinished(poolQueueEvents)
expect(await pool.state.jobIdsMapping.get(poolJob2.id as string)).eq(poolJob3.id)
Expand Down Expand Up @@ -224,4 +222,34 @@ describe('poolWorker', () => {

await expect(job.waitUntilFinished(poolQueueEvents)).rejectedWith('Incorrect root at index')
})

it('should increase gas price on re-send', async () => {
const deposit = flow[0]
await mintTokens(deposit.txTypeData.from as string, parseInt(deposit.txTypeData.amount))
await disableMining()

// @ts-ignore
const job = await submitJob(deposit)

const [[txHash, sentId]] = await job.waitUntilFinished(poolQueueEvents)
expect(txHash.length).eq(66)

const txBefore = await web3.eth.getTransaction(txHash)
const gasPriceBefore = Number(txBefore.gasPrice)

sentWorker.on('progress', async () => {
await enableMining()
})

const sentJob = (await sentTxQueue.getJob(sentId)) as Job
const [status, sentHash,] = await sentJob.waitUntilFinished(sentQueueEvents)
expect(status).eq(SentTxState.MINED)
expect(txHash).not.eq(sentHash)

const txAfter = await web3.eth.getTransaction(sentHash)
const gasPriceAfter = Number(txAfter.gasPrice)
console.log(gasPriceBefore + ' < ' + gasPriceAfter)

expect(gasPriceBefore).lt(gasPriceAfter)
})
})