events - Chai closeTo 谈以太坊活动
问题描述
我知道我们可以closeTo
像这样使用 chai matcher:
expect(BigNumber.from(100)).to.be.closeTo(BigNumber.from(101), 10);
我们可以测试一个事务是否发出带有特定参数的事件,如下所示:
await expect(contract.addAddress("street", "city")).to.emit(contract, 'AddAddress').withArgs("street", "city");
但是我们如何使用closeTo
匹配器to.emit.
来检查事务是否发出具有接近某个值的特定参数的事件?
参考:https ://ethereum-waffle.readthedocs.io/en/latest/matchers.html
解决方案
推荐阅读
- continuous-integration - 规则中无法识别 GitLab CI 自定义变量
- ios - WidgetKit:.timer 文本样式将其扩展以填充宽度,而不是占用空间以适应包含的字符串
- python - 使用 Slugify 时没有反向匹配
- rust - 默认情况下,Rust 闭包是堆栈分配的还是堆分配的?
- css - 图标无法居中
- python - Python OpenCV`ZeroDivisionError:在循环中浮点除以零
- node.js - NodeJS cookie expiration despite resave
- raku - 为什么调用 Raku 的不同方式会导致不同的启动时间?
- aws-lambda - 项目中缺少密钥 id [serverless framework + lambda + dynamodb]
- python - 是否有一种方法可以沿给定数组的轴获取所有成对差异?