An emulator failure happens with no usable information when on the initial distribution one (or more) of the wallets contains a number of different tokens (other than ADA). According to the documentation, the minimum ADA value for UTxOs containing tokens are higher then ADA only UTxOs, but the function splitOffAdaOnlyValue in Wallet/Emulator/Wallet.hs does not take that into consideration, it only sets minAdaTxOut ADA to the non-ADA part.
Steps to reproduce the behavior
Create an emulator trace with initial distribution that contains a number of different token types (with long names and policyIds).
Run the trace.
Actual Result
The test fails with no details:
This must be replaced by the core-to-plc plugin during compilation: error
CallStack (from HasCallStack):
error, called at src/PlutusTx/Utils.hs:7:26 in plutus-tx-0.1.0.0-a375f22d0d8c7641a5b365b3c6ecf3be6ea8edd57bc0b7955fbc2d4c96139e5b:PlutusTx.Utils
Expected Result
The test succeeds, or reports a meaningful message about initial wallet distribution.
Summary
An emulator failure happens with no usable information when on the initial distribution one (or more) of the wallets contains a number of different tokens (other than ADA). According to the documentation, the minimum ADA value for UTxOs containing tokens are higher then ADA only UTxOs, but the function
splitOffAdaOnlyValue
in Wallet/Emulator/Wallet.hs does not take that into consideration, it only setsminAdaTxOut
ADA to the non-ADA part.Steps to reproduce the behavior
Actual Result
The test fails with no details:
Expected Result
The test succeeds, or reports a meaningful message about initial wallet distribution.
Describe the approach you would take to fix this
According to https://cardano-foundation-cardano.readthedocs-hosted.com/en/latest/native-tokens/minimum-ada-value-requirement.html, the required ADA value should be calculated with the same function as it is validated for on-chain.
System info
OS: NixOS Plutus-apps: v2022-04-06