Skip to content

Commit

Permalink
test: increase handshake coverage to all node types
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed Nov 24, 2022
1 parent f3c478a commit f4d2c8d
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion node/tests/new_beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ async fn beacon() -> Beacon<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
.expect("couldn't create beacon instance")
}

async fn client() -> Client<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Client::new(
"127.0.0.1:0".parse().unwrap(),
Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(),
&[],
None,
)
.await
.expect("couldn't create client instance")
}

async fn prover() -> Prover<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Prover::new(
"127.0.0.1:0".parse().unwrap(),
Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(),
&[],
None,
)
.await
.expect("couldn't create prover instance")
}

async fn validator() -> Validator<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Validator::new(
"127.0.0.1:0".parse().unwrap(),
Expand All @@ -55,7 +77,7 @@ async fn validator() -> Validator<CurrentNetwork, ConsensusMemory<CurrentNetwork
None,
)
.await
.expect("couldn't create beacon instance")
.expect("couldn't create validator instance")
}

// Trait to unify Pea2Pea and P2P traits.
Expand Down Expand Up @@ -177,6 +199,42 @@ mod beacon {
}
}

mod client {
// Initiator side (full node connects to full node).
test_handshake! {
client -> beacon,
client -> client,
client -> validator,
client -> prover
}

// Responder side (synthetic peer connects to full node).
test_handshake! {
client <- beacon,
client <- client,
client <- validator,
client <- prover
}
}

mod prover {
// Initiator side (full node connects to full node).
test_handshake! {
prover -> beacon,
prover -> client,
prover -> validator,
prover -> prover
}

// Responder side (synthetic peer connects to full node).
test_handshake! {
prover <- beacon,
prover <- client,
prover <- validator,
prover <- prover
}
}

mod validator {
// Initiator side (full node connects to full node).
test_handshake! {
Expand Down

0 comments on commit f4d2c8d

Please sign in to comment.