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

feat(PocketIC): management canister types module #2140

Merged
merged 2 commits into from
Oct 21, 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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/pocket-ic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ DEPENDENCIES = [
"@crate_index//:candid",
"@crate_index//:hex",
"@crate_index//:ic-agent",
"@crate_index//:ic-cdk",
"@crate_index//:ic-transport-types",
"@crate_index//:reqwest",
"@crate_index//:schemars",
Expand Down
1 change: 1 addition & 0 deletions packages/pocket-ic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- The type `Topology` becomes a struct with two fields: `subnet_configs` contains an association of subnet ids to their configurations
and `default_effective_canister_id` contains a default effective canister id for canister creation.
- Management canister types are defined in a new `management_canister` module to avoid a dependency on `ic-cdk`.



Expand Down
3 changes: 1 addition & 2 deletions packages/pocket-ic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ edition.workspace = true

[dependencies]
base64 = { workspace = true }
candid = "^0.10.2"
candid = { workspace = true }
hex = { workspace = true }
ic-agent = { workspace = true }
ic-cdk = { workspace = true }
ic-transport-types = { workspace = true }
reqwest = { workspace = true }
schemars = "0.8.16"
Expand Down
2 changes: 1 addition & 1 deletion packages/pocket-ic/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Here is a sketch of a test for a canister making canister HTTP outcalls in the l
#[tokio::test]
async fn test_canister_http_live() {
use candid::{Decode, Encode, Principal};
use ic_cdk::api::management_canister::http_request::HttpResponse;
use pocket_ic::management_canister::HttpRequestResult;
use ic_utils::interfaces::ManagementCanister;

let mut pic = PocketIcBuilder::new()
Expand Down
7 changes: 4 additions & 3 deletions packages/pocket-ic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ use crate::common::rest::{
InstanceId, MockCanisterHttpResponse, RawEffectivePrincipal, RawMessageId, SubnetId,
SubnetKind, SubnetSpec, Topology,
};
pub use crate::management_canister::CanisterSettings;
use crate::management_canister::{CanisterId, CanisterStatusResult};
use crate::nonblocking::PocketIc as PocketIcAsync;
use candid::{
decode_args, encode_args,
utils::{ArgumentDecoder, ArgumentEncoder},
Principal,
};
pub use ic_cdk::api::management_canister::main::CanisterSettings;
use ic_cdk::api::management_canister::main::{CanisterId, CanisterStatusResponse};
use ic_transport_types::SubnetMetrics;
use reqwest::Url;
use schemars::JsonSchema;
Expand All @@ -66,6 +66,7 @@ use tokio::runtime::Runtime;
use tracing::{instrument, warn};

pub mod common;
pub mod management_canister;
pub mod nonblocking;

const EXPECTED_SERVER_VERSION: &str = "pocket-ic-server 6.0.0";
Expand Down Expand Up @@ -668,7 +669,7 @@ impl PocketIc {
&self,
canister_id: CanisterId,
sender: Option<Principal>,
) -> Result<CanisterStatusResponse, CallError> {
) -> Result<CanisterStatusResult, CallError> {
let runtime = self.runtime.clone();
runtime.block_on(async { self.pocket_ic.canister_status(canister_id, sender).await })
}
Expand Down
Loading