Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mail-b.sr.ht (Postfix) with ESMTPS id 8507211F256 for <~radicle-link/dev@lists.sr.ht>; Mon, 29 Aug 2022 19:13:50 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id r205-20020a1c44d6000000b003a84bf9b68bso812431wma.3 for <~radicle-link/dev@lists.sr.ht>; Mon, 29 Aug 2022 12:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:message-id:date:to:from:subject :content-transfer-encoding:mime-version:from:to:cc; bh=+AHqpzUH2gH/7Gpm19e18qGO8UYYGw7iQ1CV5pU+qds=; b=ciyYe69HrLOOrqmRsFGe7BrI2wUl8LD2gVT6LLuh8kiICByMBAHMVVBe5AMuGc1iOK mAFYdad8E5hEktp15+2mOkv4Tkc3PtvPZOmXZ/FJ2vO0r3fOQ/T9ymMZlvt02+xMIDsY 4ElnMlUvm8Ekw+9wJC6h5OgnOGAb/rhfYbwYRZyNhji+/W7abgzbVJMUWBT4eWbVSf51 uzgZbHDkMNfluObUucocaepqv4ybK9akZlI2uipXptqAFZgfVct1kwbp1VBe+zvZempk 1S0g9JCXs+62YPhE4I/KXaX19kFy4zKalZjs/Tg0ADKV6+DwIOvuXeTAl8/C9aSo+kxl /x6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:message-id:date:to:from:subject :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc; bh=+AHqpzUH2gH/7Gpm19e18qGO8UYYGw7iQ1CV5pU+qds=; b=6BAgtQ7cCU/Vg/JoZrvABILB+CVr1ugIel3LJiEG0rGIQbVmSYoC7c6vy0ZXQBYqy1 PLBhDVOjRuXElBy19H0U2U7eIZV0fbJRCs83EFzydbv/RjgLiZTpH2v4y0BoTfi52rc1 zlpa+SbZW6CLL0Xq7ZF554z7/6Smy0fYuL+KBFbKJv3V1qpVoecQB7fKjnBkiiJh+N6u mo5HQ7mVFYk0DevyobH+uex3MbHnLhYcGBxZ55F/IS+9wZVVXpancm1/xsnSiC6K3F/s KHH/Drq6qFWylcvpQAxQJaklBe52Ugor8iWoT7zJWOlBLWr9UaVSewnxBddlvAeddBqW 56uA== X-Gm-Message-State: ACgBeo3xnShqT04DIN0k49rya0dC8UVhWRhgm1zJXB+Xjl44XeaCIxCp gyWI5PriXWZRmByuTtDMNvNlHk3Rhz8nWg== X-Google-Smtp-Source: AA6agR7c7A1oIH1dcG4HV/Dww3TzGbAkTC4CEZ2zVykd/X+EjwvpWdGyR03B6mDbwnUk3nKQXS5DJA== X-Received: by 2002:a05:600c:1084:b0:3a6:150d:b92 with SMTP id e4-20020a05600c108400b003a6150d0b92mr7887543wmd.151.1661800429294; Mon, 29 Aug 2022 12:13:49 -0700 (PDT) Received: from localhost ([2a02:8084:a1:4280:271:4c45:62d3:b838]) by smtp.gmail.com with ESMTPSA id j27-20020a05600c1c1b00b003a31fd05e0fsm14248671wms.2.2022.08.29.12.13.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 12:13:48 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH radicle-link v5 0/5] Add integration test for bins and fix bugs found From: "Fintan Halpenny" To: "Han Xu" , <~radicle-link/dev@lists.sr.ht> Date: Mon, 29 Aug 2022 20:11:47 +0100 Message-Id: In-Reply-To: <20220825210251.61675-1-keepsimple@gmail.com> I have some stylistic suggestions for test file below. I think you can also squash the changes to that same file into a single commit. So, the patch should look like the addition of the integration_test.rs file and the fix to the signed_refs update. --- bins/tests/integration_test.rs | 165 ++++++++++++++++++++------------- 1 file changed, 100 insertions(+), 65 deletions(-) diff --git a/bins/tests/integration_test.rs b/bins/tests/integration_test.r= s index d245748d..91d4d423 100644 --- a/bins/tests/integration_test.rs +++ b/bins/tests/integration_test.rs @@ -34,59 +34,79 @@ fn two_peers_and_a_seed() { let seed_home =3D "/tmp/seed-home"; let passphrase =3D b"play\n"; =20 - println!("\n=3D=3D create lnk homes for two peers and one seed =3D=3D\= n"); - let cmd =3D LnkCmd::ProfileCreate; - run_lnk!(&cmd, peer1_home, passphrase); - run_lnk!(&cmd, peer2_home, passphrase); - run_lnk!(&cmd, seed_home, passphrase); + { + println!("\n=3D=3D create lnk homes for two peers and one seed =3D= =3D\n"); + let cmd =3D LnkCmd::ProfileCreate; + run_lnk!(&cmd, peer1_home, passphrase); + run_lnk!(&cmd, peer2_home, passphrase); + run_lnk!(&cmd, seed_home, passphrase); + } =20 - println!("\n=3D=3D add ssh keys for each profile to the ssh-agent =3D= =3D\n"); - let cmd =3D LnkCmd::ProfileSshAdd; - run_lnk!(&cmd, peer1_home, passphrase); - run_lnk!(&cmd, peer2_home, passphrase); - run_lnk!(&cmd, seed_home, passphrase); - - println!("\n=3D=3D Creating local link 1 identity =3D=3D\n"); - let peer1_name =3D "sockpuppet1".to_string(); - let cmd =3D LnkCmd::IdPersonCreate(peer1_name); - let output =3D run_lnk!(&cmd, peer1_home, passphrase); - let v: Value =3D serde_json::from_str(&output).unwrap(); - let urn1 =3D v["urn"].as_str().unwrap().to_string(); - let cmd =3D LnkCmd::IdLocalSet(urn1); - run_lnk!(&cmd, peer1_home, passphrase); - - println!("\n=3D=3D Creating local link 2 identity =3D=3D\n"); - let peer2_name =3D "sockpuppet2".to_string(); - let cmd =3D LnkCmd::IdPersonCreate(peer2_name); - let output =3D run_lnk!(&cmd, peer2_home, passphrase); - let v: Value =3D serde_json::from_str(&output).unwrap(); - let urn2 =3D v["urn"].as_str().unwrap().to_string(); - let cmd =3D LnkCmd::IdLocalSet(urn2); - run_lnk!(&cmd, peer2_home, passphrase); + { + println!("\n=3D=3D add ssh keys for each profile to the ssh-agent = =3D=3D\n"); + let cmd =3D LnkCmd::ProfileSshAdd; + run_lnk!(&cmd, peer1_home, passphrase); + run_lnk!(&cmd, peer2_home, passphrase); + run_lnk!(&cmd, seed_home, passphrase); + } =20 - println!("\n=3D=3D Create a local repository =3D=3D\n"); - let peer1_proj =3D format!("peer1_proj_{}", timestamp()); - let cmd =3D LnkCmd::IdProjectCreate(peer1_proj.clone()); - let output =3D run_lnk!(&cmd, peer1_home, passphrase); - let v: Value =3D serde_json::from_str(&output).unwrap(); - let proj_urn =3D v["urn"].as_str().unwrap().to_string(); - println!("our project URN: {}", &proj_urn); + { + println!("\n=3D=3D Creating local link 1 identity =3D=3D\n"); + let name =3D "sockpuppet1".to_string(); + let cmd =3D LnkCmd::IdPersonCreate { name }; + let output =3D run_lnk!(&cmd, peer1_home, passphrase); + let v: Value =3D serde_json::from_str(&output).unwrap(); + let urn =3D v["urn"].as_str().unwrap().to_string(); + let cmd =3D LnkCmd::IdLocalSet { urn: urn }; + run_lnk!(&cmd, peer1_home, passphrase); + } =20 - println!("\n=3D=3D Add the seed to the local peer seed configs =3D=3D\= n"); - let cmd =3D LnkCmd::ProfilePeer; - let seed_peer_id =3D run_lnk!(&cmd, seed_home, passphrase); - let seed_endpoint =3D format!("{}@127.0.0.1:8799", &seed_peer_id); + { + println!("\n=3D=3D Creating local link 2 identity =3D=3D\n"); + let name =3D "sockpuppet2".to_string(); + let cmd =3D LnkCmd::IdPersonCreate { name }; + let output =3D run_lnk!(&cmd, peer2_home, passphrase); + let v: Value =3D serde_json::from_str(&output).unwrap(); + let urn =3D v["urn"].as_str().unwrap().to_string(); + let cmd =3D LnkCmd::IdLocalSet { urn }; + run_lnk!(&cmd, peer2_home, passphrase); + } + + let urn =3D { + println!("\n=3D=3D Create a local repository =3D=3D\n"); + let peer1_proj =3D format!("peer1_proj_{}", timestamp()); + let cmd =3D LnkCmd::IdProjectCreate { + name: peer1_proj.clone(), + }; + let output =3D run_lnk!(&cmd, peer1_home, passphrase); + let v: Value =3D serde_json::from_str(&output).unwrap(); + let proj_urn =3D v["urn"].as_str().unwrap().to_string(); + println!("our project URN: {}", &proj_urn); + proj_urn + }; =20 - let cmd =3D LnkCmd::ProfileGet; - let peer1_profile =3D run_lnk!(&cmd, peer1_home, passphrase); - let peer1_seed =3D format!("{}/{}/seeds", peer1_home, peer1_profile); - let mut peer1_f =3D File::create(peer1_seed).unwrap(); - peer1_f.write_all(seed_endpoint.as_bytes()).unwrap(); + let seed_endpoint =3D { + println!("\n=3D=3D Add the seed to the local peer seed configs =3D= =3D\n"); + let cmd =3D LnkCmd::ProfilePeer; + let seed_peer_id =3D run_lnk!(&cmd, seed_home, passphrase); + format!("{}@127.0.0.1:8799", &seed_peer_id) + }; =20 - let peer2_profile =3D run_lnk!(&cmd, peer2_home, passphrase); - let peer2_seed =3D format!("{}/{}/seeds", peer2_home, peer2_profile); - let mut peer2_f =3D File::create(peer2_seed).unwrap(); - peer2_f.write_all(seed_endpoint.as_bytes()).unwrap(); + { + let cmd =3D LnkCmd::ProfileGet; + let peer1_profile =3D run_lnk!(&cmd, peer1_home, passphrase); + let peer1_seed =3D format!("{}/{}/seeds", peer1_home, peer1_profil= e); + let mut peer1_f =3D File::create(peer1_seed).unwrap(); + peer1_f.write_all(seed_endpoint.as_bytes()).unwrap(); + } + + { + let cmd =3D LnkCmd::ProfileGet; + let peer2_profile =3D run_lnk!(&cmd, peer2_home, passphrase); + let peer2_seed =3D format!("{}/{}/seeds", peer2_home, peer2_profil= e); + let mut peer2_f =3D File::create(peer2_seed).unwrap(); + peer2_f.write_all(seed_endpoint.as_bytes()).unwrap(); + } =20 println!("\n=3D=3D Start the seed linkd =3D=3D\n"); let manifest_path =3D manifest_path(); @@ -99,7 +119,7 @@ fn two_peers_and_a_seed() { let mut gitd =3D spawn_lnk_gitd(peer1_home, &manifest_path, gitd_addr)= ; =20 println!("\n=3D=3D Make some changes in the repo =3D=3D\n"); - env::set_current_dir(&peer1_proj).unwrap(); + env::set_current_dir(&urn).unwrap(); let mut test_file =3D File::create("test").unwrap(); test_file.write_all(b"test").unwrap(); Command::new("git") @@ -116,7 +136,7 @@ fn two_peers_and_a_seed() { println!("git-commit: {:?}", &output); =20 println!("\n=3D=3D Add the linkd remote to the repo =3D=3D\n"); - let remote_url =3D format!("ssh://rad@{}/{}.git", gitd_addr, &proj_urn= ); + let remote_url =3D format!("ssh://rad@{}/{}.git", gitd_addr, &urn); Command::new("git") .arg("remote") .arg("add") @@ -138,11 +158,12 @@ fn two_peers_and_a_seed() { =20 env::set_current_dir("..").unwrap(); // out of the peer1 proj director= y. let peer2_proj =3D format!("peer2_proj_{}", timestamp()); - let cmd =3D LnkCmd::Clone(proj_urn, peer1_peer_id, peer2_proj.clone())= ; + let cmd =3D LnkCmd::Clone { + urn, + peer_id: peer1_peer_id, + path: peer2_proj.clone(), + }; run_lnk!(&cmd, peer2_home, passphrase); - if !is_parent { - return; - } =20 env::set_current_dir(peer2_proj).unwrap(); let peer2_last_commit =3D git_last_commit(); @@ -162,10 +183,20 @@ enum LnkCmd { ProfileGet, ProfilePeer, ProfileSshAdd, - IdPersonCreate(String), // the associated string is "the person's nam= e". - IdLocalSet(String), // the associated string is "urn". - IdProjectCreate(String), // the associated string is "the project name= ". - Clone(String, String, String), // the associated string is "urn", "pee= r_id", "path" + IdPersonCreate { + name: String, + }, + IdLocalSet { + urn: String, + }, + IdProjectCreate { + name: String, + }, + Clone { + urn: String, + peer_id: String, + path: String, + }, } =20 /// Runs a `lnk` command of `$cmd` using `$lnk_home` as the node home. @@ -199,12 +230,12 @@ fn process_lnk_output(lnk_home: &str, lnk_process: &m= ut Master, cmd: &LnkCmd) -> // Print the output and decode them if necessary. println!("{}: {}", lnk_home, line); match cmd { - LnkCmd::IdPersonCreate(ref _name) =3D> { + LnkCmd::IdPersonCreate { .. } =3D> { if line.find("\"urn\":").is_some() { output =3D line; // get the line with URN. } }, - LnkCmd::IdProjectCreate(ref _name) =3D> { + LnkCmd::IdProjectCreate { .. } =3D> { if line.find("\"urn\":").is_some() { output =3D line; // get the line with URN. } @@ -215,7 +246,7 @@ fn process_lnk_output(lnk_home: &str, lnk_process: &mut= Master, cmd: &LnkCmd) -> LnkCmd::ProfilePeer =3D> { output =3D line; // get the last line for peer id. }, - LnkCmd::Clone(ref _urn, ref _peer, ref _path) =3D> { + LnkCmd::Clone { .. } =3D> { output =3D line; }, _ =3D> {}, @@ -245,7 +276,7 @@ fn start_lnk_cmd(lnk_home: &str, cmd: &LnkCmd) { LnkCmd::ProfileGet =3D> lnk_cmd.arg("profile").arg("get"), LnkCmd::ProfilePeer =3D> lnk_cmd.arg("profile").arg("peer"), LnkCmd::ProfileSshAdd =3D> lnk_cmd.arg("profile").arg("ssh").arg("= add"), - LnkCmd::IdPersonCreate(name) =3D> { + LnkCmd::IdPersonCreate { name } =3D> { let payload =3D json!({ "name": name }); lnk_cmd .arg("identities") @@ -255,13 +286,13 @@ fn start_lnk_cmd(lnk_home: &str, cmd: &LnkCmd) { .arg("--payload") .arg(payload.to_string()) }, - LnkCmd::IdLocalSet(urn) =3D> lnk_cmd + LnkCmd::IdLocalSet { urn } =3D> lnk_cmd .arg("identities") .arg("local") .arg("set") .arg("--urn") .arg(urn), - LnkCmd::IdProjectCreate(name) =3D> { + LnkCmd::IdProjectCreate { name } =3D> { let payload =3D json!({"name": name, "default_branch": "master= "}); let project_path =3D format!("./{}", name); lnk_cmd @@ -274,7 +305,11 @@ fn start_lnk_cmd(lnk_home: &str, cmd: &LnkCmd) { .arg("--payload") .arg(payload.to_string()) }, - LnkCmd::Clone(urn, peer_id, peer2_proj) =3D> lnk_cmd + LnkCmd::Clone { + urn, + peer_id, + path: peer2_proj, + } =3D> lnk_cmd .arg("clone") .arg("--urn") .arg(urn) --=20 2.31.1