Skip to content

Commit

Permalink
ENG-578: Try materialize a rootnet
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Feb 23, 2024
1 parent 4758f96 commit 9178e12
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions fendermint/testing/materializer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/testnets
8 changes: 8 additions & 0 deletions fendermint/testing/materializer/materializer-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"port_ranges": {
"testnets/test-root-only/root/nodes/node-1": {
"from": 0,
"to": 100
}
}
}
8 changes: 6 additions & 2 deletions fendermint/testing/materializer/src/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
M: Materials,
R: Materializer<M> + Sync + Send,
{
pub async fn new(m: &mut R, id: &TestnetId) -> anyhow::Result<Self> {
pub async fn new(m: &mut R, id: impl Into<TestnetId>) -> anyhow::Result<Self> {
let name = TestnetName::new(id);
let network = m
.create_network(&name)
Expand Down Expand Up @@ -82,7 +82,11 @@ where
///
/// To validate a manifest, we can first create a testnet with a [Materializer]
/// that only creates symbolic resources.
pub async fn setup(m: &mut R, id: &TestnetId, manifest: &Manifest) -> anyhow::Result<Self> {
pub async fn setup(
m: &mut R,
id: impl Into<TestnetId>,
manifest: &Manifest,
) -> anyhow::Result<Self> {
let mut t = Self::new(m, id).await?;
let root_name = t.root();

Expand Down
22 changes: 17 additions & 5 deletions fendermint/testing/materializer/tests/docker.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright 2022-2024 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT

use fendermint_testing_materializer::{
docker::DockerMaterializer,
manifest::{self, Manifest},
};
use std::{env::current_dir, time::Duration};

use fendermint_testing_materializer::{docker::DockerMaterializer, testnet::Testnet};

mod manifests {
use fendermint_testing_materializer::manifest::Manifest;
Expand All @@ -18,5 +17,18 @@ mod manifests {

#[tokio::test]
async fn test_root_only() {
let _manifest = manifests::parse_yaml(manifests::ROOT_ONLY);
let manifest = manifests::parse_yaml(manifests::ROOT_ONLY);

// The current directory should be this crate.
let root_dir = current_dir().unwrap().join("tests");
let mut materializer = DockerMaterializer::new(&root_dir, 0).unwrap();

let testnet = Testnet::setup(&mut materializer, "test-root-only", &manifest)
.await
.unwrap();

let node1 = testnet.root().node("node-1");
let _dnode1 = testnet.node(&node1).unwrap();

tokio::time::sleep(Duration::from_secs(60)).await;
}

0 comments on commit 9178e12

Please sign in to comment.