Skip to content

Commit

Permalink
Have RPC tests run sequentially
Browse files Browse the repository at this point in the history
Also corrects links pointing to branches to point to commits.
  • Loading branch information
kayabaNerve committed Jul 13, 2024
1 parent ba657e2 commit 70fe524
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
17 changes: 17 additions & 0 deletions coins/monero/rpc/simple-request/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
use std::sync::OnceLock;
use tokio::sync::Mutex;

use monero_address::{Network, MoneroAddress};

// monero-rpc doesn't include a transport
// We can't include the simple-request crate there as then we'd have a cyclical dependency
// Accordingly, we test monero-rpc here (implicitly testing the simple-request transport)
use monero_simple_request_rpc::*;

static SEQUENTIAL: OnceLock<Mutex<()>> = OnceLock::new();

const ADDRESS: &str =
"4B33mFPMq6mKi7Eiyd5XuyKRVMGVZz1Rqb9ZTyGApXW5d1aT7UBDZ89ewmnWFkzJ5wPd2SFbn313vCT8a4E2Qf4KQH4pNey";

#[tokio::test]
async fn test_rpc() {
use monero_rpc::Rpc;

let guard = SEQUENTIAL.get_or_init(|| Mutex::new(())).lock().await;

let rpc =
SimpleRequestRpc::new("http://serai:[email protected]:18081".to_string()).await.unwrap();

Expand Down Expand Up @@ -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:[email protected]:18081".to_string()).await.unwrap();

Expand Down Expand Up @@ -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.
Expand All @@ -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!(
Expand All @@ -123,5 +138,7 @@ async fn test_zero_out_tx_o_indexes() {
.unwrap(),
Vec::<u64>::new()
);
drop(guard);
}
*/
6 changes: 4 additions & 2 deletions coins/monero/wallet/address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
3 changes: 2 additions & 1 deletion coins/monero/wallet/polyseed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 70fe524

Please sign in to comment.