Skip to content

test: integration tests for ProxyRuntime#90

Open
lpahlavi wants to merge 4 commits intomainfrom
lpahlavi/defi-2643-proxy-int-tests
Open

test: integration tests for ProxyRuntime#90
lpahlavi wants to merge 4 commits intomainfrom
lpahlavi/defi-2643-proxy-int-tests

Conversation

@lpahlavi
Copy link
Contributor

@lpahlavi lpahlavi commented Mar 4, 2026

Add integration tests for the ProxyRuntime added in #84.

@lpahlavi lpahlavi requested a review from gregorydemay March 4, 2026 09:26
@lpahlavi lpahlavi marked this pull request as ready for review March 4, 2026 09:26
@lpahlavi lpahlavi requested a review from a team as a code owner March 4, 2026 09:26
Copy link
Contributor

@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 adding some int test! I have the impression we could simplify a few things.

use tower::BoxError;

#[derive(Debug, CandidType, Deserialize)]
pub struct InsufficientCyclesError {
Copy link
Contributor

Choose a reason for hiding this comment

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

understanding question: why this new error type, why not keep BoxError? The examples should be easy to read and my impression here is that this complexifies many examples. I think it's fine to have an example where we show the charging with the proxy, but I would a priori not touch existing examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of this new error type is that is implements CandidType so it can be returned by the canister in case insufficient cycles are passed. BoxError cannot implement CandidType.

As for the examples, I agree it makes sense to keep them as simple as possible, but I also feel like creating a whole new example just to show a different charging policy seems a little overkill... Potentially, inlining the make_http_post_request method could make the code easier to read.

let Setup {
env,
canister_id,
proxy_canister_id: _,
Copy link
Contributor

Choose a reason for hiding this comment

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

What if there is already a proxy canister id set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is test infrastructure code, so worst case we would install the proxy canister twice, but I added an assert to be safe.

}
}

pub fn canister(&self) -> Canister<MaybeProxyRuntime<'_>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

My impression is that we don't need another runtime implementation. We could have a dedicated proxy_canister method that returns a Canister<ProxyRuntime<PocketIcRuntime<'_>>> and call it in the specific test where we need it. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it's not the only way to go, but I also don't really like the idea of having to explicitly specifying whether to use the proxy or not when creating a Canister instance. IMO if the proxy canister is installed, it should be used by default.

Ideally, we would be able to box the runtime, but Runtime is not dyn-compatible due to the generics in its method signatures IIUC.

@lpahlavi lpahlavi requested a review from gregorydemay March 6, 2026 15:35
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