OpenBazaar / mason

A tool for building OpenBazaar simulations, models, and test applications.
MIT License
0 stars 3 forks source link

Runner can freeze and restore openbazaar-go configuration #2

Open placer14 opened 5 years ago

placer14 commented 5 years ago

Some test scenarios will require the configuration state to be recoverable from a previous point of execution (for example: when providing a copy of the data directory to a running node instead of allowing the original to be manipulated, giving each test instance its own copy of dependent data to work on). Update samulator (cmd/main) to accept an optional flag to allow the buyer, vendor and/or moderator configuration to be rolled back to their original state before exiting.

Implementation details:

placer14 commented 5 years ago

Thinking that this will follow a database transaction pattern, where you can do the following:

r := &OpenBazaarRunner{}
r.SetNodeStatePath(path)
err := r.NodeState().BeginTransaction() // create a copy of the state, and silently use the copy instead
...do some things with the runner...then later...
err := r.NodeState().RollbackTransaction() // throw away the copy, and make a new one based on the source
...or you can...
err := r.NodeState().CommitTransaction() // throw away the source and replace with the current copy