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