p2p: fix test for user agent

This commit is contained in:
ardocrat
2026-05-02 21:14:36 +03:00
parent f5d59e595e
commit fb87a26d3f
2 changed files with 7 additions and 9 deletions
-4
View File
@@ -45,10 +45,6 @@ pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
fn version() -> &'static str {
built_info::GIT_COMMIT_HASH_SHORT.unwrap_or("+")
}
/// Grin's user agent with current version
pub fn user_agent() -> String {
format!(
+7 -5
View File
@@ -18,15 +18,15 @@ use grin_p2p as p2p;
use grin_util as util;
use grin_util::StopState;
use std::net::{SocketAddr, TcpListener, TcpStream};
use std::sync::Arc;
use std::{thread, time};
use crate::core::core::hash::Hash;
use crate::core::global;
use crate::core::pow::Difficulty;
use crate::p2p::types::PeerAddr;
use crate::p2p::Peer;
use grin_p2p::msg::built_info;
use std::net::{SocketAddr, TcpListener, TcpStream};
use std::sync::Arc;
use std::{thread, time};
fn open_port() -> u16 {
// use port 0 to allow the OS to assign an open port
@@ -88,10 +88,12 @@ fn peer_handshake() {
)
.unwrap();
let git_hash =
built_info::GIT_COMMIT_HASH_SHORT.map_or_else(|| "+".to_owned(), |v| ".".to_owned() + v);
assert!(peer
.info
.user_agent
.ends_with(format!("{}+", env!("CARGO_PKG_VERSION")).as_str()));
.ends_with(format!("{}{}", env!("CARGO_PKG_VERSION"), git_hash).as_str()));
thread::sleep(time::Duration::from_secs(1));