Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mail-b.sr.ht (Postfix) with ESMTPS id 3C72511EF15 for <~radicle-link/dev@lists.sr.ht>; Thu, 25 Aug 2022 05:42:08 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id pm13so10329921pjb.5 for <~radicle-link/dev@lists.sr.ht>; Wed, 24 Aug 2022 22:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=h/P96o5y6s4ixfX9xZhkxo8t4Xwgn0i1n/pHMP7EsQA=; b=pMiSfwkz/BcMiMu5vWDlGzy1u1e5U2qfPb9XPthNSXymSBwf/lH40bcxqsbsMDj9Ny gbWz705tM+qGg0Am1fOKc5kcJS71C8QWtX4rgo8h4j24csYIqRXcenfYwz54HFV73SvE Ry7gpJa3Yc+gInaZK7AXVq7Yo6xqlZog7uZKLqC8KrUKynEXYwQIf46Up0Sp5elUJnjv P8L4OP2kpYEctTIznt96hNg4svss5NcD6OP66B2FxhpjP7vNCYOUMoeAJFsZOhEx51gF mad+q8thpRTgvwAEt5weF/hYn/bW6On2OQDIgjallJNztJCwPQcYGa42/5hnd318nD5L qhQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=h/P96o5y6s4ixfX9xZhkxo8t4Xwgn0i1n/pHMP7EsQA=; b=pCLtKeAZADKgYyy+RPSEWQFiWItQJhVO2/rvjCeoE1jGARBAqN5atSPONQbaeODEwt vCJd5F6wnmOR+Qu5YXuNpQR2VAOytwR0/M+i7c5v5uUUE+V7V9z8Bw3Vp/EZ8u8dkU5s tucK5DxTyTLTD2eVD2wQ0T4V5DcVeZpcLxBTOj9T5lpICHDQ1j0sGyeNmMhRttBYhpdq MEQd8XJHvvzYH9/acMEpCCvXIPauid2k58MpcfmhN+sfOPlWqSrV3+VYUbt3+QL75Mth hhgMCAxePF2zwH1KxtqVRhnlUIbeSevCgCF0GL/qGkCY0f8Q5LMQkdmj+k6hgSernxbZ RC7A== X-Gm-Message-State: ACgBeo1K00JnfRz7oIuh73X3oz8Kv5ljQj+PZNwz8ITwtNdNYOYqIaqS rgrcPwuh9ULvNtDNMx5pBIYRgukbxY8= X-Google-Smtp-Source: AA6agR7ruRraeKMlQmkFTWP0fWyyOYIrYzpwQ+I6ENuXPlCCYjL763pPeSVRVwqtFxZwXkuPw4ReEg== X-Received: by 2002:a17:90b:4f4e:b0:1f5:8a65:9192 with SMTP id pj14-20020a17090b4f4e00b001f58a659192mr11758513pjb.224.1661406126974; Wed, 24 Aug 2022 22:42:06 -0700 (PDT) Received: from localhost.localdomain (c-98-207-161-235.hsd1.ca.comcast.net. [98.207.161.235]) by smtp.gmail.com with ESMTPSA id bk2-20020a056a02028200b0041c0c9c0072sm11989417pgb.64.2022.08.24.22.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 22:42:06 -0700 (PDT) From: Han Xu To: ~radicle-link/dev@lists.sr.ht Cc: Han Xu Subject: [PATCH radicle-link v4 2/3] check peer1 and peer2 ref/heads/master Date: Wed, 24 Aug 2022 22:41:55 -0700 Message-Id: <20220825054156.57232-3-keepsimple@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220825054156.57232-1-keepsimple@gmail.com> References: <20220818225452.26321-1-keepsimple@gmail.com> <20220825054156.57232-1-keepsimple@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit --- bins/tests/integration_test.rs | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/bins/tests/integration_test.rs b/bins/tests/integration_test.rs index 770f1b5e..ea6815ab 100644 --- a/bins/tests/integration_test.rs +++ b/bins/tests/integration_test.rs @@ -170,11 +170,15 @@ fn two_peers_and_a_seed() { return; } + let peer1_last_commit = git_last_commit(); + println!("\n== peer1 project last commit: {} ==\n", &peer1_last_commit); + println!("\n== Clone to peer2 ==\n"); env::set_current_dir("..").unwrap(); // out of the peer1 proj directory. + let peer2_proj = format!("peer2_proj_{}", timestamp()); let (is_parent, _) = run_lnk( - LnkCmd::Clone(proj_urn, peer1_peer_id), + LnkCmd::Clone(proj_urn, peer1_peer_id, peer2_proj.clone()), peer2_home, passphrase, ); @@ -182,9 +186,16 @@ fn two_peers_and_a_seed() { return; } - println!("\n== Kill linkd (seed) ==\n"); + env::set_current_dir(peer2_proj).unwrap(); + let peer2_last_commit = git_last_commit(); + println!("\n== peer1 proj last commit: {}", &peer1_last_commit); + println!("\n== peer2 proj last commit: {}", &peer2_last_commit); + + println!("\n== Cleanup: kill linkd (seed) ==\n"); linkd.kill().ok(); + + assert_eq!(peer1_last_commit, peer2_last_commit); } enum LnkCmd { @@ -195,7 +206,7 @@ enum LnkCmd { IdPersonCreate(String), // the associated string is "the person's name". IdLocalSet(String), // the associated string is "urn". IdProjectCreate(String), // the associated string is "the project name". - Clone(String, String), // the associated string is "urn", "peer_id" + Clone(String, String, String), // the associated string is "urn", "peer_id", "path" } /// Runs a `cmd` for `lnk_home`. Rebuilds `lnk` if necessary. @@ -238,7 +249,7 @@ fn run_lnk(cmd: LnkCmd, lnk_home: &str, passphrase: &[u8]) -> (bool, String) { LnkCmd::ProfilePeer => { output = line; // get the last line for peer id. }, - LnkCmd::Clone(ref _urn, ref _peer) => { + LnkCmd::Clone(ref _urn, ref _peer, ref _path) => { output = line; }, _ => {}, @@ -296,8 +307,7 @@ fn run_lnk(cmd: LnkCmd, lnk_home: &str, passphrase: &[u8]) -> (bool, String) { .arg("--payload") .arg(payload.to_string()) }, - LnkCmd::Clone(urn, peer_id) => { - let peer2_proj = format!("peer2_proj_{}", timestamp()); + LnkCmd::Clone(urn, peer_id, peer2_proj) => { lnk_cmd .arg("clone") .arg("--urn") @@ -414,6 +424,15 @@ fn run_git_push() -> bool { } } +fn git_last_commit() -> String { + let output = Command::new("git") + .arg("rev-parse") + .arg("HEAD") + .output() + .expect("failed to run git rev-parse"); + String::from_utf8_lossy(&output.stdout).to_string() +} + /// Returns UNIX_TIME in millis. fn timestamp() -> u128 { let now = SystemTime::now() -- 2.32.0 (Apple Git-132)