enzymefinance / protocol

Enzyme Protocol Implementation

Home Page:https://enzyme.finance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better assertions for `amguPayable` functions in tests

SeanJCasey opened this issue · comments

Right now, the amgu.test.js integration tests assert whether the actual amount of ETH charged for an amguPayable function is less than an estimated amount. The estimated amount calculation more-or-less mirrors the amguConsumer modifier code:

https://github.com/melonproject/protocol/blob/5780305a10b86a888a180b85e55957f57e13f1c7/tests/integration/amgu.test.js#L39

This needs to be more precise than greater than / less than, either:
A. [ideal] exact amounts
B. some tolerated % deviation from the estimate

Also, it would be nice to implement a calcAmguPayableInEther helper, which could be used by amguPayable and also for external estimations like our tests, for consistency...

@SeanJCasey we can't implement A because we can't calculate the exact gas cost of a function without its modifiers. For B, I think we can add one more assertion to check if estimatedEthToPay - realEthToPay is within the range of a deviation