Set up a testnet from scratch. To validate a manifest, we can first create a testnet with a [Materializer] that only creates symbolic resources.
(m: &mut R, name: &TestnetName, manifest: &Manifest)
| 96 | /// To validate a manifest, we can first create a testnet with a [Materializer] |
| 97 | /// that only creates symbolic resources. |
| 98 | pub async fn setup(m: &mut R, name: &TestnetName, manifest: &Manifest) -> anyhow::Result<Self> { |
| 99 | let mut t = Self::new(m, name).await?; |
| 100 | let root_name = t.root(); |
| 101 | |
| 102 | // Create keys for accounts. |
| 103 | for account_id in manifest.accounts.keys() { |
| 104 | t.create_account(m, account_id)?; |
| 105 | } |
| 106 | |
| 107 | // Create the rootnet. |
| 108 | t.create_and_start_rootnet(m, &root_name, &manifest.rootnet) |
| 109 | .await |
| 110 | .context("failed to create and start rootnet")?; |
| 111 | |
| 112 | // Recursively create and start all subnet nodes. |
| 113 | for (subnet_id, subnet) in &manifest.subnets { |
| 114 | t.create_and_start_subnet(m, &root_name, subnet_id, subnet) |
| 115 | .await |
| 116 | .with_context(|| format!("failed to create and start subnet {subnet_id}"))?; |
| 117 | } |
| 118 | |
| 119 | Ok(t) |
| 120 | } |
| 121 | |
| 122 | /// Return a reference to the physical network. |
| 123 | fn network(&self) -> &M::Network { |
nothing calls this directly
no test coverage detected