-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update portal_*Offer
to handle multiple pieces of content
#1507
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add test here as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will remove |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,19 +22,12 @@ pub async fn test_unpopulated_offer(peertest: &Peertest, target: &Client) { | |
info!("Testing Unpopulated OFFER/ACCEPT flow"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer "unpopulated" flow. If I'm not mistaken, we no longer have "unpopulated" flow. Either rename/update current test, or remove it if you think it's redundant. |
||
|
||
let (content_key, content_value) = fixture_header_by_hash(); | ||
// Store content to offer in the testnode db | ||
let store_result = target | ||
.store(content_key.clone(), content_value.encode()) | ||
.await | ||
.unwrap(); | ||
|
||
assert!(store_result); | ||
|
||
// Send wire offer request from testnode to bootnode | ||
let result = target | ||
.wire_offer( | ||
.offer( | ||
Enr::from_str(&peertest.bootnode.enr.to_base64()).unwrap(), | ||
vec![content_key.clone()], | ||
vec![(content_key.clone(), content_value.encode())], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -49,40 +42,14 @@ pub async fn test_unpopulated_offer(peertest: &Peertest, target: &Client) { | |
); | ||
} | ||
|
||
pub async fn test_unpopulated_offer_fails_with_missing_content( | ||
peertest: &Peertest, | ||
target: &Client, | ||
) { | ||
info!("Testing Unpopulated OFFER/ACCEPT flow with missing content"); | ||
|
||
let (content_key, _content_value) = fixture_header_by_hash(); | ||
|
||
// validate that wire offer fails if content not available locally | ||
match target | ||
.wire_offer( | ||
Enr::from_str(&peertest.bootnode.enr.to_base64()).unwrap(), | ||
vec![content_key.clone()], | ||
) | ||
.await | ||
{ | ||
Ok(_) => panic!("Unpopulated offer should have failed"), | ||
Err(e) => { | ||
assert!(e | ||
.to_string() | ||
.contains("Content key not found in local store")); | ||
} | ||
} | ||
} | ||
|
||
pub async fn test_populated_offer(peertest: &Peertest, target: &Client) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along with @morph-dev comment above, you can update the name of this test & log to just |
||
info!("Testing Populated Offer/ACCEPT flow"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit |
||
|
||
let (content_key, content_value) = fixture_header_by_hash(); | ||
let result = target | ||
.offer( | ||
Enr::from_str(&peertest.bootnode.enr.to_base64()).unwrap(), | ||
content_key.clone(), | ||
content_value.encode(), | ||
vec![(content_key.clone(), content_value.encode())], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -144,8 +111,7 @@ pub async fn test_offer_propagates_gossip(peertest: &Peertest, target: &Client) | |
target | ||
.offer( | ||
peertest.bootnode.enr.clone(), | ||
content_key.clone(), | ||
content_value.encode(), | ||
vec![(content_key.clone(), content_value.encode())], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -178,15 +144,10 @@ pub async fn test_offer_propagates_gossip_with_large_content(peertest: &Peertest | |
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(body_key.clone(), body_value.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
target | ||
.wire_offer( | ||
.offer( | ||
peertest.bootnode.ipc_client.node_info().await.unwrap().enr, | ||
vec![body_key.clone()], | ||
vec![(body_key.clone(), body_value.encode())], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -221,8 +182,7 @@ pub async fn test_offer_propagates_gossip_multiple_content_values( | |
target | ||
.offer( | ||
peertest.bootnode.enr.clone(), | ||
header_key.clone(), | ||
header_value.encode(), | ||
vec![(header_key.clone(), header_value.encode())], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -241,23 +201,14 @@ pub async fn test_offer_propagates_gossip_multiple_content_values( | |
wait_for_history_content(&peertest.nodes[0].ipc_client, header_key.clone()).await, | ||
); | ||
|
||
// Store content to offer in the testnode db | ||
let store_result = target | ||
.store(body_key.clone(), body_value.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(receipts_key.clone(), receipts_value.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
|
||
// here everythings stored in target | ||
target | ||
.wire_offer( | ||
.offer( | ||
peertest.bootnode.ipc_client.node_info().await.unwrap().enr, | ||
vec![body_key.clone(), receipts_key.clone()], | ||
vec![ | ||
(body_key.clone(), body_value.encode()), | ||
(receipts_key.clone(), receipts_value.encode()), | ||
], | ||
) | ||
.await | ||
.unwrap(); | ||
|
@@ -308,16 +259,6 @@ pub async fn test_offer_propagates_gossip_multiple_large_content_values( | |
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(body_key_1.clone(), body_value_1.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(receipts_key_1.clone(), receipts_value_1.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
|
||
let (header_key_2, header_value_2) = fixture_header_by_hash_with_proof_15040641(); | ||
let (body_key_2, body_value_2) = fixture_block_body_15040641(); | ||
|
@@ -329,25 +270,15 @@ pub async fn test_offer_propagates_gossip_multiple_large_content_values( | |
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(body_key_2.clone(), body_value_2.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
let store_result = target | ||
.store(receipts_key_2.clone(), receipts_value_2.encode()) | ||
.await | ||
.unwrap(); | ||
assert!(store_result); | ||
|
||
target | ||
.wire_offer( | ||
.offer( | ||
peertest.bootnode.ipc_client.node_info().await.unwrap().enr, | ||
vec![ | ||
body_key_1.clone(), | ||
receipts_key_1.clone(), | ||
body_key_2.clone(), | ||
receipts_key_2.clone(), | ||
(body_key_1.clone(), body_value_1.encode()), | ||
(receipts_key_1.clone(), receipts_value_1.encode()), | ||
(body_key_2.clone(), body_value_2.encode()), | ||
(receipts_key_2.clone(), receipts_value_2.encode()), | ||
], | ||
) | ||
.await | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
MAX_CONTENT_KEYS_PER_OFFER