Skip to content

Commit

Permalink
Merge branch 'arshavir/port-overpayment_fail_test-to-pic' into 'master'
Browse files Browse the repository at this point in the history
chore(sns): Port `overpayment_fail_test` and `payment_flow_with_finalization_test ` to integration tests

This MR substitutes the SNS-related `overpayment_fail_test` and `payment_flow_with_finalization_test` system tests with integration tests.

| [Next MR in this series](https://gitlab.com/dfinity-lab/public/ic/-/merge_requests/20124) > 

See merge request dfinity-lab/public/ic!20192
  • Loading branch information
aterga committed Jul 3, 2024
2 parents 011cbe4 + 4a701a5 commit 599c1b3
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ impl CreateServiceNervousSystemBuilder {
self
}

pub fn with_minimum_participants(mut self, minimum_participants: u64) -> Self {
let swap_parameters = self.0.swap_parameters.as_mut().unwrap();
swap_parameters.minimum_participants = Some(minimum_participants);
self
}

pub fn build(self) -> CreateServiceNervousSystem {
self.0
}
Expand Down
54 changes: 52 additions & 2 deletions rs/nervous_system/integration_tests/src/pocket_ic_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,10 @@ pub mod sns {

pub mod root {
use super::*;
use ic_sns_root::pb::v1::ListSnsCanistersRequest;
use ic_sns_root::{
pb::v1::ListSnsCanistersRequest, GetSnsCanistersSummaryRequest,
GetSnsCanistersSummaryResponse,
};

pub fn list_sns_canisters(
pocket_ic: &PocketIc,
Expand All @@ -2018,6 +2021,30 @@ pub mod sns {
};
Decode!(&result, ListSnsCanistersResponse).unwrap()
}

pub fn get_sns_canisters_summary(
pocket_ic: &PocketIc,
sns_root_canister_id: PrincipalId,
) -> GetSnsCanistersSummaryResponse {
let result = pocket_ic
.update_call(
sns_root_canister_id.into(),
Principal::anonymous(),
"get_sns_canisters_summary",
Encode!(&GetSnsCanistersSummaryRequest {
update_canister_list: Some(false),
})
.unwrap(),
)
.unwrap();
let result = match result {
WasmResult::Reply(result) => result,
WasmResult::Reject(s) => {
panic!("Call to get_sns_canisters_summary failed: {:#?}", s)
}
};
Decode!(&result, GetSnsCanistersSummaryResponse).unwrap()
}
}

// Helper function that calls tick on env until either the index canister has synced all
Expand Down Expand Up @@ -2120,7 +2147,10 @@ pub mod sns {
use super::*;
use assert_matches::assert_matches;
use ic_nns_governance::pb::v1::create_service_nervous_system::SwapParameters;
use ic_sns_swap::{pb::v1::BuyerState, swap::principal_to_subaccount};
use ic_sns_swap::{
pb::v1::{BuyerState, GetOpenTicketRequest, GetOpenTicketResponse},
swap::principal_to_subaccount,
};
use icp_ledger::DEFAULT_TRANSFER_FEE;

pub fn get_init(pocket_ic: &PocketIc, canister_id: PrincipalId) -> GetInitResponse {
Expand Down Expand Up @@ -2236,6 +2266,26 @@ pub mod sns {
Ok(Decode!(&result, GetBuyerStateResponse).unwrap())
}

pub fn get_open_ticket(
pocket_ic: &PocketIc,
swap_canister_id: PrincipalId,
buyer: PrincipalId,
) -> Result<GetOpenTicketResponse, String> {
let result = pocket_ic
.query_call(
swap_canister_id.into(),
buyer.into(),
"get_open_ticket",
Encode!(&GetOpenTicketRequest {}).unwrap(),
)
.map_err(|err| err.to_string())?;
let result = match result {
WasmResult::Reply(result) => result,
WasmResult::Reject(s) => panic!("Call to get_open_ticket failed: {:#?}", s),
};
Ok(Decode!(&result, GetOpenTicketResponse).unwrap())
}

pub fn error_refund_icp(
pocket_ic: &PocketIc,
swap_canister_id: PrincipalId,
Expand Down
Loading

0 comments on commit 599c1b3

Please sign in to comment.