Skip to content

Commit a68b7e3

Browse files
Elrondclaude
andcommitted
acceptance: report the probe's pubkey; pin the key file end to end
The JSON report now names the public key the run authenticated as. The key-file test passes the path through BUZZ_PRIVATE_KEY_FILE, as the chart does, and checks that the run used that key, so a probe that ignored the file fails it. The test launcher no longer inherits the probe's settings from the caller's environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
1 parent 0133b36 commit a68b7e3

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎crates/buzz-test-client/src/acceptance/metrics.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ mod tests {
121121
fn report() -> Report {
122122
Report {
123123
relay_url: "wss://relay.example".into(),
124+
pubkey: "00".repeat(32),
124125
relay_version: Some("1.2.3".into()),
125126
passed: false,
126127
seconds: 1.5,

‎crates/buzz-test-client/src/acceptance/mod.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ pub struct Config {
7171
pub struct Report {
7272
/// The relay the run checked.
7373
pub relay_url: String,
74+
/// The public key (hex) the run authenticated and signed as.
75+
pub pubkey: String,
7476
/// The relay's NIP-11 `version`, when it reported one.
7577
pub relay_version: Option<String>,
7678
/// True when no check failed.
@@ -234,6 +236,7 @@ pub async fn run(cfg: &Config) -> Report {
234236

235237
Report {
236238
relay_url: cfg.relay_url.clone(),
239+
pubkey: cfg.keys.public_key().to_hex(),
237240
relay_version,
238241
passed: checks.iter().all(|c| c.result != Outcome::Failure),
239242
seconds: started.elapsed().as_secs_f64(),

‎crates/buzz-test-client/tests/e2e_acceptance.rs‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ async fn every_acceptance_check_passes_against_a_live_relay() {
4343
/// Runs the binary with `args`, metrics sent to a local listener. Returns
4444
/// its output and every datagram that arrived.
4545
fn probe(args: &[&str]) -> (Output, Vec<String>) {
46+
probe_with_env(args, &[])
47+
}
48+
49+
/// [`probe`] with extra environment variables. The child inherits none of the
50+
/// probe's own settings from the test's environment.
51+
fn probe_with_env(args: &[&str], envs: &[(&str, &str)]) -> (Output, Vec<String>) {
4652
let agent = UdpSocket::bind("127.0.0.1:0").unwrap();
4753
agent
4854
.set_read_timeout(Some(Duration::from_millis(500)))
@@ -52,7 +58,11 @@ fn probe(args: &[&str]) -> (Output, Vec<String>) {
5258
.args(args)
5359
.args(["--statsd-addr", &addr, "--tag", "env:test"])
5460
.env_remove("BUZZ_PRIVATE_KEY")
61+
.env_remove("BUZZ_PRIVATE_KEY_FILE")
62+
.env_remove("BUZZ_ACCEPTANCE_ASSERTION_FILE")
63+
.env_remove("BUZZ_ACCEPTANCE_STATSD_ADDR")
5564
.env_remove("BUZZ_RELAY_URL")
65+
.envs(envs.iter().copied())
5666
.stdout(Stdio::piped())
5767
.stderr(Stdio::piped())
5868
.spawn()
@@ -195,7 +205,7 @@ fn the_binary_exits_2_when_it_cannot_run() {
195205

196206
#[test]
197207
#[ignore]
198-
fn the_binary_passes_with_a_key_from_a_file() {
208+
fn the_binary_authenticates_with_the_key_from_its_key_file() {
199209
let dir = std::env::temp_dir().join(format!("acceptance-key-{}", uuid::Uuid::new_v4()));
200210
std::fs::create_dir_all(&dir).unwrap();
201211
let key_file = dir.join("key");
@@ -206,14 +216,15 @@ fn the_binary_passes_with_a_key_from_a_file() {
206216
)
207217
.unwrap();
208218

209-
let (output, _) = probe(&[
210-
"--relay-url",
211-
&relay_url(),
212-
"--private-key-file",
213-
key_file.to_str().unwrap(),
214-
]);
219+
// The chart passes the path through the environment, so this does too.
220+
let (output, _) = probe_with_env(
221+
&["--relay-url", &relay_url()],
222+
&[("BUZZ_PRIVATE_KEY_FILE", key_file.to_str().unwrap())],
223+
);
215224
let report = report(&output);
216225
assert_eq!(output.status.code(), Some(0), "{report}");
217226
assert_eq!(report["passed"], true);
227+
// A probe that ignored the file would run as a new key.
228+
assert_eq!(report["pubkey"], keys.public_key().to_hex(), "{report}");
218229
std::fs::remove_dir_all(dir).unwrap();
219230
}

0 commit comments

Comments
 (0)