From e32d353543d4dee8edaada18a3e81a47a7ab04b1 Mon Sep 17 00:00:00 2001 From: hashmap Date: Tue, 27 Mar 2018 14:52:59 +0200 Subject: [PATCH] Externalize Grin User Agent (#880) Take the version from the root Cargo.toml Fixes #875 --- p2p/src/msg.rs | 4 ++-- p2p/tests/peer_handshake.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/src/msg.rs b/p2p/src/msg.rs index d3f948f1..0a17d70c 100644 --- a/p2p/src/msg.rs +++ b/p2p/src/msg.rs @@ -31,8 +31,8 @@ use types::*; /// Current latest version of the protocol pub const PROTOCOL_VERSION: u32 = 1; -/// Grin's user agent with current version (TODO externalize) -pub const USER_AGENT: &'static str = "MW/Grin 0.1"; +/// Grin's user agent with current version +pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION")); /// Magic number expected in the header of every message const MAGIC: [u8; 2] = [0x1e, 0xc5]; diff --git a/p2p/tests/peer_handshake.rs b/p2p/tests/peer_handshake.rs index 4e81cad3..90be2f1c 100644 --- a/p2p/tests/peer_handshake.rs +++ b/p2p/tests/peer_handshake.rs @@ -76,6 +76,8 @@ fn peer_handshake() { net_adapter, ).unwrap(); + assert!(peer.info.user_agent.ends_with(env!("CARGO_PKG_VERSION"))); + peer.start(socket); thread::sleep(time::Duration::from_secs(1));