Skip to content

Commit af24ba6

Browse files
committed
Drop commented out code, reoder tests
1 parent 40ee1b0 commit af24ba6

1 file changed

Lines changed: 29 additions & 87 deletions

File tree

  • crates/node/src/providers/verify_foreign_tx

crates/node/src/providers/verify_foreign_tx/sign.rs

Lines changed: 29 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,35 @@ mod tests {
428428
)])
429429
}
430430

431+
#[test]
432+
fn build_signature_request__should_reject_payload_not_matching_expected_hash() {
433+
// Given
434+
let request = verify_foreign_tx_request(Some(dtos::Hash256([1u8; 32])));
435+
let payload = bitcoin_payload();
436+
437+
// When
438+
let result = build_signature_request(&request, &payload);
439+
440+
// Then
441+
let error = result.unwrap_err().to_string();
442+
assert!(
443+
error.contains("does not match the request's expected payload hash"),
444+
"expected the payload hash mismatch error, got: {error}",
445+
);
446+
}
447+
448+
#[test]
449+
fn build_signature_request__should_accept_any_payload_without_expected_hash() {
450+
// Given
451+
let request = verify_foreign_tx_request(None);
452+
453+
// When
454+
let result = build_signature_request(&request, &bitcoin_payload());
455+
456+
// Then
457+
result.unwrap();
458+
}
459+
431460
#[test]
432461
fn ensure_chain_is_available__should_succeed_when_chain_has_supporters() {
433462
// Given
@@ -459,35 +488,6 @@ mod tests {
459488
);
460489
}
461490

462-
#[test]
463-
fn build_signature_request__should_reject_payload_not_matching_expected_hash() {
464-
// Given
465-
let request = verify_foreign_tx_request(Some(dtos::Hash256([1u8; 32])));
466-
let payload = bitcoin_payload();
467-
468-
// When
469-
let result = build_signature_request(&request, &payload);
470-
471-
// Then
472-
let error = result.unwrap_err().to_string();
473-
assert!(
474-
error.contains("does not match the request's expected payload hash"),
475-
"expected the payload hash mismatch error, got: {error}",
476-
);
477-
}
478-
479-
#[test]
480-
fn build_signature_request__should_accept_any_payload_without_expected_hash() {
481-
// Given
482-
let request = verify_foreign_tx_request(None);
483-
484-
// When
485-
let result = build_signature_request(&request, &bitcoin_payload());
486-
487-
// Then
488-
result.unwrap();
489-
}
490-
491491
fn bitcoin_request() -> dtos::ForeignChainRpcRequest {
492492
dtos::ForeignChainRpcRequest::Bitcoin(dtos::BitcoinRpcRequest {
493493
tx_id: dtos::BitcoinTxId([0; 32]),
@@ -496,44 +496,6 @@ mod tests {
496496
})
497497
}
498498

499-
// fn bitcoin_chain_policy() -> dtos::SupportedForeignChains {
500-
// BTreeSet::from([dtos::ForeignChain::Bitcoin]).into()
501-
// }
502-
503-
// fn mock_policy_reader(policy: dtos::SupportedForeignChains) -> MockReadSupportedForeignChain {
504-
// let mut reader = MockReadSupportedForeignChain::new();
505-
// reader
506-
// .expect_get_supported_chains()
507-
// .returning(move || Box::pin(std::future::ready(Ok(policy.clone()))));
508-
// reader
509-
// }
510-
511-
// #[tokio::test]
512-
// async fn chain_is_supported__should_succeed_when_chain_is_present_in_policy() {
513-
// let reader = mock_policy_reader(bitcoin_chain_policy());
514-
515-
// assert_matches!(chain_is_supported(&reader, &bitcoin_request()).await, Ok(_));
516-
// }
517-
518-
// #[test]
519-
// fn ensure_chain_is_available__should_fail_when_chain_has_no_supporters() {
520-
// // Given: the supporters map covers Bitcoin, but the request is for Ethereum.
521-
// let supporters = bitcoin_supporters();
522-
// let ethereum_request = dtos::ForeignChainRpcRequest::Ethereum(dtos::EvmRpcRequest {
523-
// tx_id: dtos::EvmTxId([0; 32]),
524-
// extractors: vec![],
525-
// finality: dtos::EvmFinality::Finalized,
526-
// });
527-
528-
// // When, then
529-
// assert_matches!(
530-
// ensure_chain_is_available(&supporters, &ethereum_request),
531-
// Err(ChainNotAvailableError {
532-
// requested: dtos::ForeignChain::Ethereum
533-
// })
534-
// );
535-
// }
536-
537499
fn bitcoin_payload() -> dtos::ForeignTxSignPayload {
538500
dtos::ForeignTxSignPayload::V1(dtos::ForeignTxSignPayloadV1 {
539501
request: bitcoin_request(),
@@ -557,24 +519,4 @@ mod tests {
557519
domain_id: mpc_primitives::domain::DomainId(0),
558520
}
559521
}
560-
561-
// fn bitcoin_request() -> dtos::ForeignChainRpcRequest {
562-
// dtos::ForeignChainRpcRequest::Bitcoin(dtos::BitcoinRpcRequest {
563-
// tx_id: dtos::BitcoinTxId([0; 32]),
564-
// confirmations: dtos::BlockConfirmations(6),
565-
// extractors: vec![dtos::BitcoinExtractor::BlockHash],
566-
// })
567-
// }
568-
569-
// fn bitcoin_chain_policy() -> dtos::SupportedForeignChains {
570-
// BTreeSet::from([dtos::ForeignChain::Bitcoin]).into()
571-
// }
572-
573-
// fn mock_policy_reader(policy: dtos::SupportedForeignChains) -> MockReadSupportedForeignChain {
574-
// let mut reader = MockReadSupportedForeignChain::new();
575-
// reader
576-
// .expect_get_supported_chains()
577-
// .returning(move || Box::pin(std::future::ready(Ok(policy.clone()))));
578-
// reader
579-
// }
580522
}

0 commit comments

Comments
 (0)