You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an audit I ended up using a function like the following to test the final ledger state of a trace.
--| Assert success of a validator where wallets are holding the given-- amounts of a certain tokenassertSuccessWithTokens::
(C.IsPropprop, Showa) =>C.InitialDistribution->
[(C.Wallet, Pl.AssetClass, Integer)] ->C.StagedMockChaina->prop
assertSuccessWithTokens dst xs =C.testSucceedsFrom'
( \_ s -> (`C.testAll` xs) $\(w, ac, i) ->let actual =Value.assetClassValueOf (holdingInState s w) ac
in testBoolMsg (message w ac i actual) $ actual == i
)
dst
where
message w ac i actual ="Expected wallet "<> walletString w
<>" to hold "<>show i
<>" of token "<>show ac
<>" but found "<>show actual
walletString w = fromMaybe "unknown" (CW.mwPrintAs w)
This function is helpful when using tokens other than ada. With ada is harder to guess the exact amounts since they depend on the fees that have been charged.
To deal with Ada, maybe the above function could be generalized to receive predicates for each token
The text was updated successfully, but these errors were encountered:
facundominguez
changed the title
Add a function to test specific values on the final ledger state
Add a function to test for specific tokens and wallets on the final ledger state
Mar 13, 2023
In an audit I ended up using a function like the following to test the final ledger state of a trace.
This function is helpful when using tokens other than ada. With ada is harder to guess the exact amounts since they depend on the fees that have been charged.
To deal with Ada, maybe the above function could be generalized to receive predicates for each token
The text was updated successfully, but these errors were encountered: