~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

Test accounts made side by side no longer take the same handle

Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:tests/unique-handles
crates/knotless/tests/common/mod.rs+15−7
@@ -130,21 +130,29 @@ fn start() -> Result<(Net, Child), String> {
static NEXT: Mutex<usize> = Mutex::new(0);
/// What sets this test binary's accounts apart from every other's on a
/// shared harness: its process ID, which no binary running beside it has,
/// and when it first made one, which a later binary given the same ID
/// does not share. Each is six hex digits, so no two tags read the same.
pub static TAG: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
let micros = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_micros();
let pid = std::process::id() & 0xff_ffff;
format!("{pid:06x}{:06x}", micros & 0xff_ffff)
});
/// A new account on a shared harness, named so that no other test binary,
/// in this run or an earlier one, has it: a handle's first label is at
/// most 18 characters.
/// most 18 characters, here `k`, the binary's [`TAG`] and a count.
fn created() -> Account {
let n = {
let mut next = NEXT.lock().unwrap();
*next += 1;
*next
};
let nanos = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_nanos();
let tag = (nanos as u64 ^ (u64::from(std::process::id()) << 32)) as u32;
let handle = format!("k{tag:08x}{n}.test");
let handle = format!("k{}{n}.test", *TAG);
let password = format!("{handle}-password");
let res: serde_json::Value = reqwest::blocking::Client::new()
.post(format!(
crates/knotless-serve/tests/pages.rs+2−6
@@ -256,12 +256,8 @@ fn a_taken_down_account_is_logged_out() {
fn making_an_account_to_log_in() {
let server = server();
let start = json!({"create": true, "back": "/"});
let nanos = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_nanos();
let tag = (nanos as u64 ^ (u64::from(std::process::id()) << 32)) as u32;
let handle = format!("n{tag:08x}.test");
// Made once in this binary, so its tag sets it apart.
let handle = format!("n{}.test", *common::TAG);
let made = Account {
handle: handle.clone(),
did: String::new(),