diff --git a/.dockerignore b/.dockerignore index 0eb8c7df0..d9d6ac512 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,7 +6,6 @@ !Cargo.toml !/bin !/crates -!/ethportal-peertest !/portal-bridge !/testing !/trin-execution diff --git a/Cargo.lock b/Cargo.lock index 2cade4d47..b5c164d94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2283,6 +2283,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", + "serial_test", "tempfile", "tokio", "tracing", diff --git a/Cargo.toml b/Cargo.toml index efa0dff1d..ac554fd80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,9 @@ members = [ "crates/subnetworks/state", "crates/utils", "crates/validation", - "ethportal-peertest", "portal-bridge", "testing/ef-tests", + "testing/ethportal-peertest", "trin-execution", "utp-testing", ] diff --git a/ethportal-peertest/Cargo.toml b/testing/ethportal-peertest/Cargo.toml similarity index 96% rename from ethportal-peertest/Cargo.toml rename to testing/ethportal-peertest/Cargo.toml index 1d70138b6..d2357303e 100644 --- a/ethportal-peertest/Cargo.toml +++ b/testing/ethportal-peertest/Cargo.toml @@ -44,3 +44,6 @@ url.workspace = true [target.'cfg(windows)'.dependencies] uds_windows.workspace = true + +[dev-dependencies] +serial_test.workspace = true diff --git a/ethportal-peertest/README.md b/testing/ethportal-peertest/README.md similarity index 100% rename from ethportal-peertest/README.md rename to testing/ethportal-peertest/README.md diff --git a/ethportal-peertest/src/lib.rs b/testing/ethportal-peertest/src/lib.rs similarity index 100% rename from ethportal-peertest/src/lib.rs rename to testing/ethportal-peertest/src/lib.rs diff --git a/ethportal-peertest/src/scenarios/basic.rs b/testing/ethportal-peertest/src/scenarios/basic.rs similarity index 100% rename from ethportal-peertest/src/scenarios/basic.rs rename to testing/ethportal-peertest/src/scenarios/basic.rs diff --git a/ethportal-peertest/src/scenarios/bridge.rs b/testing/ethportal-peertest/src/scenarios/bridge.rs similarity index 91% rename from ethportal-peertest/src/scenarios/bridge.rs rename to testing/ethportal-peertest/src/scenarios/bridge.rs index 09ee40187..0750014ee 100644 --- a/ethportal-peertest/src/scenarios/bridge.rs +++ b/testing/ethportal-peertest/src/scenarios/bridge.rs @@ -22,7 +22,7 @@ use crate::{ pub async fn test_history_bridge(peertest: &Peertest, portal_client: &HttpClient) { let header_oracle = HeaderOracle::default(); let epoch_acc_path = "validation_assets/epoch_acc.bin".into(); - let mode = BridgeMode::Test("./test_assets/portalnet/bridge_data.json".into()); + let mode = BridgeMode::Test("./../../test_assets/portalnet/bridge_data.json".into()); // url doesn't matter, we're not making any requests let client_url = Url::parse("http://www.null.com").unwrap(); let execution_api = ExecutionApi::new( @@ -54,7 +54,7 @@ pub async fn test_history_bridge(peertest: &Peertest, portal_client: &HttpClient } pub async fn test_beacon_bridge(peertest: &Peertest, portal_client: &HttpClient) { - let mode = BridgeMode::Test("./test_assets/portalnet/beacon_bridge_data.yaml".into()); + let mode = BridgeMode::Test("./../../test_assets/portalnet/beacon_bridge_data.yaml".into()); // Wait for bootnode to start sleep(Duration::from_secs(1)).await; // url doesn't matter, we're not making any requests @@ -69,7 +69,7 @@ pub async fn test_beacon_bridge(peertest: &Peertest, portal_client: &HttpClient) let bridge = BeaconBridge::new(consensus_api, mode, portal_client.clone()); bridge.launch().await; - let value = std::fs::read_to_string("./test_assets/portalnet/beacon_bridge_data.yaml") + let value = std::fs::read_to_string("./../../test_assets/portalnet/beacon_bridge_data.yaml") .expect("cannot find test asset"); let value: Value = serde_yaml::from_str(&value).unwrap(); let content_key = BeaconContentKey::deserialize(&value[0]["content_key"]).unwrap(); diff --git a/ethportal-peertest/src/scenarios/eth_rpc.rs b/testing/ethportal-peertest/src/scenarios/eth_rpc.rs similarity index 100% rename from ethportal-peertest/src/scenarios/eth_rpc.rs rename to testing/ethportal-peertest/src/scenarios/eth_rpc.rs diff --git a/ethportal-peertest/src/scenarios/find.rs b/testing/ethportal-peertest/src/scenarios/find.rs similarity index 100% rename from ethportal-peertest/src/scenarios/find.rs rename to testing/ethportal-peertest/src/scenarios/find.rs diff --git a/ethportal-peertest/src/scenarios/mod.rs b/testing/ethportal-peertest/src/scenarios/mod.rs similarity index 100% rename from ethportal-peertest/src/scenarios/mod.rs rename to testing/ethportal-peertest/src/scenarios/mod.rs diff --git a/ethportal-peertest/src/scenarios/offer_accept.rs b/testing/ethportal-peertest/src/scenarios/offer_accept.rs similarity index 100% rename from ethportal-peertest/src/scenarios/offer_accept.rs rename to testing/ethportal-peertest/src/scenarios/offer_accept.rs diff --git a/ethportal-peertest/src/scenarios/paginate.rs b/testing/ethportal-peertest/src/scenarios/paginate.rs similarity index 100% rename from ethportal-peertest/src/scenarios/paginate.rs rename to testing/ethportal-peertest/src/scenarios/paginate.rs diff --git a/ethportal-peertest/src/scenarios/put_content.rs b/testing/ethportal-peertest/src/scenarios/put_content.rs similarity index 100% rename from ethportal-peertest/src/scenarios/put_content.rs rename to testing/ethportal-peertest/src/scenarios/put_content.rs diff --git a/ethportal-peertest/src/scenarios/state.rs b/testing/ethportal-peertest/src/scenarios/state.rs similarity index 100% rename from ethportal-peertest/src/scenarios/state.rs rename to testing/ethportal-peertest/src/scenarios/state.rs diff --git a/ethportal-peertest/src/scenarios/utp.rs b/testing/ethportal-peertest/src/scenarios/utp.rs similarity index 100% rename from ethportal-peertest/src/scenarios/utp.rs rename to testing/ethportal-peertest/src/scenarios/utp.rs diff --git a/ethportal-peertest/src/scenarios/validation.rs b/testing/ethportal-peertest/src/scenarios/validation.rs similarity index 100% rename from ethportal-peertest/src/scenarios/validation.rs rename to testing/ethportal-peertest/src/scenarios/validation.rs diff --git a/ethportal-peertest/src/utils.rs b/testing/ethportal-peertest/src/utils.rs similarity index 90% rename from ethportal-peertest/src/utils.rs rename to testing/ethportal-peertest/src/utils.rs index fd347217c..5afff57f0 100644 --- a/ethportal-peertest/src/utils.rs +++ b/testing/ethportal-peertest/src/utils.rs @@ -116,20 +116,21 @@ fn read_fixture(file_name: &str) -> (HistoryContentKey, HistoryContentValue) { /// History HeaderWithProof content key & value /// Block #1000010 pub fn fixture_header_by_hash_1000010() -> (HistoryContentKey, HistoryContentValue) { - read_fixture("portal-spec-tests/tests/mainnet/history/headers_with_proof/1000010.yaml") + read_fixture("../../portal-spec-tests/tests/mainnet/history/headers_with_proof/1000010.yaml") } /// History HeaderByHash content key & value /// Block #14764013 (pre-merge) pub fn fixture_header_by_hash() -> (HistoryContentKey, HistoryContentValue) { - read_fixture("portal-spec-tests/tests/mainnet/history/headers_with_proof/14764013.yaml") + read_fixture("../../portal-spec-tests/tests/mainnet/history/headers_with_proof/14764013.yaml") } /// History HeaderByNumber content key & value /// Block #14764013 (pre-merge) pub fn fixture_header_by_number() -> (HistoryContentKey, HistoryContentValue) { - let (_, content_value) = - read_fixture("portal-spec-tests/tests/mainnet/history/headers_with_proof/14764013.yaml"); + let (_, content_value) = read_fixture( + "../../portal-spec-tests/tests/mainnet/history/headers_with_proof/14764013.yaml", + ); // Create a content key from the block number let HistoryContentValue::BlockHeaderWithProof(header_with_proof) = content_value.clone() else { @@ -144,13 +145,13 @@ pub fn fixture_header_by_number() -> (HistoryContentKey, HistoryContentValue) { /// History BlockBody content key & value /// Block #14764013 (pre-merge) pub fn fixture_block_body() -> (HistoryContentKey, HistoryContentValue) { - read_fixture("portal-spec-tests/tests/mainnet/history/bodies/14764013.yaml") + read_fixture("../../portal-spec-tests/tests/mainnet/history/bodies/14764013.yaml") } /// History Receipts content key & value /// Block #14764013 (pre-merge) pub fn fixture_receipts() -> (HistoryContentKey, HistoryContentValue) { - read_fixture("portal-spec-tests/tests/mainnet/history/receipts/14764013.yaml") + read_fixture("../../portal-spec-tests/tests/mainnet/history/receipts/14764013.yaml") } enum DependentType { @@ -208,7 +209,7 @@ fn read_binary_history_fixture( dependent: Option, ) -> (HistoryContentKey, HistoryContentValue) { let header_value = std::fs::read(format!( - "test_assets/mainnet/large_content/{block_number}/header.bin" + "../../test_assets/mainnet/large_content/{block_number}/header.bin" )) .unwrap(); let header_content_value: HeaderWithProof = @@ -217,7 +218,7 @@ fn read_binary_history_fixture( match dependent { Some(dependent_type) => { let dependent_value = std::fs::read(format!( - "test_assets/mainnet/large_content/{block_number}/{dependent_type}.bin" + "../../test_assets/mainnet/large_content/{block_number}/{dependent_type}.bin" )) .unwrap(); match dependent_type { @@ -296,15 +297,19 @@ fn read_state_fixture(file_name: &str) -> Vec { } pub fn fixtures_state_account_trie_node() -> Vec { - read_state_fixture("portal-spec-tests/tests/mainnet/state/validation/account_trie_node.yaml") + read_state_fixture( + "../../portal-spec-tests/tests/mainnet/state/validation/account_trie_node.yaml", + ) } pub fn fixtures_state_contract_storage_trie_node() -> Vec { read_state_fixture( - "portal-spec-tests/tests/mainnet/state/validation/contract_storage_trie_node.yaml", + "../../portal-spec-tests/tests/mainnet/state/validation/contract_storage_trie_node.yaml", ) } pub fn fixtures_state_contract_bytecode() -> Vec { - read_state_fixture("portal-spec-tests/tests/mainnet/state/validation/contract_bytecode.yaml") + read_state_fixture( + "../../portal-spec-tests/tests/mainnet/state/validation/contract_bytecode.yaml", + ) } diff --git a/tests/rpc_server.rs b/testing/ethportal-peertest/tests/rpc_server.rs similarity index 97% rename from tests/rpc_server.rs rename to testing/ethportal-peertest/tests/rpc_server.rs index 8e587cc8b..fc9ec0f03 100644 --- a/tests/rpc_server.rs +++ b/testing/ethportal-peertest/tests/rpc_server.rs @@ -11,20 +11,19 @@ use alloy::{ transports::RpcError, }; use ethportal_api::{ - types::{ - cli::{TrinConfig, DEFAULT_WEB3_IPC_PATH}, - execution::{block_body::BlockBody, header_with_proof::HeaderWithProof}, - }, + types::execution::{block_body::BlockBody, header_with_proof::HeaderWithProof}, utils::bytes::{hex_decode, hex_encode}, ContentValue, Header, HistoryContentKey, HistoryContentValue, HistoryNetworkApiClient, }; use jsonrpsee::async_client::Client; +use portalnet::constants::DEFAULT_WEB3_IPC_PATH; use rpc::RpcServerHandle; use serde_yaml::Value; use serial_test::serial; use ssz::Decode; mod utils; +use trin::cli::TrinConfig; use utils::init_tracing; async fn setup_web3_server() -> (RpcServerHandle, RootProvider, Client) { @@ -313,7 +312,7 @@ fn assert_header(actual: &RpcHeader, expected: &Header) { } fn get_full_block() -> (HeaderWithProof, BlockBody) { - let file = fs::read_to_string("crates/validation/src/assets/hive/blocks.yaml").unwrap(); + let file = fs::read_to_string("../../crates/validation/src/assets/hive/blocks.yaml").unwrap(); let value: Value = serde_yaml::from_str(&file).unwrap(); let all_blocks = value.as_sequence().unwrap(); let post_shanghai = all_blocks.last().unwrap(); diff --git a/tests/self_peertest.rs b/testing/ethportal-peertest/tests/self_peertest.rs similarity index 99% rename from tests/self_peertest.rs rename to testing/ethportal-peertest/tests/self_peertest.rs index 7a48ca630..e010dd153 100644 --- a/tests/self_peertest.rs +++ b/testing/ethportal-peertest/tests/self_peertest.rs @@ -4,16 +4,15 @@ use std::{ net::{IpAddr, Ipv4Addr}, }; -use ethportal_api::types::{ - cli::{TrinConfig, DEFAULT_WEB3_HTTP_ADDRESS, DEFAULT_WEB3_IPC_PATH}, - network::{Network, Subnetwork}, -}; +use ethportal_api::types::network::{Network, Subnetwork}; use ethportal_peertest as peertest; use ethportal_peertest::Peertest; use jsonrpsee::{async_client::Client, http_client::HttpClient}; +use portalnet::constants::{DEFAULT_WEB3_HTTP_ADDRESS, DEFAULT_WEB3_IPC_PATH}; use rpc::RpcServerHandle; use serial_test::serial; use tokio::time::{sleep, Duration}; +use trin::cli::TrinConfig; mod utils; diff --git a/tests/utils/mod.rs b/testing/ethportal-peertest/tests/utils/mod.rs similarity index 100% rename from tests/utils/mod.rs rename to testing/ethportal-peertest/tests/utils/mod.rs