英文:
Using expectEvent with hardhat requires an argument of type `never`
问题
I get that this has the type const resp0: Truffle.TransactionResponse<never>
. Now when I want to test whether an event was triggered, I use
我了解,这具有类型 const resp0: Truffle.TransactionResponse<never>
。现在,当我想要测试事件是否已触发时,我使用
expectEvent(resp0, "AgentRedemptionInCollateral", { _amountUBA: fassets0 });
but it tells me the argument "AgentRedemptionInCollateral" is expected to be of type never
. How can I fix this?
但它告诉我参数 "AgentRedemptionInCollateral" 应该是类型 never
。我该如何修复这个问题?
The expectEvent
is imported as
expectEvent
是作为导入的:
import { expectEvent } from "@openzeppelin/test-helpers";
Is it a problem that a function emitting an event is in another contract that is getting called by collateralPool.
一个发出事件的函数位于 collateralPool 调用的另一个合同中,这是否有问题。
英文:
When I make a contract call with hardhat
const resp0 = await collateralPool.selfCloseExit(tokenShare0, true, TokenExitType.MINIMIZE_FEE_DEBT, "", { from: accounts[0] });
I get that this has the type const resp0: Truffle.TransactionResponse<never>
. Now when I want to test whether an event was triggered, I use
expectEvent(resp0, "AgentRedemptionInCollateral", { _amountUBA: fassets0 });
but it tells me the argument "AgentRedemptionInCollateral" is expected to be of type never
. How can I fix this? The expectEvent
is imported as
import { expectEvent } from "@openzeppelin/test-helpers";
Is it a problem that a function emitting an event is in another contract that is getting called by collateralPool.
答案1
得分: 1
在搜索在线内容时,我发现其他人在TypeScript中使用这个包时也遇到了问题。我认为最简单的解决方法是添加 // @ts-ignore
或者像这样调用函数 (expectEvent as any)(resp0, "AgentRedemptionInCollateral", { _amountUBA: fassets0 });
。
英文:
When searching online I found that other people are also experiencing problems with this package in typescript I think the easiest way to fix this is by adding // @ts-ignore
or by calling the function like (expectEvent as any)(resp0, "AgentRedemptionInCollateral, { _amountUBA: fassets0 });
答案2
得分: 0
问题似乎是事件是通过不同的合同触发的,而最初调用的合同不同。使用expectEvent.inTransaction
方法解决了这个问题。
英文:
The problem seemed to be that the event was triggered in a different contract, through the one that was called initially. Using method expectEvent.inTransaction
solved the problem.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论