use evm_client::provider::Transaction; use evm_client::provider::{parse_signature_rs_v, get_balance}; // All native (non-WASM) balance and signature tests are in this file. use ethers_core::types::{U256, Address, Bytes}; #[test] fn test_rlp_encode_unsigned() { let tx = Transaction { nonce: U256::from(1), to: Address::zero(), value: U256::from(100), gas: U256::from(21000), gas_price: U256::from(1), data: Bytes::new(), chain_id: 1u64, }; let rlp = tx.rlp_encode_unsigned(); assert!(!rlp.is_empty()); } #[test] fn test_parse_signature_rs_v() { let mut sig = [0u8; 65]; sig[31] = 1; sig[63] = 2; sig[64] = 27; let (r, s, v) = parse_signature_rs_v(&sig, 1).unwrap(); assert_eq!(r, U256::from(1)); assert_eq!(s, U256::from(2)); assert_eq!(v, 27 + 1 * 2 + 8); } #[cfg(not(target_arch = "wasm32"))] #[tokio::test] async fn test_get_balance_real_address() { // Vitalik's address let address = "d8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; let address = ethers_core::types::Address::from_slice(&hex::decode(address).unwrap()); let url = "https://ethereum.blockpi.network/v1/rpc/public"; let balance = get_balance(url, address).await.expect("Failed to get balance"); assert!(balance > ethers_core::types::U256::zero(), "Vitalik's balance should be greater than zero"); }