From 783a3c304b68eabec1a21461a784323884e8cbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20Bayindirli=20=F0=9F=A5=82?= Date: Mon, 6 Jan 2025 12:16:47 -0800 Subject: [PATCH] run format --- contracts/axelar-gateway/src/auth.rs | 2 +- contracts/axelar-gateway/src/event.rs | 29 +++------------- contracts/axelar-gateway/src/testutils.rs | 19 ++++++----- contracts/axelar-gateway/tests/gateway.rs | 41 +++++------------------ 4 files changed, 26 insertions(+), 65 deletions(-) diff --git a/contracts/axelar-gateway/src/auth.rs b/contracts/axelar-gateway/src/auth.rs index cab48e39..6152a5ea 100644 --- a/contracts/axelar-gateway/src/auth.rs +++ b/contracts/axelar-gateway/src/auth.rs @@ -1,7 +1,7 @@ use crate::error::ContractError; use crate::types::{ProofSignature, ProofSigner, WeightedSigner}; -use axelar_soroban_std::events::Event; use axelar_soroban_std::ensure; +use axelar_soroban_std::events::Event; use soroban_sdk::{crypto::Hash, Bytes, BytesN, Env, Vec}; use crate::event; diff --git a/contracts/axelar-gateway/src/event.rs b/contracts/axelar-gateway/src/event.rs index afb0c002..1ab6fb41 100644 --- a/contracts/axelar-gateway/src/event.rs +++ b/contracts/axelar-gateway/src/event.rs @@ -48,10 +48,7 @@ impl Event for ContractCalledEvent { impl Event for MessageApprovedEvent { fn topics(&self, env: &Env) -> impl Topics + Debug { - ( - Symbol::new(env, "message_approved"), - self.message.clone(), - ) + (Symbol::new(env, "message_approved"), self.message.clone()) } fn data(&self, env: &Env) -> impl IntoVal + Debug { @@ -61,10 +58,7 @@ impl Event for MessageApprovedEvent { impl Event for MessageExecutedEvent { fn topics(&self, env: &Env) -> impl Topics + Debug { - ( - Symbol::new(env, "message_executed"), - self.message.clone(), - ) + (Symbol::new(env, "message_executed"), self.message.clone()) } fn data(&self, env: &Env) -> impl IntoVal + Debug { @@ -89,7 +83,6 @@ impl Event for SignersRotatedEvent { #[cfg(any(test, feature = "testutils"))] use axelar_soroban_std::impl_event_testutils; - #[cfg(any(test, feature = "testutils"))] impl_event_testutils!( ContractCalledEvent, @@ -98,22 +91,10 @@ impl_event_testutils!( ); #[cfg(any(test, feature = "testutils"))] -impl_event_testutils!( - MessageApprovedEvent, - (Symbol, Message), - () -); +impl_event_testutils!(MessageApprovedEvent, (Symbol, Message), ()); #[cfg(any(test, feature = "testutils"))] -impl_event_testutils!( - MessageExecutedEvent, - (Symbol, Message), - () -); +impl_event_testutils!(MessageExecutedEvent, (Symbol, Message), ()); #[cfg(any(test, feature = "testutils"))] -impl_event_testutils!( - SignersRotatedEvent, - (Symbol, u64, BytesN<32>), - () -); +impl_event_testutils!(SignersRotatedEvent, (Symbol, u64, BytesN<32>), ()); diff --git a/contracts/axelar-gateway/src/testutils.rs b/contracts/axelar-gateway/src/testutils.rs index 4456ffa3..d2c652f3 100644 --- a/contracts/axelar-gateway/src/testutils.rs +++ b/contracts/axelar-gateway/src/testutils.rs @@ -94,11 +94,19 @@ pub fn randint(a: u32, b: u32) -> u32 { rand::thread_rng().gen_range(a..b) } -pub fn generate_signers_set(env: &Env, num_signers: u32, domain_separator: BytesN<32>) -> TestSignerSet { +pub fn generate_signers_set( + env: &Env, + num_signers: u32, + domain_separator: BytesN<32>, +) -> TestSignerSet { generate_signers_set_with_randomness(env, num_signers, domain_separator, true) } -pub fn generate_deterministic_signers_set(env: &Env, num_signers: u32, domain_separator: BytesN<32>) -> TestSignerSet { +pub fn generate_deterministic_signers_set( + env: &Env, + num_signers: u32, + domain_separator: BytesN<32>, +) -> TestSignerSet { generate_signers_set_with_randomness(env, num_signers, domain_separator, false) } @@ -239,12 +247,7 @@ pub fn rotate_to_new_signers<'a>( num_signers: u32, use_rng: bool, ) -> TestSignerSet { - let (new_signers, proof) = generate_new_signers( - env, - signers, - num_signers, - use_rng, - ); + let (new_signers, proof) = generate_new_signers(env, signers, num_signers, use_rng); client.rotate_signers(&new_signers.signers, &proof, &bypass_rotation_delay); new_signers diff --git a/contracts/axelar-gateway/tests/gateway.rs b/contracts/axelar-gateway/tests/gateway.rs index 034ed63d..39773ff4 100644 --- a/contracts/axelar-gateway/tests/gateway.rs +++ b/contracts/axelar-gateway/tests/gateway.rs @@ -1,12 +1,13 @@ use axelar_gateway::error::ContractError; +use axelar_gateway::event::{ + ContractCalledEvent, MessageApprovedEvent, MessageExecutedEvent, SignersRotatedEvent, +}; #[cfg(any(test, feature = "testutils"))] use axelar_gateway::testutils::{ - generate_deterministic_test_message, generate_new_signers, generate_proof, generate_signers_set, generate_test_message, get_approve_hash, randint, rotate_to_new_signers + generate_deterministic_test_message, generate_new_signers, generate_proof, + generate_signers_set, generate_test_message, get_approve_hash, randint, rotate_to_new_signers, }; use axelar_gateway::types::Message; -use axelar_gateway::event::{ - ContractCalledEvent, MessageApprovedEvent, MessageExecutedEvent, SignersRotatedEvent -}; use axelar_soroban_std::{ assert_contract_err, assert_invocation, assert_invoke_auth_err, assert_invoke_auth_ok, events, }; @@ -222,14 +223,7 @@ fn approve_messages_skip_duplicate_message() { #[test] fn rotate_signers() { let (env, signers, client) = setup_env(1, 5); - rotate_to_new_signers( - &env, - signers, - &client, - false, - 5, - false - ); + rotate_to_new_signers(&env, signers, &client, false, 5, false); goldie::assert!(events::fmt_last_emitted_event::(&env)); } @@ -237,14 +231,7 @@ fn rotate_signers() { #[test] fn approve_messages_after_rotation() { let (env, signers, client) = setup_env(1, 5); - let new_signers = rotate_to_new_signers( - &env, - signers, - &client, - false, - 5, - false - ); + let new_signers = rotate_to_new_signers(&env, signers, &client, false, 5, false); let (message, _) = generate_deterministic_test_message(&env); let messages = vec![&env, message.clone()]; @@ -258,12 +245,7 @@ fn approve_messages_after_rotation() { #[test] fn rotate_signers_bypass_rotation_delay() { let (env, signers, client) = setup_env(1, 5); - let (new_signers, proof) = generate_new_signers( - &env, - signers, - 5, - false, - ); + let (new_signers, proof) = generate_new_signers(&env, signers, 5, false); let bypass_rotation_delay = true; assert_invoke_auth_ok!( @@ -277,12 +259,7 @@ fn rotate_signers_bypass_rotation_delay() { #[test] fn rotate_signers_bypass_rotation_delay_unauthorized() { let (env, signers, client) = setup_env(1, 5); - let (new_signers, proof) = generate_new_signers( - &env, - signers, - 5, - true, - ); + let (new_signers, proof) = generate_new_signers(&env, signers, 5, true); let bypass_rotation_delay = true; assert_invoke_auth_err!(