Skip to content

Commit

Permalink
cucumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Oct 16, 2024
1 parent 7b2d1cb commit 67376b5
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 1,115 deletions.
952 changes: 0 additions & 952 deletions 2q

This file was deleted.

2 changes: 0 additions & 2 deletions Cargo.lock

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

12 changes: 2 additions & 10 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,13 @@ use tari_key_manager::{
key_manager_service::{KeyId, KeyManagerInterface},
SeedWords,
};
use tari_network::{
multiaddr::Multiaddr,
DiscoveryResult,
NetworkEvent,
NetworkHandle,
NetworkingService,
Peer,
ToPeerId,
};
use tari_network::{multiaddr::Multiaddr, NetworkEvent, NetworkHandle, NetworkingService, Peer, ToPeerId};
use tari_p2p::{auto_update::AutoUpdateConfig, peer_seeds::SeedPeer, PeerSeedsConfig};
use tari_script::{push_pubkey_script, CheckSigSchnorrSignature};
use tari_shutdown::Shutdown;
use tari_utilities::{encoding::MBase58, hex::Hex, ByteArray, SafePassword};
use tokio::{
sync::{broadcast, mpsc, oneshot::error::RecvError},
sync::{broadcast, mpsc},
time::{sleep, timeout},
};

Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_console_wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ use tari_common::{
};
use tari_common_types::wallet_types::WalletType;
use tari_key_manager::cipher_seed::CipherSeed;
#[cfg(all(unix, feature = "libtor"))]
use tari_libtor::tor::Tor;
// #[cfg(all(unix, feature = "libtor"))]
// use tari_libtor::tor::Tor;
use tari_shutdown::Shutdown;
use tari_utilities::SafePassword;
use tokio::runtime::Runtime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
use std::collections::HashMap;

use log::*;
use tari_network::{
identity::{sr25519::PublicKey, OtherVariantError},
public_key_to_string,
Peer,
};
use tari_utilities::hex::Hex;
use tari_network::{public_key_to_string, Peer};
use tokio::runtime::Handle;
use tui::{
backend::Backend,
Expand Down
6 changes: 2 additions & 4 deletions applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ use tokio::sync::mpsc;
use crate::ApplicationConfig;

const LOG_TARGET: &str = "c::bn::initialization";
/// The minimum buffer size for the base node pubsub_connector channel
const BASE_NODE_BUFFER_MIN_SIZE: usize = 30;

pub struct BaseNodeBootstrapper<'a, B> {
pub app_config: &'a ApplicationConfig,
Expand All @@ -83,7 +81,7 @@ where B: BlockchainBackend + 'static
#[allow(clippy::too_many_lines)]
pub async fn bootstrap(self) -> Result<ServiceHandles, ExitError> {
let mut base_node_config = self.app_config.base_node.clone();
let mut p2p_config = self.app_config.base_node.p2p.clone();
let p2p_config = self.app_config.base_node.p2p.clone();
let peer_seeds = &self.app_config.peer_seeds;

let mempool_config = base_node_config.mempool.service.clone();
Expand Down Expand Up @@ -163,7 +161,7 @@ where B: BlockchainBackend + 'static
}

async fn setup_rpc_services(
mut networking: NetworkHandle,
networking: NetworkHandle,
handles: &ServiceHandles,
db: AsyncBlockchainDb<B>,
config: &P2pConfig,
Expand Down
2 changes: 1 addition & 1 deletion base_layer/chat_ffi/src/application_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tari_chat_client::{
networking::Multiaddr,
};
use tari_common::configuration::{MultiaddrList, Network, StringList};
use tari_p2p::{PeerSeedsConfig, TransportConfig, TransportType};
use tari_p2p::PeerSeedsConfig;

use crate::error::{InterfaceError, LibChatError};

Expand Down
9 changes: 2 additions & 7 deletions base_layer/chat_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use callback_handler::CallbackContactStatusChange;
use libc::c_int;
use log::info;
use minotari_app_utilities::identity_management::setup_node_identity;
use tari_chat_client::{config::ApplicationConfig, networking::PeerFeatures, ChatClient as ChatClientTrait, Client};
use tari_chat_client::{config::ApplicationConfig, ChatClient as ChatClientTrait, Client};
use tari_common_types::tari_address::TariAddress;
use tari_contacts::contacts_service::handle::ContactsServiceHandle;
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -129,12 +129,7 @@ pub unsafe extern "C" fn create_chat_client(
ptr::null_mut::<ChatClient>()
};

let identity = match setup_node_identity(
(*config).chat_client.identity_file.clone(),
(*config).chat_client.p2p.public_addresses.clone().into_vec(),
true,
PeerFeatures::COMMUNICATION_NODE,
) {
let identity = match setup_node_identity((*config).chat_client.identity_file.clone(), true) {
Ok(node_id) => node_id,
_ => {
bad_identity("No identity loaded".to_string());
Expand Down
3 changes: 2 additions & 1 deletion base_layer/contacts/src/chat_client/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use std::{str::FromStr, sync::Arc, time::Duration};

use tari_contacts::contacts_service::{handle::ContactsServiceHandle, ContactsServiceInitializer};
pub use tari_network::multiaddr::Multiaddr;
use tari_network::{identity, NetworkHandle, Peer};
use tari_p2p::{
connector::InboundMessaging,
Expand All @@ -41,7 +42,7 @@ use crate::{
error::NetworkingError,
};

const LOG_TARGET: &str = "contacts::chat_client::networking";
const _LOG_TARGET: &str = "contacts::chat_client::networking";

pub async fn start(
node_identity: Arc<identity::Keypair>,
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub mod one_sided;
pub mod rolling_avg;
#[cfg(feature = "base_node")]
pub mod rolling_vec;
#[cfg(feature = "base_node")]
pub(crate) mod waiting_requests;

/// Hasher used in the DAN to derive masks and encrypted value keys
Expand Down
2 changes: 2 additions & 0 deletions base_layer/core/src/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#[cfg(feature = "base_node")]
pub const BLOCK_TOPIC: &str = "tari-block";
#[cfg(feature = "base_node")]
pub const TRANSACTION_TOPIC: &str = "tari-transaction";
22 changes: 11 additions & 11 deletions base_layer/p2p/src/peer_seeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl DnsSeedResolver {
}

/// Parsed information from a DNS seed record
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(try_from = "String", into = "String")]
pub struct SeedPeer {
pub public_key: RistrettoPublicKey,
Expand Down Expand Up @@ -115,16 +115,14 @@ impl FromStr for SeedPeer {

impl Display for SeedPeer {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}::{}",
self.public_key,
self.addresses
.iter()
.map(|ma| ma.to_string())
.collect::<Vec<_>>()
.join("::")
)
write!(f, "{}::", self.public_key)?;
for (i, addr) in self.addresses.iter().enumerate() {
write!(f, "{}", addr)?;
if i != self.addresses.len() - 1 {
write!(f, "::")?;
}
}
Ok(())
}
}

Expand Down Expand Up @@ -175,6 +173,8 @@ mod test {
"06e98e9c5eb52bd504836edec1878eccf12eb9f26a5fe5ec0e279423156e657a"
);
assert_eq!(seed.addresses.len(), 2);
let s2 = seed.to_string().parse::<SeedPeer>().unwrap();
assert_eq!(seed, s2);
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use std::{
slice,
str::FromStr,
sync::Arc,
time::Duration,
};

use chrono::{DateTime, Local};
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ minotari_app_grpc = { path = "../applications/minotari_app_grpc" }
minotari_app_utilities = { path = "../applications/minotari_app_utilities" }
minotari_node = { path = "../applications/minotari_node", features = ["metrics"] }
minotari_node_grpc_client = { path = "../clients/rust/base_node_grpc_client" }
tari_chat_client = { path = "../base_layer/contacts/src/chat_client" }
minotari_chat_ffi = { path = "../base_layer/chat_ffi" }
#tari_chat_client = { path = "../base_layer/contacts/src/chat_client" }
#minotari_chat_ffi = { path = "../base_layer/chat_ffi" }
tari_crypto = { version = "0.21.0" }
tari_common = { path = "../common" }
tari_common_types = { path = "../base_layer/common_types" }
Expand Down
23 changes: 19 additions & 4 deletions integration_tests/src/base_node_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,35 @@ use tari_common::{
configuration::{CommonConfig, MultiaddrList},
network_check::set_network_if_choice_valid,
};
use tari_network::identity;
use tari_crypto::ristretto::RistrettoPublicKey;
use tari_network::{identity, multiaddr::Multiaddr};
use tari_p2p::{auto_update::AutoUpdateConfig, Network, PeerSeedsConfig};
use tari_shutdown::Shutdown;
use tokio::task;
use tonic::transport::Channel;

use crate::{get_peer_addresses, get_port, wait_for_service, TariWorld};
use crate::{get_peer_seeds, get_port, wait_for_service, TariWorld};

#[derive(Clone)]
pub struct BaseNodeProcess {
pub name: String,
pub port: u64,
pub grpc_port: u64,
pub identity: identity::Keypair,
pub public_key: RistrettoPublicKey,
pub temp_dir_path: PathBuf,
pub is_seed_node: bool,
pub seed_nodes: Vec<String>,
pub config: BaseNodeConfig,
pub kill_signal: Shutdown,
}

impl BaseNodeProcess {
pub fn get_listen_addr(&self) -> Multiaddr {
format!("/ip4/127.0.0.1/tcp/{}", self.port).parse().unwrap()
}
}

impl Drop for BaseNodeProcess {
fn drop(&mut self) {
self.kill();
Expand Down Expand Up @@ -128,6 +136,13 @@ pub async fn spawn_base_node_with_config(
port,
grpc_port,
identity: base_node_identity.clone(),
public_key: base_node_identity
.public()
.clone()
.try_into_sr25519()
.unwrap()
.inner_key()
.clone(),
temp_dir_path: temp_dir_path.clone(),
is_seed_node,
seed_nodes: peers.clone(),
Expand All @@ -137,7 +152,7 @@ pub async fn spawn_base_node_with_config(

let name_cloned = bn_name.clone();

let peer_addresses = get_peer_addresses(world, &peers).await;
let peer_seeds = get_peer_seeds(world, &peers).await;

let mut common_config = CommonConfig::default();
common_config.base_path = temp_dir_path.clone();
Expand All @@ -148,7 +163,7 @@ pub async fn spawn_base_node_with_config(
base_node: base_node_config,
metrics: MetricsConfig::default(),
peer_seeds: PeerSeedsConfig {
peer_seeds: peer_addresses.into(),
peer_seeds: peer_seeds.into(),
dns_seeds_use_dnssec: false,
..Default::default()
},
Expand Down
1 change: 1 addition & 0 deletions integration_tests/src/ffi/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ impl Callbacks {
START.call_once(|| {
INSTANCE = Some(Self::default());
});
#[allow(static_mut_refs)]
INSTANCE.as_mut().unwrap()
}
}
Expand Down
23 changes: 14 additions & 9 deletions integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
use std::{convert::TryFrom, net::TcpListener, ops::Range, path::PathBuf, process, time::Duration};

use rand::Rng;
use tari_p2p::peer_seeds::SeedPeer;
use tokio::net::TcpSocket;

pub mod base_node_process;
pub mod chat_client;
pub mod chat_ffi;
// pub mod chat_client;
// pub mod chat_ffi;
pub mod ffi;
pub mod merge_mining_proxy;
pub mod miner;
Expand Down Expand Up @@ -57,13 +59,13 @@ pub fn get_base_dir() -> PathBuf {
}

pub async fn wait_for_service(port: u64) {
// The idea is that if the port is taken it means the service is running.
// If the port is not taken the service hasn't come up yet
// Check if we can open a socket to a port.
let max_tries = 4 * 60;
let mut attempts = 0;
let addr = ([127u8, 0, 0, 1], u16::try_from(port).unwrap()).into();

loop {
if TcpListener::bind(("127.0.0.1", u16::try_from(port).unwrap())).is_err() {
if TcpSocket::new_v4().unwrap().connect(addr).await.is_ok() {
return;
}

Expand All @@ -76,12 +78,15 @@ pub async fn wait_for_service(port: u64) {
}
}

pub async fn get_peer_addresses(world: &TariWorld, peers: &[String]) -> Vec<String> {
peers
pub async fn get_peer_seeds(world: &TariWorld, seed_peer_names: &[String]) -> Vec<String> {
seed_peer_names
.iter()
.map(|peer_string| {
let peer = world.base_nodes.get(peer_string.as_str()).unwrap().identity.to_peer();
peer.to_short_string()
let bn = world.base_nodes.get(peer_string.as_str()).unwrap();
SeedPeer::new(bn.public_key.clone(), vec![format!("/ip4/127.0.0.1/tcp/{}", bn.port)
.parse()
.unwrap()])
.to_string()
})
.collect()
}
Loading

0 comments on commit 67376b5

Please sign in to comment.