Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Fixed test error
Browse files Browse the repository at this point in the history
  • Loading branch information
jimni1222 committed Jun 27, 2022
1 parent 62a71b5 commit e0a488b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/caver-core-method/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const buildSendFunc = (method, isSendTx) => async (...args) => {

// The TxTypeEthereumDynamicFee transaction does not use the gasPrice field,
// so we need to check `maxPriorityFeePerGas` and `maxFeePerGas` field instead of `gasPrice`.
const isDynamicFeeTx = payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee
const isDynamicFeeTx = isSendTx && (payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee)
const filledDynamicGasFeeTx =
isDynamicFeeTx && payload.params[0].maxPriorityFeePerGas !== undefined && payload.params[0].maxFeePerGas !== undefined

Expand Down
13 changes: 9 additions & 4 deletions test/packages/caver.transaction/ethereumDynamicFee.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ describe('TxTypeEthereumDynamicFee', () => {

await tx.fillTransaction()
expect(getMaxPriorityFeePerGasSpy).to.have.been.calledOnce
expect(getHeaderByNumberSpy).to.have.been.calledOnce
expect(getHeaderByNumberSpy).not.to.have.been.calledOnce // getHeader only when maxFeePerGas is empty to get baseFee.
expect(getNonceSpy).not.to.have.been.calledOnce
expect(getChainIdSpy).not.to.have.been.calledOnce
}).timeout(200000)
Expand All @@ -915,9 +915,14 @@ describe('TxTypeEthereumDynamicFee', () => {
transactionObj.nonce = '0x3a'
delete transactionObj.maxFeePerGas
const tx = caver.transaction.ethereumDynamicFee.create(transactionObj)
const expectedMaxFeePerGas = utils.toHex(
utils.hexToNumber(baseFee) * 2 + utils.hexToNumber(transactionObj.maxPriorityFeePerGas)
)

let expectedMaxFeePerGas
const latestHeader = await caver.rpc.klay.getHeaderByNumber('latest')
if (latestHeader.baseFeePerGas && caver.utils.hexToNumber(latestHeader.baseFeePerGas) > 0) {
expectedMaxFeePerGas = caver.utils.toHex(caver.utils.hexToNumber(latestHeader.baseFeePerGas) * 2)
} else {
expectedMaxFeePerGas = await caver.rpc.klay.getGasPrice()
}

await tx.fillTransaction()

Expand Down

0 comments on commit e0a488b

Please sign in to comment.