Update lox_cli test to use different endpoint for advancing time

This commit is contained in:
Vecna 2024-04-26 23:12:10 -04:00
parent 69953bc16c
commit afefe519b1
4 changed files with 17 additions and 9 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
Cargo.lock
target
*.json

View File

@ -1,5 +1,5 @@
[package]
name = "lox_test"
name = "lox_cli"
version = "0.1.0"
edition = "2021"
@ -7,8 +7,9 @@ edition = "2021"
[dependencies]
#lox = { git = "https://git-crysp.uwaterloo.ca/iang/lox.git", branch = "vvecna/lox_test" }
lox-library = { git = "https://gitlab.torproject.org/tpo/anti-censorship/lox-rs.git", version = "0.1.0" }
lox_utils = { git = "https://gitlab.torproject.org/tpo/anti-censorship/lox-rs.git", version = "0.1.0" }
#lox-library = { git = "https://gitlab.torproject.org/tpo/anti-censorship/lox.git", version = "0.1.0" }
lox-library = { git = "https://gitlab.torproject.org/vecna/lox.git", version = "0.1.0" }
lox_utils = { git = "https://gitlab.torproject.org/tpo/anti-censorship/lox.git", version = "0.1.0" }
curve25519-dalek = { package = "curve25519-dalek-ng", version = "3", default-features = false, features = ["serde", "std"] }
ed25519-dalek = { version = "1", features = ["serde"] }
getopts = "0.2"
@ -19,7 +20,7 @@ serde_with = "1.9.1"
time = "0.2"
# TODO: reduce feature set to just the ones needed
tokio = { version = "1", features = ["full"] }
hyper = { version = "0.14.27", features = ["full"] }
hyper = { version = "0.14.28", features = ["full"] }
async-trait = "0.1.68"
[features]

View File

@ -1,10 +1,10 @@
# lox_test
# lox_cli
This is an in-development client library and CLI for Lox, designed to talk to the Lox Distributor.
## Server
The Lox Distributor code can be found [here](https://gitlab.torproject.org/tpo/anti-censorship/lox/-/tree/main/crates/lox-distributor). I am aiming to keep this project up-to-date to work with that repository. For testing, use [this fork](https://gitlab.torproject.org/vecna/lox-rs/-/tree/main/crates/lox-distributor) which adds an endpoint to the server to allow artificially increasing the number of days that have passed.
The Lox Distributor code can be found [here](https://gitlab.torproject.org/tpo/anti-censorship/lox/-/tree/main/crates/lox-distributor). I am aiming to keep this project up-to-date to work with that repository. For testing, use [this fork](https://gitlab.torproject.org/vecna/lox/-/tree/main/crates/lox-distributor) which adds an endpoint to the server to allow artificially increasing the number of days that have passed.
## Usage

View File

@ -1,5 +1,5 @@
/*! Unit tests. Note that these require
https://gitlab.torproject.org/vecna/lox-rs/-/tree/main/crates/lox-distributor
https://gitlab.torproject.org/vecna/lox/-/tree/main/crates/lox-distributor
to be running. That fork adds an endpoint which allows for artificially
increasing the number of days that have passed, which allows us to test
trust migration and level up functions. */
@ -19,6 +19,7 @@ use lox_library::proto::trust_promotion::UNTRUSTED_INTERVAL;
use lox_library::scalar_u32;
use std::cmp::min;
use tokio::spawn;
// These are all combined into the same test because otherwise we run into
// issues with server state due to asynchronicity.
@ -27,6 +28,9 @@ async fn test_credential_operations() {
let net = HyperNet {
hostname: "http://localhost:8001".to_string(),
};
let net_test = HyperNet {
hostname: "http://localhost:8005".to_string(),
};
let la_pubkeys = get_lox_auth_keys(&net).await;
// Get new Lox credential
@ -43,7 +47,7 @@ async fn test_credential_operations() {
assert_eq!(scalar_u32(&cred.trust_level).unwrap(), 0);
// Advance server time and trust migrate
advance_days(&net, u16::try_from(UNTRUSTED_INTERVAL).unwrap()).await;
advance_days(&net_test, u16::try_from(UNTRUSTED_INTERVAL).unwrap()).await;
assert!(eligible_for_trust_promotion(&net, &cred).await);
let migration_cred = trust_promotion(&net, &cred, get_lox_pub(&la_pubkeys)).await;
cred = trust_migration(
@ -62,7 +66,7 @@ async fn test_credential_operations() {
scalar_u32(&cred.trust_level).unwrap(),
u32::try_from(i).unwrap()
);
advance_days(&net, u16::try_from(LEVEL_INTERVAL[i]).unwrap()).await;
advance_days(&net_test, u16::try_from(LEVEL_INTERVAL[i]).unwrap()).await;
assert!(eligible_for_level_up(&net, &cred).await);
let encbuckets = get_reachability_credential(&net).await;
cred = level_up(