Issue with initialising mock wallet with native token in EmulatorTrace
bjing opened this issue · comments
Summary
When initialising EmulatorConfig
with wallets with only lovelace, it's fine, but as soon as I introduce native tokens, it throws error complaining about not being able to deserialise the policy ID of the token.
Here's the error message:
Test suite cardano-plutus-v2-test-test: RUNNING...
Test
Token deposit tests
Can deposit token into contract: FAIL
Cannot build the initial state: Tag "toCardanoPolicyId" (Tag "56 bytes" DeserialisationError)
CallStack (from HasCallStack):
error, called at src/Wallet/Emulator/Stream.hs:166:12 in plts-cntrct-1.0.0.0-989ebfa8:Wallet.Emulator.Stream
1 out of 1 tests failed (0.03s)
Test suite cardano-plutus-v2-test-test: FAIL
Here's the test code that will fail because of this: https://github.com/bjing/cardano-plutus-v2-test/blob/main/test/Spec/DepositTrace.hs
Steps to reproduce the behavior
- Enter nix shell through
plutus-apps
repo, make sure you are on commitd4255f05477fd8477ee9673e850ebb9ebb8c9657
on thenext-node
branch. - Check out repo: https://github.com/bjing/cardano-plutus-v2-test
- Run
cabal test
under the project.
Actual Result
Cannot build the initial state of the EmulatorTrace because of the following native token definition:
assetClass
(currencySymbol "5cb39e252088575b32ab13f235b18c0297b1e987185e2b27d9975999")
(tokenName "TokenName")
Expected Result
EmulatorTrace should not actually be doing checks on the policy id validity. it should just accept whatever string I throw at it as the policy id.
Even if it checks on policy id validity, it should be happy with the legit policy id I put in there.
Describe the approach you would take to fix this
No response
System info
OS: MacOS Monterey
Version: 12.6
Plutus apps branch: next-node
Plutus apps commit: d4255f0
The CurrencySymbol hash is too long.
> currencySymbol "5cb39e252088575b32ab13f235b18c0297b1e987185e2b27d9975999"
3563623339653235323038383537356233326162313366323335623138633032393762316539383731383565326232376439393735393939
> fromString "5cb39e252088575b32ab13f235b18c0297b1e987185e2b27d9975999" :: CurrencySymbol
5cb39e252088575b32ab13f235b18c0297b1e987185e2b27d9975999
Try using fromString
when defining your CurrencySymbol.
Oh wow, thanks so much for taking the time to look at this. Of course I was doing it wrong!
🙇♂️ .