node: Test fetch comes from right place

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier 2022-09-09 20:43:25 +02:00
parent 825bd3f5e1
commit a47463a664
No known key found for this signature in database
3 changed files with 23 additions and 15 deletions

27
Cargo.lock generated
View File

@ -593,7 +593,7 @@ dependencies = [
[[package]]
name = "nakamoto-net"
version = "0.3.0"
source = "git+https://github.com/cloudhead/nakamoto?branch=master#90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
source = "git+https://github.com/cloudhead/nakamoto?rev=90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb#90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
dependencies = [
"crossbeam-channel",
"fastrand",
@ -604,7 +604,7 @@ dependencies = [
[[package]]
name = "nakamoto-net-poll"
version = "0.3.0"
source = "git+https://github.com/cloudhead/nakamoto?branch=master#90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
source = "git+https://github.com/cloudhead/nakamoto?rev=90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb#90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
dependencies = [
"crossbeam-channel",
"libc",
@ -642,6 +642,17 @@ dependencies = [
"autocfg",
]
[[package]]
name = "olpc-cjson"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ca49fe685014bbf124ee547da94ed7bb65a6eb9dc9c4711773c081af96a39c"
dependencies = [
"serde",
"serde_json",
"unicode-normalization",
]
[[package]]
name = "once_cell"
version = "1.14.0"
@ -782,6 +793,7 @@ version = "0.2.0"
dependencies = [
"anyhow",
"bs58",
"byteorder",
"chrono",
"colored",
"crossbeam-channel",
@ -795,6 +807,7 @@ dependencies = [
"nakamoto-net",
"nakamoto-net-poll",
"nonempty",
"olpc-cjson",
"once_cell",
"quickcheck",
"quickcheck_macros",
@ -805,7 +818,6 @@ dependencies = [
"siphasher",
"tempfile",
"thiserror",
"toml",
]
[[package]]
@ -1029,15 +1041,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]
[[package]]
name = "typenum"
version = "1.15.0"

View File

@ -11,10 +11,10 @@ tag = "cycle/2022-07-12"
[patch.crates-io.nakamoto-net]
git = "https://github.com/cloudhead/nakamoto"
branch = "master"
rev = "90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
version = "0.3.0"
[patch.crates-io.nakamoto-net-poll]
git = "https://github.com/cloudhead/nakamoto"
branch = "master"
rev = "90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
version = "0.3.0"

View File

@ -435,11 +435,16 @@ fn test_push_and_pull() {
// Alice announces her refs.
// We now expect Eve to fetch Alice's project from Alice.
// Then we expect Bob to fetch Alice's project from Eve.
// TODO: Check that Bob is fetching from Eve and not Alice, via an event.
alice.command(protocol::Command::AnnounceRefsUpdate(proj_id.clone()));
sim.run_while([&mut alice, &mut bob, &mut eve], |s| !s.is_settled());
assert!(eve.storage().get(&proj_id).unwrap().is_some());
assert!(bob.storage().get(&proj_id).unwrap().is_some());
assert_matches!(
sim.events(&bob.ip).next(),
Some(protocol::Event::RefsFetched { from, .. })
if from == eve.git_url(),
"Bob fetched from Eve"
);
}
#[test]