From 70fe52437cfdca95ab943e1c037b31d0fbaf5762 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 12 Jul 2024 22:09:46 -0400 Subject: [PATCH] Have RPC tests run sequentially Also corrects links pointing to branches to point to commits. --- coins/monero/rpc/simple-request/tests/tests.rs | 17 +++++++++++++++++ coins/monero/wallet/address/src/lib.rs | 6 ++++-- coins/monero/wallet/polyseed/src/lib.rs | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/coins/monero/rpc/simple-request/tests/tests.rs b/coins/monero/rpc/simple-request/tests/tests.rs index 40f9209a..7b28f9a7 100644 --- a/coins/monero/rpc/simple-request/tests/tests.rs +++ b/coins/monero/rpc/simple-request/tests/tests.rs @@ -1,3 +1,6 @@ +use std::sync::OnceLock; +use tokio::sync::Mutex; + use monero_address::{Network, MoneroAddress}; // monero-rpc doesn't include a transport @@ -5,6 +8,8 @@ use monero_address::{Network, MoneroAddress}; // Accordingly, we test monero-rpc here (implicitly testing the simple-request transport) use monero_simple_request_rpc::*; +static SEQUENTIAL: OnceLock> = OnceLock::new(); + const ADDRESS: &str = "4B33mFPMq6mKi7Eiyd5XuyKRVMGVZz1Rqb9ZTyGApXW5d1aT7UBDZ89ewmnWFkzJ5wPd2SFbn313vCT8a4E2Qf4KQH4pNey"; @@ -12,6 +17,8 @@ const ADDRESS: &str = async fn test_rpc() { use monero_rpc::Rpc; + let guard = SEQUENTIAL.get_or_init(|| Mutex::new(())).lock().await; + let rpc = SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap(); @@ -53,12 +60,16 @@ async fn test_rpc() { } assert_eq!(blocks, actual_blocks); } + + drop(guard); } #[tokio::test] async fn test_decoy_rpc() { use monero_rpc::{Rpc, DecoyRpc}; + let guard = SEQUENTIAL.get_or_init(|| Mutex::new(())).lock().await; + let rpc = SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap(); @@ -101,6 +112,8 @@ async fn test_decoy_rpc() { #[allow(clippy::reversed_empty_ranges)] rpc.get_output_distribution(1 .. 0).await.unwrap_err(); } + + drop(guard); } // This test passes yet requires a mainnet node, which we don't have reliable access to in CI. @@ -109,6 +122,8 @@ async fn test_decoy_rpc() { async fn test_zero_out_tx_o_indexes() { use monero_rpc::Rpc; + let guard = SEQUENTIAL.get_or_init(|| Mutex::new(())).lock().await; + let rpc = SimpleRequestRpc::new("https://node.sethforprivacy.com".to_string()).await.unwrap(); assert_eq!( @@ -123,5 +138,7 @@ async fn test_zero_out_tx_o_indexes() { .unwrap(), Vec::::new() ); + + drop(guard); } */ diff --git a/coins/monero/wallet/address/src/lib.rs b/coins/monero/wallet/address/src/lib.rs index 26e0b08a..b3c43d8d 100644 --- a/coins/monero/wallet/address/src/lib.rs +++ b/coins/monero/wallet/address/src/lib.rs @@ -170,12 +170,14 @@ const MONERO_MAINNET_BYTES: AddressBytes = match AddressBytes::new(18, 19, 42, 7 Some(bytes) => bytes, None => panic!("mainnet byte constants conflicted"), }; -// https://github.com/monero-project/monero/blob/master/src/cryptonote_config.h#L277-L281 +// https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454 +// /src/cryptonote_config.h#L277-L281 const MONERO_STAGENET_BYTES: AddressBytes = match AddressBytes::new(24, 25, 36, 86) { Some(bytes) => bytes, None => panic!("stagenet byte constants conflicted"), }; -// https://github.com/monero-project/monero/blob/master/src/cryptonote_config.h#L262-L266 +// https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454 +// /src/cryptonote_config.h#L262-L266 const MONERO_TESTNET_BYTES: AddressBytes = match AddressBytes::new(53, 54, 63, 111) { Some(bytes) => bytes, None => panic!("testnet byte constants conflicted"), diff --git a/coins/monero/wallet/polyseed/src/lib.rs b/coins/monero/wallet/polyseed/src/lib.rs index 8c4b502f..7cd19ac7 100644 --- a/coins/monero/wallet/polyseed/src/lib.rs +++ b/coins/monero/wallet/polyseed/src/lib.rs @@ -101,7 +101,8 @@ const POLYSEED_SALT: &[u8] = b"POLYSEED key"; const POLYSEED_KEYGEN_ITERATIONS: u32 = 10000; // Polyseed technically supports multiple coins, and the value for Monero is 0 -// See: https://github.com/tevador/polyseed/blob/master/include/polyseed.h#L58 +// See: https://github.com/tevador/polyseed/blob/dfb05d8edb682b0e8f743b1b70c9131712ff4157 +// /include/polyseed.h#L57 const COIN: u16 = 0; /// An error when working with a Polyseed.