Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulator's ChainState produces an EmulatorState with empty WalletState Map #696

Open
catch-21 opened this issue Sep 5, 2022 · 1 comment
Labels
bug Something isn't working Tracked Issue is tracked in our internal backlog

Comments

@catch-21
Copy link
Contributor

catch-21 commented Sep 5, 2022

Summary

Using the Emulator's ChainState to produce an EmulatorState results in an empty WalletState Map. This is probably minor because there is agentState for this purpose, but still good to investigate.

Steps to reproduce the behavior

There is a commented out test to recreate this bug, see here. Please re-enable once fixed.

Actual Result

let trace :: Trace.EmulatorTrace () = do
        thisChainState <- Trace.chainState
        let traceBlockchain = thisChainState ^. chainNewestFirst
            traceEmulatorState = emulatorState traceBlockchain
            walletStateMap = traceEmulatorState ^. walletStates
            w1State = fromJust $ M.lookup w1 walletStateMap -- Fails here: Maybe.fromJust: Nothing

Expected Result

It is possible to get all TxOutRef for any wallet from Trace's ChainState.

Describe the approach you would take to fix this

No response

System info

a8540db

@catch-21 catch-21 added the bug Something isn't working label Sep 5, 2022
@koslambrou koslambrou added the Tracked Issue is tracked in our internal backlog label Sep 6, 2022
@berewt
Copy link
Contributor

berewt commented Oct 20, 2022

Indeed emulatorState only recreates the chainState of an EmulatorState. Its main purpose is to perform a partial initialisation of the EmulatorState when we start the emulator, not to provide access to the whole emulatorState.
Its behaviour is aligned with the behaviour of the other initializer: create the chain index and update the wallets through the EmulatorEvents. In this particular case, as we don't replay the events on the newly (re)created state, the wallet list is empty.

We have already discussed the need to clean up and clarify the API, especially to clarify which parts of it are public. I think it's a pretty good example of it. I suggest that we remove the test, close the bug and that we initiate an action item (epic or story (?)) about cleaning and clarifying the API.

berewt added a commit that referenced this issue Oct 25, 2022
* Fix the test(s) for bug 695

* Remove bug695 test

* Add solution to #695 to MustReferenceOutput / Remove #696 / harmonize tests

* Fix imports
kayvank pushed a commit that referenced this issue Oct 27, 2022
* Fix the test(s) for bug 695

* Remove bug695 test

* Add solution to #695 to MustReferenceOutput / Remove #696 / harmonize tests

* Fix imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Tracked Issue is tracked in our internal backlog
Projects
None yet
Development

No branches or pull requests

3 participants