Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list cell ids #107

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/admin_websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ impl AdminWebsocket {
}
}

pub async fn list_cell_ids(&self) -> ConductorApiResult<Vec<CellId>> {
let response = self.send(AdminRequest::ListCellIds).await?;
match response {
AdminResponse::CellIdsListed(cell_ids) => Ok(cell_ids),
_ => unreachable!("Unexpected response {:?}", response),
}
}

pub async fn get_dna_definition(&self, hash: DnaHash) -> ConductorApiResult<DnaDef> {
let msg = AdminRequest::GetDnaDefinition(Box::new(hash));
let response = self.send(msg).await?;
Expand Down
35 changes: 35 additions & 0 deletions tests/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,38 @@ async fn agent_info() {
assert_eq!(agent_infos.len(), 3);
assert!(agent_infos.contains(&other_agent));
}

#[tokio::test(flavor = "multi_thread")]
async fn list_cell_ids() {
let conductor = SweetConductor::from_standard_config().await;
let admin_port = conductor.get_arbitrary_admin_websocket_port().unwrap();
let admin_ws = AdminWebsocket::connect(format!("127.0.0.1:{}", admin_port))
.await
.unwrap();
let app_id: InstalledAppId = "test-app".into();
let agent_key = admin_ws.generate_agent_pub_key().await.unwrap();
let app_info = admin_ws
.install_app(InstallAppPayload {
agent_key: Some(agent_key),
installed_app_id: Some(app_id.clone()),
existing_cells: HashMap::new(),
membrane_proofs: Some(HashMap::new()),
network_seed: None,
source: AppBundleSource::Path(PathBuf::from("./fixture/test.happ")),
ignore_genesis_failure: false,
})
.await
.unwrap();
admin_ws.enable_app(app_id).await.unwrap();
let cell_id =
if let CellInfo::Provisioned(cell) = &app_info.cell_info.get(ROLE_NAME).unwrap()[0] {
cell.cell_id.clone()
} else {
panic!("expected provisioned cell");
};

let cell_ids = admin_ws.list_cell_ids().await.unwrap();
// Check if list includes cell id. Not checking for equality to a vector of just the one cell id,
// because the DPKI cell is included too.
assert!(cell_ids.contains(&cell_id));
}
Loading