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
The reason I do this is because I want the most accurate emulation of what happens in production, with the Env being destroyed and recreated every transaction, and I don't think the common approach of mutating the sequence_number and timestamp without destroying the whole Env does that. In particular I want to ensure that:
events are cleared
the internal memory of the Host is cleared of all old Vals
Completely recreating the Env is the obvious way to ensure it's clean for the next transaction.
(If I really should not be destroying and recreating the Env during tests let me know, but it seems reasonable).
I have recently discovered that this doesn't do what I expect: with testutils configured Env::default (default_with_testutils) enables several configurations for convenience that Env::from_snapshot does not do. It seems that since from_snapshot is also a testutils function for creating an Env, it might be appropriate for it to do the same setup steps as Env::default.
In particular, Env::default turns on debug diagnostics and sets the prng seed; while Env::from_snapshot does not:
What problem does your feature solve?
In many of my tests I use snapshots to destroy and reconstruct the Env from scratch to simulate the advancement of time, e.g.
The reason I do this is because I want the most accurate emulation of what happens in production, with the Env being destroyed and recreated every transaction, and I don't think the common approach of mutating the sequence_number and timestamp without destroying the whole Env does that. In particular I want to ensure that:
Completely recreating the Env is the obvious way to ensure it's clean for the next transaction.
(If I really should not be destroying and recreating the Env during tests let me know, but it seems reasonable).
I have recently discovered that this doesn't do what I expect: with testutils configured Env::default (default_with_testutils) enables several configurations for convenience that Env::from_snapshot does not do. It seems that since from_snapshot is also a testutils function for creating an Env, it might be appropriate for it to do the same setup steps as Env::default.
In particular, Env::default turns on debug diagnostics and sets the prng seed; while Env::from_snapshot does not:
What would you like to see?
Env::from_snapshot should also turn on debug diagnostics and the prng.
What alternatives are there?
My assumptions here about how from_snapshot should work may just be wrong.
cc stellar/soroban-examples#286 (comment)
The text was updated successfully, but these errors were encountered: