diff --git a/crates/rpc/rpc-eth-api/src/helpers/signer.rs b/crates/rpc/rpc-eth-api/src/helpers/signer.rs index c54c8943c0..be04ecc278 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/signer.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/signer.rs @@ -31,4 +31,46 @@ pub trait EthSigner: Send + Sync + DynClone { fn sign_typed_data(&self, address: Address, payload: &TypedData) -> Result; } -dyn_clone::clone_trait_object!( EthSigner); +dyn_clone::clone_trait_object!( EthSigner); + +#[cfg(test)] +mod tests { + use super::*; + + #[derive(Clone)] + struct MockSigner; + + struct MockSignedTx; + struct MockTxReq; + + #[async_trait::async_trait] + impl EthSigner for MockSigner { + fn accounts(&self) -> Vec
{ + Vec::new() + } + + async fn sign(&self, _address: Address, _message: &[u8]) -> Result { + Err(SignError::NoAccount) + } + + async fn sign_transaction( + &self, + _request: MockTxReq, + _address: &Address, + ) -> Result { + Err(SignError::NoAccount) + } + + fn sign_typed_data(&self, _address: Address, _payload: &TypedData) -> Result { + Err(SignError::NoAccount) + } + } + + #[test] + fn clones_trait_object_with_custom_tx_request_type() { + let signer: Box> = Box::new(MockSigner); + let cloned: Box> = dyn_clone::clone_box(&*signer); + + assert!(cloned.accounts().is_empty()); + } +}