From 530adda1ca3d85c264b13802f222740b3a000413 Mon Sep 17 00:00:00 2001 From: kukabi Date: Tue, 2 Aug 2022 00:47:02 +0300 Subject: [PATCH] Fix clippy. --- subvt-telegram-bot/src/test/basic/mod.rs | 10 +++--- subvt-telegram-bot/src/test/command/about.rs | 4 +-- .../src/test/command/add_validator.rs | 32 ++++++++----------- .../src/test/command/broadcast.rs | 26 +++++++-------- subvt-telegram-bot/src/test/command/cancel.rs | 4 +-- .../src/test/command/contact.rs | 4 +-- .../src/test/command/democracy.rs | 12 +++---- subvt-telegram-bot/src/test/command/help.rs | 4 +-- .../src/test/command/invalid.rs | 7 ++-- .../src/test/command/network_status.rs | 9 +++--- subvt-telegram-bot/src/test/command/nfts.rs | 12 +++---- .../src/test/command/nomination_details.rs | 30 ++++++++--------- .../src/test/command/nominations.rs | 30 ++++++++--------- .../src/test/command/payouts.rs | 12 +++---- subvt-telegram-bot/src/test/command/remove.rs | 12 +++---- .../src/test/command/rewards.rs | 12 +++---- .../src/test/command/settings.rs | 6 ++-- subvt-telegram-bot/src/test/command/start.rs | 4 +-- .../src/test/command/validator_info.rs | 23 ++++++------- 19 files changed, 116 insertions(+), 137 deletions(-) diff --git a/subvt-telegram-bot/src/test/basic/mod.rs b/subvt-telegram-bot/src/test/basic/mod.rs index 724c2c30..94e58c14 100644 --- a/subvt-telegram-bot/src/test/basic/mod.rs +++ b/subvt-telegram-bot/src/test/basic/mod.rs @@ -8,7 +8,7 @@ use crate::{MessengerImpl, TelegramBot, DEFAULT_RULES}; async fn test_save_new_chat() { let chat_id = get_random_chat_id(); let bot = new_test_bot(MockMessenger::new()).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); assert!(bot .network_postgres .chat_exists_by_id(chat_id) @@ -41,18 +41,18 @@ async fn test_save_new_chat() { async fn test_restore_chat_and_user() { let bot: TelegramBot = TelegramBot::::new().await.unwrap(); let chat_id = 2; - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); let user_id = bot .network_postgres .get_chat_app_user_id(chat_id) .await .unwrap(); assert!(!bot.network_postgres.chat_is_deleted(chat_id).await.unwrap()); - assert!(bot.network_postgres.delete_chat(chat_id).await.is_ok()); - assert!(bot.app_postgres.delete_user(user_id).await.is_ok()); + bot.network_postgres.delete_chat(chat_id).await.unwrap(); + bot.app_postgres.delete_user(user_id).await.unwrap(); assert!(bot.network_postgres.chat_is_deleted(chat_id).await.unwrap()); assert!(!bot.app_postgres.user_exists_by_id(user_id).await.unwrap()); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); assert!(bot .network_postgres .chat_exists_by_id(chat_id) diff --git a/subvt-telegram-bot/src/test/command/about.rs b/subvt-telegram-bot/src/test/command/about.rs index edea6127..dcaaa55c 100644 --- a/subvt-telegram-bot/src/test/command/about.rs +++ b/subvt-telegram-bot/src/test/command/about.rs @@ -17,6 +17,6 @@ async fn test_about() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/about", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/about", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/add_validator.rs b/subvt-telegram-bot/src/test/command/add_validator.rs index 5890b57c..8e3d45c9 100644 --- a/subvt-telegram-bot/src/test/command/add_validator.rs +++ b/subvt-telegram-bot/src/test/command/add_validator.rs @@ -17,8 +17,8 @@ async fn test_add_validator_no_address() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/add", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/add", &[]).await.unwrap(); } /// Tests the case when the user enters an invalid SS58 address following the /add command. @@ -38,11 +38,10 @@ async fn test_add_validator_invalid_address() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/add", &[invalid_address.to_string()]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/add", &[invalid_address.to_string()]) .await - .is_ok()); + .unwrap(); } /// Tests when the user tries to add a validator that doesn't exist in the Redis database, @@ -64,11 +63,10 @@ async fn test_add_non_existent_validator() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/add", &command_args) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/add", &command_args) .await - .is_ok()); + .unwrap(); } /// Tests the case of trying to add a validator that already exists in the chat. @@ -90,7 +88,7 @@ async fn test_add_validator_duplicate() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); @@ -98,10 +96,9 @@ async fn test_add_validator_duplicate() { .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/add", &command_args) + bot.process_command(chat_id, "/add", &command_args) .await - .is_ok()); + .unwrap(); } /// Test the successful addition of a validator to a chat. @@ -135,9 +132,8 @@ async fn test_add_validator_successful() { add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/add", &command_args) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/add", &command_args) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/broadcast.rs b/subvt-telegram-bot/src/test/command/broadcast.rs index c60af339..07494b27 100644 --- a/subvt-telegram-bot/src/test/command/broadcast.rs +++ b/subvt-telegram-bot/src/test/command/broadcast.rs @@ -18,11 +18,10 @@ async fn test_broadcasttest() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(ADMIN_CHAT_ID).await.is_ok()); - assert!(bot - .process_command(ADMIN_CHAT_ID, "/broadcasttest", &[]) + bot.save_or_restore_chat(ADMIN_CHAT_ID).await.unwrap(); + bot.process_command(ADMIN_CHAT_ID, "/broadcasttest", &[]) .await - .is_ok()); + .unwrap(); } /// Tests the case of calling the /broadcast and /broadcasttest commands from an @@ -40,15 +39,13 @@ async fn test_broadcast_and_broadcasttest_non_admin() { .times(2) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/broadcast", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/broadcast", &[]) .await - .is_ok()); - assert!(bot - .process_command(chat_id, "/broadcasttest", &[]) + .unwrap(); + bot.process_command(chat_id, "/broadcasttest", &[]) .await - .is_ok()); + .unwrap(); } /// Test the calling of the /broadcast command by an authorized chat. This command is replied @@ -65,9 +62,8 @@ async fn test_broadcast() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(ADMIN_CHAT_ID).await.is_ok()); - assert!(bot - .process_command(ADMIN_CHAT_ID, "/broadcast", &[]) + bot.save_or_restore_chat(ADMIN_CHAT_ID).await.unwrap(); + bot.process_command(ADMIN_CHAT_ID, "/broadcast", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/cancel.rs b/subvt-telegram-bot/src/test/command/cancel.rs index 71e8bf96..730c8635 100644 --- a/subvt-telegram-bot/src/test/command/cancel.rs +++ b/subvt-telegram-bot/src/test/command/cancel.rs @@ -14,6 +14,6 @@ async fn test_cancel() { .withf(|_, _, _, message_type: &Box| matches!(**message_type, MessageType::Ok)) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/cancel", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/cancel", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/contact.rs b/subvt-telegram-bot/src/test/command/contact.rs index 94d40f6c..2973943f 100644 --- a/subvt-telegram-bot/src/test/command/contact.rs +++ b/subvt-telegram-bot/src/test/command/contact.rs @@ -17,6 +17,6 @@ async fn test_contact() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/contact", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/contact", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/democracy.rs b/subvt-telegram-bot/src/test/command/democracy.rs index d691c35a..8d71ebd1 100644 --- a/subvt-telegram-bot/src/test/command/democracy.rs +++ b/subvt-telegram-bot/src/test/command/democracy.rs @@ -19,13 +19,11 @@ async fn test_democracy() { .times(2) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/democracy", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/democracy", &[]) .await - .is_ok()); - assert!(bot - .process_command(chat_id, "/referenda", &[]) + .unwrap(); + bot.process_command(chat_id, "/referenda", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/help.rs b/subvt-telegram-bot/src/test/command/help.rs index 96fc7535..346bd29d 100644 --- a/subvt-telegram-bot/src/test/command/help.rs +++ b/subvt-telegram-bot/src/test/command/help.rs @@ -16,6 +16,6 @@ async fn test_help() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/help", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/help", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/invalid.rs b/subvt-telegram-bot/src/test/command/invalid.rs index babe81dd..9de9a00d 100644 --- a/subvt-telegram-bot/src/test/command/invalid.rs +++ b/subvt-telegram-bot/src/test/command/invalid.rs @@ -16,9 +16,8 @@ async fn test_invalid_command() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/xyz23wefergknt", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/xyz23wefergknt", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/network_status.rs b/subvt-telegram-bot/src/test/command/network_status.rs index e700c0f1..45d05288 100644 --- a/subvt-telegram-bot/src/test/command/network_status.rs +++ b/subvt-telegram-bot/src/test/command/network_status.rs @@ -23,10 +23,9 @@ async fn test_get_network_status_success() { .set_network_status(&NetworkStatus::default()) .await .unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/network", &[]).await.is_ok()); - assert!(bot - .process_command(chat_id, "/networkstatus", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/network", &[]).await.unwrap(); + bot.process_command(chat_id, "/networkstatus", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/nfts.rs b/subvt-telegram-bot/src/test/command/nfts.rs index 720148f0..2bd5edfb 100644 --- a/subvt-telegram-bot/src/test/command/nfts.rs +++ b/subvt-telegram-bot/src/test/command/nfts.rs @@ -18,8 +18,8 @@ async fn test_nfts_no_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/nfts", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/nfts", &[]).await.unwrap(); } /// User has called the /nfts command, and has a single validator added to the chat, @@ -47,12 +47,12 @@ async fn test_nfts_single_validator_no_nfts() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot.process_command(chat_id, "/nfts", &[]).await.is_ok()); + bot.process_command(chat_id, "/nfts", &[]).await.unwrap(); } /// Tests the successful result of the /nfts command with a validator stash address with NFTs. @@ -80,10 +80,10 @@ async fn test_nfts_single_validator_with_nfts() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot.process_command(chat_id, "/nfts", &[]).await.is_ok()); + bot.process_command(chat_id, "/nfts", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/nomination_details.rs b/subvt-telegram-bot/src/test/command/nomination_details.rs index d0480ca5..ca55c0d4 100644 --- a/subvt-telegram-bot/src/test/command/nomination_details.rs +++ b/subvt-telegram-bot/src/test/command/nomination_details.rs @@ -20,12 +20,11 @@ async fn test_nomination_details_no_validator() { .times(2) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/nominationdetails", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/nominationdetails", &[]) .await - .is_ok()); - assert!(bot.process_command(chat_id, "/nd", &[]).await.is_ok()); + .unwrap(); + bot.process_command(chat_id, "/nd", &[]).await.unwrap(); } /// Tests /nominationdetails command for a chat with a single validator. @@ -48,7 +47,7 @@ async fn test_nomination_details_single_validator() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); @@ -56,10 +55,9 @@ async fn test_nomination_details_single_validator() { .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/nominationdetails", &[]) + bot.process_command(chat_id, "/nominationdetails", &[]) .await - .is_ok()); + .unwrap(); } /// Tests /nominationdetails for a single validator that doesn't exist in the Redis database. @@ -76,15 +74,14 @@ async fn test_nomination_details_single_non_existent_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/nominationdetails", &[]) + bot.process_command(chat_id, "/nominationdetails", &[]) .await - .is_ok()); + .unwrap(); } /// Tests /nominationdetails where the user has multiple validators added to the chat - should @@ -112,7 +109,7 @@ async fn test_nomination_details_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -120,8 +117,7 @@ async fn test_nomination_details_multiple_validators() { .await .unwrap(); } - assert!(bot - .process_command(chat_id, "/nominationdetails", &[]) + bot.process_command(chat_id, "/nominationdetails", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/nominations.rs b/subvt-telegram-bot/src/test/command/nominations.rs index 92204ed9..ac287a6b 100644 --- a/subvt-telegram-bot/src/test/command/nominations.rs +++ b/subvt-telegram-bot/src/test/command/nominations.rs @@ -20,12 +20,11 @@ async fn test_nominations_no_validator() { .times(2) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/nominations", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/nominations", &[]) .await - .is_ok()); - assert!(bot.process_command(chat_id, "/n", &[]).await.is_ok()); + .unwrap(); + bot.process_command(chat_id, "/n", &[]).await.unwrap(); } /// Tests /nominations command for a chat with a single validator. @@ -48,7 +47,7 @@ async fn test_nominations_single_validator() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); @@ -56,10 +55,9 @@ async fn test_nominations_single_validator() { .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/nominations", &[]) + bot.process_command(chat_id, "/nominations", &[]) .await - .is_ok()); + .unwrap(); } /// Tests /nominations for a single validator that doesn't exist in the Redis database. @@ -76,15 +74,14 @@ async fn test_nominations_single_non_existent_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/nominations", &[]) + bot.process_command(chat_id, "/nominations", &[]) .await - .is_ok()); + .unwrap(); } /// Tests /nominations where the user has multiple validators added to the chat - should @@ -112,7 +109,7 @@ async fn test_nominations_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -120,8 +117,7 @@ async fn test_nominations_multiple_validators() { .await .unwrap(); } - assert!(bot - .process_command(chat_id, "/nominations", &[]) + bot.process_command(chat_id, "/nominations", &[]) .await - .is_ok()); + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/payouts.rs b/subvt-telegram-bot/src/test/command/payouts.rs index 0c164100..38b323d1 100644 --- a/subvt-telegram-bot/src/test/command/payouts.rs +++ b/subvt-telegram-bot/src/test/command/payouts.rs @@ -19,8 +19,8 @@ async fn test_payouts_no_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/payouts", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/payouts", &[]).await.unwrap(); } /// Tests calling the /payouts command with a single validator on the chat that has no @@ -38,7 +38,7 @@ async fn test_payouts_single_validator_no_payouts() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); @@ -46,7 +46,7 @@ async fn test_payouts_single_validator_no_payouts() { .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot.process_command(chat_id, "/payouts", &[]).await.is_ok()); + bot.process_command(chat_id, "/payouts", &[]).await.unwrap(); } /// Tests calling the /payouts command with multiple single validator on the chat - the @@ -73,7 +73,7 @@ async fn test_payouts_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -81,5 +81,5 @@ async fn test_payouts_multiple_validators() { .await .unwrap(); } - assert!(bot.process_command(chat_id, "/payouts", &[]).await.is_ok()); + bot.process_command(chat_id, "/payouts", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/remove.rs b/subvt-telegram-bot/src/test/command/remove.rs index 7629d91d..946cc194 100644 --- a/subvt-telegram-bot/src/test/command/remove.rs +++ b/subvt-telegram-bot/src/test/command/remove.rs @@ -18,8 +18,8 @@ async fn test_remove_no_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/remove", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/remove", &[]).await.unwrap(); } /// Tests /remove command with a single validator added to the chat. @@ -40,12 +40,12 @@ async fn test_remove_single_validator() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot.process_command(chat_id, "/remove", &[]).await.is_ok()); + bot.process_command(chat_id, "/remove", &[]).await.unwrap(); } /// Tests /remove command with multiple validators on the chat - user should receive @@ -73,7 +73,7 @@ async fn test_remove_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -81,5 +81,5 @@ async fn test_remove_multiple_validators() { .await .unwrap(); } - assert!(bot.process_command(chat_id, "/remove", &[]).await.is_ok()); + bot.process_command(chat_id, "/remove", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/rewards.rs b/subvt-telegram-bot/src/test/command/rewards.rs index 9d50733c..c6459799 100644 --- a/subvt-telegram-bot/src/test/command/rewards.rs +++ b/subvt-telegram-bot/src/test/command/rewards.rs @@ -19,8 +19,8 @@ async fn test_rewards_no_validator() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/rewards", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/rewards", &[]).await.unwrap(); } /// Tests calling the /rewards command with a single validator on the chat that has no @@ -38,7 +38,7 @@ async fn test_rewards_single_validator_no_rewards() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); add_validator_to_redis(&bot.redis, &account_id) .await .unwrap(); @@ -46,7 +46,7 @@ async fn test_rewards_single_validator_no_rewards() { .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot.process_command(chat_id, "/rewards", &[]).await.is_ok()); + bot.process_command(chat_id, "/rewards", &[]).await.unwrap(); } /// Tests calling the /rewards command with multiple single validator on the chat - the @@ -73,7 +73,7 @@ async fn test_rewards_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -81,5 +81,5 @@ async fn test_rewards_multiple_validators() { .await .unwrap(); } - assert!(bot.process_command(chat_id, "/rewards", &[]).await.is_ok()); + bot.process_command(chat_id, "/rewards", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/settings.rs b/subvt-telegram-bot/src/test/command/settings.rs index 25b0004a..476965b2 100644 --- a/subvt-telegram-bot/src/test/command/settings.rs +++ b/subvt-telegram-bot/src/test/command/settings.rs @@ -16,6 +16,8 @@ async fn test_settings() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/settings", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/settings", &[]) + .await + .unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/start.rs b/subvt-telegram-bot/src/test/command/start.rs index 8f042d61..cc0a33b2 100644 --- a/subvt-telegram-bot/src/test/command/start.rs +++ b/subvt-telegram-bot/src/test/command/start.rs @@ -16,6 +16,6 @@ async fn test_start() { }) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot.process_command(chat_id, "/start", &[]).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/start", &[]).await.unwrap(); } diff --git a/subvt-telegram-bot/src/test/command/validator_info.rs b/subvt-telegram-bot/src/test/command/validator_info.rs index f7849d7b..a7196746 100644 --- a/subvt-telegram-bot/src/test/command/validator_info.rs +++ b/subvt-telegram-bot/src/test/command/validator_info.rs @@ -20,12 +20,11 @@ async fn test_validator_info_no_validator() { .times(2) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); - assert!(bot - .process_command(chat_id, "/validatorinfo", &[]) + bot.save_or_restore_chat(chat_id).await.unwrap(); + bot.process_command(chat_id, "/validatorinfo", &[]) .await - .is_ok()); - assert!(bot.process_command(chat_id, "/vi", &[]).await.is_ok()); + .unwrap(); + bot.process_command(chat_id, "/vi", &[]).await.unwrap(); } /// Test /validatorinfo with a single validator on the chat. @@ -49,15 +48,14 @@ async fn test_validator_info_single_validator() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); bot.network_postgres .add_validator_to_chat(chat_id, &account_id, &account_id.to_ss58_check(), &None) .await .unwrap(); - assert!(bot - .process_command(chat_id, "/validatorinfo", &[]) + bot.process_command(chat_id, "/validatorinfo", &[]) .await - .is_ok()); + .unwrap(); } /// Test /validatorinfo when there are multiple validators on the chat. @@ -84,7 +82,7 @@ async fn test_validator_info_multiple_validators() { ) .returning(|_, _, _, _| Ok(get_telegram_message_response())); let bot = new_test_bot(messenger).await.unwrap(); - assert!(bot.save_or_restore_chat(chat_id).await.is_ok()); + bot.save_or_restore_chat(chat_id).await.unwrap(); for _ in 0..validator_count { let account_id = get_random_account_id(); bot.network_postgres @@ -92,8 +90,7 @@ async fn test_validator_info_multiple_validators() { .await .unwrap(); } - assert!(bot - .process_command(chat_id, "/validatorinfo", &[]) + bot.process_command(chat_id, "/validatorinfo", &[]) .await - .is_ok()); + .unwrap(); }