From ad63583bee62015e59b073c904cd96aed2f52cd1 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 23 Feb 2023 09:53:27 +0000 Subject: [PATCH] cli: rad node example Tests the rad node CLI subcommand. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/examples/rad-node.md | 88 ++++++++++++++++++++++++++++++++ radicle-cli/tests/commands.rs | 31 +++++++++++ 2 files changed, 119 insertions(+) create mode 100644 radicle-cli/examples/rad-node.md diff --git a/radicle-cli/examples/rad-node.md b/radicle-cli/examples/rad-node.md new file mode 100644 index 00000000..d3a4ffe3 --- /dev/null +++ b/radicle-cli/examples/rad-node.md @@ -0,0 +1,88 @@ +The radicle node is our daemon friend that is running as a background +process. It allows us to interact with the network as well as storing +some key data that we may be interested in. + +
+🚧 `rad node start` is under construction 🚧 +If the node is not running we can start it by using the `rad node +start` command: + + + + +
+ +We can confirm the status of the node at any time by using the `rad +node status` command (or just `rad node` for short): + +``` +$ rad node status +✓ The node is running +``` + +The node also allows us to connect with other nodes in the +network. For example, let's connect to a known peer using their Node +ID and their network address: + +``` +$ rad node connect z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk 0.0.0.0:3679 +✓ Connecting to z6Mkt67…v4N1tRk@0.0.0.0:3679... +``` + +The node also allows us to query data that it has access too such as +the tracking relationships and the routing table. Before we explore +those commands we'll first track a peer so that we have something to +see. + +``` +$ rad track z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias Bob +Establishing 🌱 tracking relationship for heartwood + +✓ Tracking relationship with Bob (z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk) established +! Warning: fetch after track is not yet supported +``` + +Now, when we use the `rad node tracking` command we will see +information for repositories that we track -- in this case a +repository that was already created: + +``` +$ rad node tracking +RID Scope Policy +--- ----- ------ +rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji all track +``` + +This is the same as using the `--repos` flag, but if we wish to see +which nodes we are specifically tracking, then we use the `--nodes` +flag: + +``` +$ rad node tracking --nodes +DID Alias Policy +--- ----- ------ +did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk Bob track +``` + +To see the routing table we can use the `rad node routing` command and +see what Repository IDs match up with the interests of which Node +IDs. In this case, it is just our own Node ID for the project we +created. + +``` +$ rad node routing +RID NID +--- --- +rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji z6MknSL…StBU8Vi +``` + +
+🚧 `rad node stop` is under construction 🚧 +Finally, if we want to stop the daemon process from running we can +issue the `rad node stop` command: + + + + + +
diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index b3d2ae6b..69acff6d 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -211,6 +211,37 @@ fn rad_id_rebase() { test("examples/rad-id-rebase.md", working.path(), Some(home), []).unwrap(); } +#[test] +fn rad_node() { + logger::init(log::Level::Debug); + + let mut environment = Environment::new(); + let alice = environment.node("alice"); + let bob = environment.node("bob"); + let working = tempfile::tempdir().unwrap(); + + let alice = alice.spawn(Config::default()); + let _bob = bob.spawn(Config::default()); + + fixtures::repository(working.path().join("alice")); + + test( + "examples/rad-init-sync.md", + &working.path().join("alice"), + Some(&alice.home), + [], + ) + .unwrap(); + + test( + "examples/rad-node.md", + working.path().join("alice"), + Some(&alice.home), + [], + ) + .unwrap(); +} + #[test] #[ignore] fn rad_patch() {