Skip to content

Commit

Permalink
ref: update handshake tests post common changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed Nov 30, 2022
1 parent 977eab1 commit 33ebf65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 60 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions node/tests/common/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub async fn beacon() -> Beacon<CurrentNetwork, ConsensusMemory<CurrentNetwork>>
None,
Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(),
&[],
sample_genesis_bloc(), // Should load the current network's genesis block.
None, // No CDN.
sample_genesis_block(), // Should load the current network's genesis block.
None, // No CDN.
None,
)
.await
Expand Down
62 changes: 4 additions & 58 deletions node/tests/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,17 @@

#![recursion_limit = "256"]

#[allow(dead_code)]
mod common;
use common::{sample_genesis_block, TestPeer};
use common::{node::*, test_peer::TestPeer};

use snarkos_account::Account;
use snarkos_node::{Beacon, Client, Prover, Validator};
use snarkos_node_tcp::P2P;
use snarkvm::prelude::{ConsensusMemory, Testnet3 as CurrentNetwork};

use pea2pea::Pea2Pea;

use std::{io, net::SocketAddr, str::FromStr};

/* Node constructors */

async fn beacon() -> Beacon<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Beacon::new(
"127.0.0.1:0".parse().unwrap(),
None,
Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(),
&[],
sample_genesis_block(),
None, // No CDN.
None,
)
.await
.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(),
&[],
sample_genesis_block(),
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(),
&[],
sample_genesis_block(),
None,
)
.await
.expect("couldn't create prover instance")
}

async fn validator() -> Validator<CurrentNetwork, ConsensusMemory<CurrentNetwork>> {
Validator::new(
"127.0.0.1:0".parse().unwrap(),
None,
Account::<CurrentNetwork>::from_str("APrivateKey1zkp2oVPTci9kKcUprnbzMwq95Di1MQERpYBhEeqvkrDirK1").unwrap(),
&[],
sample_genesis_block(),
None, // No CDN.
None,
)
.await
.expect("couldn't create validator instance")
}
use std::{io, net::SocketAddr};

// Trait to unify Pea2Pea and P2P traits.
#[async_trait::async_trait]
Expand Down Expand Up @@ -155,7 +101,7 @@ macro_rules! test_handshake {
let node = $crate::$node_type().await;

// Spin up a test peer (synthetic node).
let peer = $crate::common::TestPeer::$peer_type().await;
let peer = $crate::common::test_peer::TestPeer::$peer_type().await;

// Sets up the connection direction as described above.
if $is_initiator {
Expand Down

0 comments on commit 33ebf65

Please sign in to comment.