Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- calculateDelta :: Value -> Lovelace -> Lovelace -> [Lovelace] -> Value
Documentation
:: Value | Expected delta of the test |
-> Lovelace | Initial value of the wallet before the test |
-> Lovelace | Final value of the wallet after the test |
-> [Lovelace] | Missing lovelace costs of outputs from |
-> Value |
Returns the calculated delta between initial and final values. Might be false positive.
The tests check if a wallet's funds are equal to some expected value at the end. Unfortunately, because of the adjustion of transactions, the outputs' costs change and it's hard to track these changes in the tests layer.
This function tries to check if the difference between final and initial values (realDelta
)
is a result of combination of operations between output's costs and the expected delta.
There is a risk when expected delta has only ada part and expected delta /= realDelta and realDelta is divisible by some delta from deltas, then we will return realDelta's ada. Which means that the test will pass but without strong confidence in wallets' funds consistency. For example, we expected -n, but there is n among deltas and realDelta is n, it is divisible by n, then the test will pass. So please be careful.