Skip to content

Commit

Permalink
refactor: move crate ethportal-peertest to `testing/ethportal-peert…
Browse files Browse the repository at this point in the history
…est`
  • Loading branch information
KolbyML committed Jan 13, 2025
1 parent dbdf060 commit c833ddd
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 25 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!Cargo.toml
!/bin
!/crates
!/ethportal-peertest
!/portal-bridge
!/testing
!/trin-execution
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ url.workspace = true

[target.'cfg(windows)'.dependencies]
uds_windows.workspace = true

[dev-dependencies]
serial_test.workspace = true
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -208,7 +209,7 @@ fn read_binary_history_fixture(
dependent: Option<DependentType>,
) -> (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 =
Expand All @@ -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 {
Expand Down Expand Up @@ -296,15 +297,19 @@ fn read_state_fixture(file_name: &str) -> Vec<StateFixture> {
}

pub fn fixtures_state_account_trie_node() -> Vec<StateFixture> {
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<StateFixture> {
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<StateFixture> {
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",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PubSubFrontend>, Client) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
File renamed without changes.

0 comments on commit c833ddd

Please sign in to comment.