Create a materializer with a directory where all the testnets can live next to each other.
(dir: &Path, seed: u64)
| 180 | /// Create a materializer with a directory where all the |
| 181 | /// testnets can live next to each other. |
| 182 | pub fn new(dir: &Path, seed: u64) -> anyhow::Result<Self> { |
| 183 | let docker = |
| 184 | Docker::connect_with_local_defaults().context("failed to connect to Docker")?; |
| 185 | |
| 186 | // Create a runtime for the execution of drop tasks. |
| 187 | let (drop_handle, drop_chute) = dropper::start(docker.clone()); |
| 188 | |
| 189 | // Read in the state if it exists, otherwise create a default one. |
| 190 | let state = import_json(dir.join(STATE_JSON_FILE_NAME)) |
| 191 | .context("failed to read state")? |
| 192 | .unwrap_or_default(); |
| 193 | |
| 194 | let m = Self { |
| 195 | dir: dir.into(), |
| 196 | rng: StdRng::seed_from_u64(seed), |
| 197 | docker, |
| 198 | drop_handle, |
| 199 | drop_chute, |
| 200 | state, |
| 201 | drop_policy: DropPolicy::default(), |
| 202 | }; |
| 203 | |
| 204 | m.save_state().context("failed to save state")?; |
| 205 | m.export_scripts().context("failed to export scripts")?; |
| 206 | |
| 207 | Ok(m) |
| 208 | } |
| 209 | |
| 210 | pub fn with_policy(mut self, policy: DropPolicy) -> Self { |
| 211 | self.drop_policy = policy; |
nothing calls this directly
no test coverage detected