Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit b3f1fcc

Browse files
KolbyMLfedacking
authored andcommitted
simulators/portal: update gossip to put content tests (ethereum#1196)
1 parent 7fe60bd commit b3f1fcc

File tree

4 files changed

+29
-140
lines changed

4 files changed

+29
-140
lines changed

simulators/portal/Cargo.lock

Lines changed: 12 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

simulators/portal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
[dependencies]
88
alloy-rlp = "0.3.8"
99
alloy-primitives = "0.8.3"
10-
ethportal-api = { git = "https://github.com/ethereum/trin", rev = "4b212d4f3e8afa7b3298eebd4b4b6e3ec04d680f" }
10+
ethportal-api = { git = "https://github.com/ethereum/trin", rev = "5ae01c3ad2c69b4b003e0c206a961f2cf09f3be9" }
1111
futures = "0.3.25"
1212
hivesim = { git = "https://github.com/ethereum/hive", rev = "4408fc1de3fee3ac23acd25a812c117756af2f39" }
1313
itertools = "0.10.5"

simulators/portal/src/suites/history/interop.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::str::FromStr;
22

33
use alloy_primitives::Bytes;
4-
use ethportal_api::types::portal::{FindContentInfo, GetContentInfo};
4+
use ethportal_api::types::portal::{FindContentInfo, GetContentInfo, PutContentInfo};
55
use ethportal_api::types::portal_wire::MAX_PORTAL_CONTENT_PAYLOAD_SIZE;
66
use ethportal_api::{
77
ContentValue, Discv5ApiClient, HistoryContentKey, HistoryContentValue, HistoryNetworkApiClient,
@@ -180,10 +180,10 @@ dyn_async! {
180180
// Test gossiping a collection of blocks to node B (B will gossip back to A)
181181
test.run(
182182
NClientTestSpec {
183-
name: format!("GOSSIP blocks from A:{} --> B:{}", client_a.name, client_b.name),
183+
name: format!("PUT CONTENT blocks from A:{} --> B:{}", client_a.name, client_b.name),
184184
description: "".to_string(),
185185
always_run: false,
186-
run: test_gossip_two_nodes,
186+
run: test_put_content_two_nodes,
187187
environments: None,
188188
test_data: content.clone(),
189189
clients: vec![client_a.clone(), client_b.clone()],
@@ -425,7 +425,7 @@ dyn_async! {
425425
}
426426

427427
dyn_async! {
428-
async fn test_gossip_two_nodes<'a> (clients: Vec<Client>, test_data: TestData) {
428+
async fn test_put_content_two_nodes<'a> (clients: Vec<Client>, test_data: TestData) {
429429
let (client_a, client_b) = match clients.iter().collect_tuple() {
430430
Some((client_a, client_b)) => (client_a, client_b),
431431
None => panic!("Unable to get expected amount of clients from NClientTestSpec"),
@@ -445,10 +445,10 @@ dyn_async! {
445445

446446
// With default node settings nodes should be storing all content
447447
for (content_key, content_value) in test_data.clone() {
448-
match client_a.rpc.gossip(content_key.clone(), content_value.encode()).await {
449-
Ok(nodes_gossiped_to) => {
450-
if nodes_gossiped_to != 1 {
451-
panic!("We expected to gossip to 1 node instead we gossiped to: {nodes_gossiped_to}");
448+
match client_a.rpc.put_content(content_key.clone(), content_value.encode()).await {
449+
Ok(PutContentInfo { peer_count, .. }) => {
450+
if peer_count != 1 {
451+
panic!("We expected to gossip to 1 node instead we gossiped to: {peer_count}");
452452
}
453453
}
454454
Err(err) => panic!("Unable to get received content: {err:?}"),

simulators/portal/src/suites/state/interop.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ethportal_api::jsonrpsee::http_client::HttpClient;
99
use ethportal_api::types::execution::header_with_proof::{
1010
BlockHeaderProof, HeaderWithProof, SszNone,
1111
};
12-
use ethportal_api::types::portal::{FindContentInfo, GetContentInfo};
12+
use ethportal_api::types::portal::{FindContentInfo, GetContentInfo, PutContentInfo};
1313
use ethportal_api::types::portal_wire::MAX_PORTAL_CONTENT_PAYLOAD_SIZE;
1414
use ethportal_api::utils::bytes::hex_encode;
1515
use ethportal_api::{
@@ -196,10 +196,10 @@ dyn_async! {
196196
// Test gossiping a collection of blocks to node B (B will gossip back to A)
197197
test.run(
198198
NClientTestSpec {
199-
name: format!("GOSSIP blocks from A:{} --> B:{}", client_a.name, client_b.name),
199+
name: format!("PUT CONTENT blocks from A:{} --> B:{}", client_a.name, client_b.name),
200200
description: "".to_string(),
201201
always_run: false,
202-
run: test_gossip_two_nodes,
202+
run: test_put_content_two_nodes,
203203
environments: environments.clone(),
204204
test_data: content.clone(),
205205
clients: vec![client_a.clone(), client_b.clone()],
@@ -439,7 +439,7 @@ dyn_async! {
439439
}
440440

441441
dyn_async! {
442-
async fn test_gossip_two_nodes<'a> (clients: Vec<Client>, test_data: Vec<TestData>) {
442+
async fn test_put_content_two_nodes<'a> (clients: Vec<Client>, test_data: Vec<TestData>) {
443443
let (client_a, client_b) = match clients.iter().collect_tuple() {
444444
Some((client_a, client_b)) => (client_a, client_b),
445445
None => panic!("Unable to get expected amount of clients from NClientTestSpec"),
@@ -461,10 +461,10 @@ dyn_async! {
461461
for TestData { header, key: content_key, offer_value: content_offer_value, .. } in test_data.clone() {
462462
store_header(header, &client_b.rpc).await;
463463

464-
match client_a.rpc.gossip(content_key.clone(), content_offer_value.encode()).await {
465-
Ok(nodes_gossiped_to) => {
466-
if nodes_gossiped_to != 1 {
467-
panic!("We expected to gossip to 1 node instead we gossiped to: {nodes_gossiped_to}");
464+
match client_a.rpc.put_content(content_key.clone(), content_offer_value.encode()).await {
465+
Ok(PutContentInfo { peer_count, .. }) => {
466+
if peer_count != 1 {
467+
panic!("We expected to gossip to 1 node instead we gossiped to: {peer_count}");
468468
}
469469
}
470470
Err(err) => panic!("Unable to get received content: {err:?}"),

0 commit comments

Comments
 (0)