mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
cli: rad node connect using only NodeId
Allow the `rad node connect` command to use only a `NodeId` when connecting. The `NodeId` is used to connect to known addresses, and will stop at the first address that is connected to.
This commit is contained in:
committed by
Fintan Halpenny
parent
76e00a34ea
commit
895ca5d025
@@ -958,6 +958,49 @@ fn rad_node_connect() {
|
||||
assert!(session.state.is_connected());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_node_connect_without_address() {
|
||||
logger::init(log::Level::Debug);
|
||||
let mut environment = Environment::new();
|
||||
let mut alice = environment.node(Config::test(Alias::new("alice")));
|
||||
let bob = environment.node(Config::test(Alias::new("bob")));
|
||||
let working = tempfile::tempdir().unwrap();
|
||||
let bob = bob.spawn();
|
||||
|
||||
alice
|
||||
.db
|
||||
.addresses_mut()
|
||||
.insert(
|
||||
&bob.id,
|
||||
PROTOCOL_VERSION,
|
||||
node::Features::SEED,
|
||||
&Alias::new("bob"),
|
||||
0,
|
||||
&UserAgent::default(),
|
||||
localtime::LocalTime::now().into(),
|
||||
[node::KnownAddress::new(
|
||||
node::Address::from(bob.addr),
|
||||
node::address::Source::Imported,
|
||||
)],
|
||||
)
|
||||
.unwrap();
|
||||
let alice = alice.spawn();
|
||||
alice
|
||||
.rad(
|
||||
"node",
|
||||
&["connect", format!("{}", bob.id).as_str()],
|
||||
working.path(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let sessions = alice.handle.sessions().unwrap();
|
||||
let session = sessions.first().unwrap();
|
||||
|
||||
assert_eq!(session.nid, bob.id);
|
||||
assert_eq!(session.addr, bob.addr.into());
|
||||
assert!(session.state.is_connected());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_node() {
|
||||
let mut environment = Environment::new();
|
||||
|
||||
Reference in New Issue
Block a user