Skip to content

Commit

Permalink
Fix test for rejecting a TSS node who is not part of the signing comm…
Browse files Browse the repository at this point in the history
…itte (#1028)

* Update error message for unexpected participant

* Fix test
  • Loading branch information
ameba23 authored Aug 26, 2024
1 parent c8a2fc3 commit a47156c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ async fn handle_initial_incoming_ws_message(
};

{
// Check that the given public key matches the public key we got in the
// UserTransactionRequest or register transaction
// Check that the given public key is of the ones we are expecting for this protocol session
let mut listeners = app_state
.listener_state
.listeners
Expand All @@ -186,8 +185,7 @@ async fn handle_initial_incoming_ws_message(
// Make the signing process fail, since one of the commitee has misbehaved
listeners.remove(&msg.session_id);
return Err(SubscribeErr::Decryption(
"Public key does not match that given in UserTransactionRequest or register \
transaction"
"Public key does not match any of those expected for this protocol session"
.to_string(),
));
}
Expand Down
13 changes: 4 additions & 9 deletions crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ async fn test_request_limit_are_updated_during_signing() {
clean_tests();
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_fails_to_sign_if_non_signing_group_participants_are_used() {
Expand Down Expand Up @@ -728,7 +727,7 @@ async fn test_fails_to_sign_if_non_signing_group_participants_are_used() {
};

let with_parent_key = true;
let (validators_info, mut signature_request, validator_ips_and_keys) =
let (_validators_info, mut signature_request, validator_ips_and_keys) =
get_sign_tx_data(&entropy_api, &rpc, hex::encode(PREIMAGE_SHOULD_SUCCEED), with_parent_key)
.await;

Expand Down Expand Up @@ -769,7 +768,7 @@ async fn test_fails_to_sign_if_non_signing_group_participants_are_used() {
let subscribe_response: Result<(), String> =
bincode::deserialize(&response_message).unwrap();

assert_eq!(Err("NoListener(\"no listener\")".to_string()), subscribe_response);
assert_eq!(Err("Decryption(\"Public key does not match any of those expected for this protocol session\")".to_string()), subscribe_response);

// The stream should not continue to send messages
// returns true if this part of the test passes
Expand All @@ -780,20 +779,16 @@ async fn test_fails_to_sign_if_non_signing_group_participants_are_used() {
signature_request.signature_verifying_key = verifying_key.to_vec();

let test_user_bad_connection_res = submit_transaction_requests(
vec![validator_ips_and_keys[1].clone()],
vec![validator_ips_and_keys[0].clone()],
signature_request.clone(),
one,
)
.await;

// thread 'user::tests::test_fails_to_sign_if_non_signing_group_participants_are_used' panicked at crates/threshold-signature-server/src/user/tests.rs:848:9:
// assertion `left == right` failed
// left: "{\"Err\":\"Subscribe message rejected: NoListener(\\\"no listener\\\")\"}"
// right: "{\"Err\":\"Timed out waiting for remote party\"}"
for res in test_user_bad_connection_res {
assert_eq!(
res.unwrap().text().await.unwrap(),
"{\"Err\":\"Timed out waiting for remote party\"}"
"{\"Err\":\"Oneshot timeout error: channel closed\"}"
);
}

Expand Down

0 comments on commit a47156c

Please sign in to comment.