Skip to content

Conversation

@lpahlavi
Copy link
Contributor

@lpahlavi lpahlavi commented Nov 4, 2025

Add ic-canister-runtime crate whose Runtime trait abstracts the canister runtime and allows code making calls to canister to be re-used:

  • in production using ic_cdk,
  • in unit tests by mocking this trait,
  • in integration tests by implementing this trait for PocketIc.

@lpahlavi lpahlavi changed the title feat: create canruntime crate feat: add ic-canister-runtime crate Nov 5, 2025
@lpahlavi lpahlavi force-pushed the lpahlavi/create-runtime-crate branch from 4fa36b1 to 9824002 Compare November 5, 2025 13:37
@lpahlavi lpahlavi force-pushed the lpahlavi/create-runtime-crate branch from 9824002 to 022551c Compare November 5, 2025 13:58
@lpahlavi lpahlavi requested a review from gregorydemay November 5, 2025 13:59
@lpahlavi lpahlavi marked this pull request as ready for review November 5, 2025 13:59
@lpahlavi lpahlavi requested a review from a team as a code owner November 5, 2025 13:59
Copy link
Collaborator

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @lpahlavi ! Some minor comments.


/// Runtime when interacting with a canister running on the Internet Computer.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct IcRuntime;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the risk of breaking change, let's ensure that this runtime can only be instantiated by a constructor (new() + Default). I could envision that in the future we sometimes don't always want to use unbounded_wait.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I added an unused private field to make sure it can only be instantiated with new or default now.

@lpahlavi
Copy link
Contributor Author

lpahlavi commented Nov 6, 2025

Thanks a lot for the feedback @gregorydemay! Your comments have been addressed.

@lpahlavi lpahlavi requested a review from gregorydemay November 6, 2025 08:11
@lpahlavi lpahlavi merged commit 5395674 into main Nov 6, 2025
9 checks passed
@lpahlavi lpahlavi deleted the lpahlavi/create-runtime-crate branch November 6, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants