Skip to content

Commit

Permalink
Fix test_revoke_invalid_case
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Nov 5, 2024
1 parent 57167b4 commit 2d687be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
6 changes: 0 additions & 6 deletions src/dns_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ mod test {
#[test]
fn test_dns_client_gmail() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -339,7 +338,6 @@ mod test {
#[test]
fn test_dns_client_expect_error_no_answer() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -421,7 +419,6 @@ mod test {
#[test]
fn test_dns_client_expect_error_invalid_key_type() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -511,7 +508,6 @@ mod test {
#[test]
fn test_dns_client_expect_error_invalid_base64_format() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -601,7 +597,6 @@ mod test {
#[test]
fn test_dns_client_expect_error_invalid_selector() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -650,7 +645,6 @@ mod test {
#[test]
fn test_dns_client_expect_error_invalid_domain() {
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down
37 changes: 29 additions & 8 deletions src/ic_dns_oracle_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ mod test {
fn test_sign_gmail() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -889,7 +888,6 @@ mod test {
fn test_sign_gappssmtp() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -1042,7 +1040,6 @@ mod test {
fn test_revoke_valid_case() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -1226,7 +1223,6 @@ mod test {
fn test_revoke_valid_case_gappssmtp() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -1442,11 +1438,9 @@ mod test {
}

#[test]
#[should_panic]
fn test_revoke_invalid_case() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down Expand Up @@ -1567,14 +1561,41 @@ mod test {
additional_responses: vec![],
};
pic.mock_canister_http_response(mock_canister_http_response);
pic.await_call(call_id).unwrap();

pic.tick();
pic.tick();
pic.tick();
let canister_http_requests: Vec<pocket_ic::common::rest::CanisterHttpRequest> =
pic.get_canister_http();
assert_eq!(canister_http_requests.len(), 1);
let canister_http_request = &canister_http_requests[0];
let mock_canister_http_response = MockCanisterHttpResponse {
subnet_id: canister_http_request.subnet_id,
request_id: canister_http_request.request_id,
response: CanisterHttpResponse::CanisterHttpReply(CanisterHttpReply {
status: 200,
headers: vec![],
body: body.as_bytes().to_vec(),
}),
additional_responses: vec![],
};
pic.mock_canister_http_response(mock_canister_http_response);

let reply = pic.await_call(call_id).unwrap();
println!("{:?}", reply);
match reply {
WasmResult::Reply(data) => {
let res: Result<SignedDkimPublicKey, String> = decode_one(&data).unwrap();
assert!(res.is_err());
}
WasmResult::Reject(msg) => panic!("Unexpected reject {}", msg),
};
}

#[test]
fn test_sign_gmail_invalid_selector() {
// We create a PocketIC instance consisting of the NNS, II, and one application subnet.
let pic = PocketIcBuilder::new()
.with_max_request_time_ms(None)
.with_nns_subnet()
.with_ii_subnet() // this subnet has ECDSA keys
.with_application_subnet()
Expand Down

0 comments on commit 2d687be

Please sign in to comment.