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

StateServiceStore Fixture for unit tests #41

Open
merl111 opened this issue Nov 16, 2022 · 1 comment
Open

StateServiceStore Fixture for unit tests #41

merl111 opened this issue Nov 16, 2022 · 1 comment

Comments

@merl111
Copy link

merl111 commented Nov 16, 2022

Following our quick discussion on Discord:

It might come very handy if we could use a WorkNet instance in unit tests to test new features and upgrades with the actual data currently on the contract deployed to mainnet.

@devhawk
Copy link
Contributor

devhawk commented Nov 16, 2022

WorkNet sits on top of StateServiceStore + PersistentTrackingStore from the Neo Blockchain Toolkit Library. I think for test purposes, we could build an xuint fixture to enable the StateServiceStore to be shared across tests. Then, in a given test you could create a MemoryTrackingStore instance on top of the StateServiceStore provided by the fixture to enable a clean environment for each test.

// assuming a StateServiceStoreFixture injected as fixture test class field 
using var store = new MemoryTrackingStore(fixture.StateServiceStore);
using var snapshot = new SnapshotCache(store.GetSnapshot());

Note, StateServiceStore requires async initialization, and I'm not sure how to do that with xuint off the top of my head

@devhawk devhawk changed the title WorkNet integration for unit tests StateServiceStore Fixture for unit tests Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants