clippy: the simplifications a machine can make without changing the code's shape #318
34 changed files with 62 additions and 86 deletions
|
|
@ -291,7 +291,7 @@ mod tests {
|
|||
);
|
||||
let mut h = EchoHarness::new("h");
|
||||
let eval = sup
|
||||
.evaluate("sut", &mut h, "q", &"ab".repeat(32), 1, 2, false, false)
|
||||
.evaluate("sut", &mut h, "q", "ab".repeat(32), 1, 2, false, false)
|
||||
.unwrap();
|
||||
let session_json = serde_json::to_string(&eval.session).unwrap();
|
||||
let att_json = serde_json::to_string(&eval.attestation).unwrap();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ impl Default for ValidationDepth {
|
|||
/// How stochastic the system is on the certified task. `A` is the most
|
||||
/// deterministic; `E` (uncharacterized) is the default.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum ConvergenceClass {
|
||||
/// Deterministic equivalent (≥100 identical/equivalent runs).
|
||||
A,
|
||||
|
|
@ -75,6 +76,7 @@ pub enum ConvergenceClass {
|
|||
/// Divergent on extension (stable short, diverges with length/depth).
|
||||
D,
|
||||
/// Uncharacterized. Variance never measured. Default.
|
||||
#[default]
|
||||
E,
|
||||
}
|
||||
|
||||
|
|
@ -97,11 +99,6 @@ impl ConvergenceClass {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for ConvergenceClass {
|
||||
fn default() -> Self {
|
||||
ConvergenceClass::E
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────
|
||||
// Security Class (S0–S4) — information theory + cryptography
|
||||
|
|
@ -110,8 +107,10 @@ impl Default for ConvergenceClass {
|
|||
/// Measured resistance to adversarial conditions. `S0` (uncharacterized)
|
||||
/// is the default; `S4` (complete auditability) is the ceiling.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum SecurityClass {
|
||||
/// Uncharacterized. No security measurement. Default.
|
||||
#[default]
|
||||
S0,
|
||||
/// Adversarial robustness measured (attack success rate published).
|
||||
S1,
|
||||
|
|
@ -141,11 +140,6 @@ impl SecurityClass {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for SecurityClass {
|
||||
fn default() -> Self {
|
||||
SecurityClass::S0
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────
|
||||
// Energy Profile (joules) — thermodynamics
|
||||
|
|
@ -155,8 +149,10 @@ impl Default for SecurityClass {
|
|||
/// to disclose is a *valid state* — it just caps the achievable ARL at 3
|
||||
/// (enforced by [`crate::Claim::validate`]).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum EnergyProfile {
|
||||
/// Energy not disclosed. Caps the score at ARL 3.
|
||||
#[default]
|
||||
Undisclosed,
|
||||
/// All three figures disclosed.
|
||||
Disclosed {
|
||||
|
|
@ -184,11 +180,6 @@ impl EnergyProfile {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for EnergyProfile {
|
||||
fn default() -> Self {
|
||||
EnergyProfile::Undisclosed
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ fn to_hex(bytes: &[u8]) -> String {
|
|||
}
|
||||
|
||||
fn from_hex(s: &str, field: &'static str) -> Result<Vec<u8>, AttestError> {
|
||||
if s.len() % 2 != 0 {
|
||||
if !s.len().is_multiple_of(2) {
|
||||
return Err(AttestError::BadHex(field));
|
||||
}
|
||||
let bytes = s.as_bytes();
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ mod tests {
|
|||
"model-x v2",
|
||||
&mut harness,
|
||||
"what is the capital of france",
|
||||
&"ab".repeat(32),
|
||||
"ab".repeat(32),
|
||||
1_900_000_000,
|
||||
1_931_536_000,
|
||||
false,
|
||||
|
|
@ -298,7 +298,7 @@ mod tests {
|
|||
let mut sup = Supervisor::new("sup-1", key(), IsolationTier::Tier1, NullPhysicalSource);
|
||||
let mut harness = EchoHarness::new("harness v1");
|
||||
let eval = sup
|
||||
.evaluate("sut", &mut harness, "hi", &"0".repeat(64), 1, 2, false, false)
|
||||
.evaluate("sut", &mut harness, "hi", "0".repeat(64), 1, 2, false, false)
|
||||
.unwrap();
|
||||
assert!(!eval.session.telemetry.physical);
|
||||
// Tier 1 (ARL 4) requires all three categories → fails honestly.
|
||||
|
|
@ -310,8 +310,8 @@ mod tests {
|
|||
fn session_ids_are_unique_per_supervisor() {
|
||||
let mut sup = Supervisor::new("sup-1", key(), IsolationTier::Tier0, NullPhysicalSource);
|
||||
let mut h = EchoHarness::new("h");
|
||||
let a = sup.evaluate("s", &mut h, "x", &"0".repeat(64), 1, 2, false, false).unwrap();
|
||||
let b = sup.evaluate("s", &mut h, "y", &"0".repeat(64), 1, 2, false, false).unwrap();
|
||||
let a = sup.evaluate("s", &mut h, "x", "0".repeat(64), 1, 2, false, false).unwrap();
|
||||
let b = sup.evaluate("s", &mut h, "y", "0".repeat(64), 1, 2, false, false).unwrap();
|
||||
assert_ne!(a.session.session_id, b.session.session_id);
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ mod tests {
|
|||
);
|
||||
let mut h = EchoHarness::new("h");
|
||||
let eval = sup
|
||||
.evaluate("s", &mut h, "x", &"0".repeat(64), 1, 2, false, /* tampering */ true)
|
||||
.evaluate("s", &mut h, "x", "0".repeat(64), 1, 2, false, /* tampering */ true)
|
||||
.unwrap();
|
||||
assert!(eval.session.tampering_detected);
|
||||
// Attestation still verifies (it faithfully signs that tampering
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use crate::worker::{Load, Worker};
|
|||
|
||||
/// Routing strategy.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Default)]
|
||||
pub enum Strategy {
|
||||
/// Round-robin across satisfying workers.
|
||||
RoundRobin,
|
||||
|
|
@ -30,6 +31,7 @@ pub enum Strategy {
|
|||
/// Lowest projected p50 latency.
|
||||
LatencyWeighted,
|
||||
/// Lowest projected joule cost for a hypothetical N-token request.
|
||||
#[default]
|
||||
JouleWeighted,
|
||||
/// Lowest projected gCO2e for a hypothetical N-token request.
|
||||
CarbonWeighted,
|
||||
|
|
@ -53,11 +55,6 @@ pub struct Router {
|
|||
rr_counter: AtomicUsize,
|
||||
}
|
||||
|
||||
impl Default for Strategy {
|
||||
fn default() -> Self {
|
||||
Strategy::JouleWeighted
|
||||
}
|
||||
}
|
||||
|
||||
impl Router {
|
||||
/// Construct.
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
/// Span kind, per OTel.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum SpanKind {
|
||||
/// Default; an internal operation.
|
||||
#[default]
|
||||
Internal,
|
||||
/// Synchronous outbound call.
|
||||
Client,
|
||||
|
|
@ -33,16 +35,13 @@ pub enum SpanKind {
|
|||
Consumer,
|
||||
}
|
||||
|
||||
impl Default for SpanKind {
|
||||
fn default() -> Self {
|
||||
SpanKind::Internal
|
||||
}
|
||||
}
|
||||
|
||||
/// Status code per OTel.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum StatusCode {
|
||||
/// Default, unset by SDK.
|
||||
#[default]
|
||||
Unset,
|
||||
/// Operation succeeded.
|
||||
Ok,
|
||||
|
|
@ -50,11 +49,6 @@ pub enum StatusCode {
|
|||
Error,
|
||||
}
|
||||
|
||||
impl Default for StatusCode {
|
||||
fn default() -> Self {
|
||||
StatusCode::Unset
|
||||
}
|
||||
}
|
||||
|
||||
/// Span status: a code plus optional human-readable description.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn strictly_increasing() {
|
|||
|
||||
#[test]
|
||||
fn contains_zero() {
|
||||
assert!(NF4_LEVELS.iter().any(|&v| v == 0.0));
|
||||
assert!(NF4_LEVELS.contains(&0.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -58,22 +58,19 @@ impl Cite {
|
|||
|
||||
/// What the caller wants the pipeline to do about citations.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Default)]
|
||||
pub enum CitationPolicy {
|
||||
/// Citations are optional — the pipeline may return an answer with
|
||||
/// none.
|
||||
Optional,
|
||||
/// At least one citation must be attached, otherwise the answer is
|
||||
/// rejected.
|
||||
#[default]
|
||||
Required,
|
||||
/// Every retrieved chunk must contribute a citation.
|
||||
PerChunk,
|
||||
}
|
||||
|
||||
impl Default for CitationPolicy {
|
||||
fn default() -> Self {
|
||||
CitationPolicy::Required
|
||||
}
|
||||
}
|
||||
|
||||
/// Enforcement gate. Pipelines call [`CitationEnforcement::enforce`]
|
||||
/// just before returning.
|
||||
|
|
|
|||
|
|
@ -143,5 +143,5 @@ fn luhn_valid(s: &str) -> bool {
|
|||
sum += x;
|
||||
alt = !alt;
|
||||
}
|
||||
sum % 10 == 0
|
||||
sum.is_multiple_of(10)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ fn sse(event: &str, data: &str) -> SseEvent {
|
|||
#[test]
|
||||
fn full_text_message_lifecycle() {
|
||||
let m = AnthropicMapper;
|
||||
let frames = vec![
|
||||
sse(
|
||||
let frames = [sse(
|
||||
"message_start",
|
||||
r#"{"message":{"id":"msg_01","role":"assistant"}}"#,
|
||||
),
|
||||
|
|
@ -38,8 +37,7 @@ fn full_text_message_lifecycle() {
|
|||
"message_delta",
|
||||
r#"{"delta":{"stop_reason":"end_turn"}}"#,
|
||||
),
|
||||
sse("message_stop", r#"{}"#),
|
||||
];
|
||||
sse("message_stop", r#"{}"#)];
|
||||
|
||||
let mut events: Vec<Event> = Vec::new();
|
||||
for f in frames.iter() {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ fn read_envelope(path: &str) -> Result<Vec<u8>, String> {
|
|||
let raw = std::fs::read(path).map_err(|e| e.to_string())?;
|
||||
if let Ok(text) = std::str::from_utf8(&raw) {
|
||||
let t: String = text.split_whitespace().collect();
|
||||
if !t.is_empty() && t.len() % 2 == 0 && t.bytes().all(|c| c.is_ascii_hexdigit()) {
|
||||
if !t.is_empty() && t.len().is_multiple_of(2) && t.bytes().all(|c| c.is_ascii_hexdigit()) {
|
||||
return hex::decode(&t).map_err(|e| e.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ pub fn observe_shape(windows: &[EnergyWindow], idle_floor_uj: u64) -> Option<Dra
|
|||
.iter()
|
||||
.map(|&x| {
|
||||
let x = u128::from(x);
|
||||
if x > mean { x - mean } else { mean - x }
|
||||
x.abs_diff(mean)
|
||||
})
|
||||
.sum::<u128>()
|
||||
/ n;
|
||||
|
|
|
|||
|
|
@ -1821,12 +1821,12 @@ mod tests {
|
|||
let mut rt = Runtime::new();
|
||||
// Plain chain path: no facts under a ceiling ⇒ fail closed.
|
||||
assert_eq!(
|
||||
rt.decide_chained(&f, &[root_sg.clone()], did(&holder), Energy::measured(10), 10).verdict,
|
||||
rt.decide_chained(&f, std::slice::from_ref(&root_sg), did(&holder), Energy::measured(10), 10).verdict,
|
||||
Verdict::Deny(DenyReason::TaintedFlow),
|
||||
);
|
||||
// Flow chain path: a tainted argument is denied.
|
||||
assert_eq!(
|
||||
rt.decide_chained_flow(&f, &[root_sg.clone()], did(&holder), Energy::measured(10), 10, &tainted(7)).verdict,
|
||||
rt.decide_chained_flow(&f, std::slice::from_ref(&root_sg), did(&holder), Energy::measured(10), 10, &tainted(7)).verdict,
|
||||
Verdict::Deny(DenyReason::TaintedFlow),
|
||||
);
|
||||
// A clean argument passes.
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ fn main() {
|
|||
let claimed: Vec<String> = clauses.iter().map(|c| c.to_string()).collect();
|
||||
let reviews = reviewer.review(&o, &spec, &claimed).unwrap();
|
||||
let verdict = if approval(&o, &reviews).is_approved() { "✓ APPROVED" } else { "⛔ SENT BACK" };
|
||||
println!("{label}\n {verdict} (reviewer principal {}…)", &hex8(reviewer.principal()));
|
||||
println!("{label}\n {verdict} (reviewer principal {}…)", hex8(reviewer.principal()));
|
||||
for r in &reviews {
|
||||
let mark = if r.review.verdict == ReviewVerdict::Approve { "✓" } else { "✗" };
|
||||
print!(" {mark} {:?}", r.review.stage);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ fn hex_encode(bytes: &[u8]) -> String {
|
|||
#[cfg(feature = "quic")]
|
||||
fn hex_decode(s: &str) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
|
||||
let s = s.trim();
|
||||
if s.len() % 2 != 0 {
|
||||
if !s.len().is_multiple_of(2) {
|
||||
return Err("odd-length hex".into());
|
||||
}
|
||||
(0..s.len())
|
||||
|
|
|
|||
|
|
@ -936,8 +936,8 @@ impl Chain {
|
|||
}
|
||||
|
||||
fn remember_within(&mut self, link: [u8; 32], digest: [u8; 32], cap: usize) {
|
||||
if !self.links.contains_key(&link) {
|
||||
self.links.insert(link, digest);
|
||||
if let std::collections::btree_map::Entry::Vacant(e) = self.links.entry(link) {
|
||||
e.insert(digest);
|
||||
self.links_order.push_back(link);
|
||||
while self.links_order.len() > cap {
|
||||
if let Some(old) = self.links_order.pop_front() {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ pub const KNOWN_CAPABILITIES: &[&str] = &[
|
|||
/// known `comms.*` extensions. Linear scan — the registry is tiny.
|
||||
#[inline]
|
||||
pub fn is_known_capability(cap: &str) -> bool {
|
||||
KNOWN_CAPABILITIES.iter().any(|&k| k == cap)
|
||||
KNOWN_CAPABILITIES.contains(&cap)
|
||||
}
|
||||
|
||||
/// True iff `cap` is one of the three mandatory-floor capabilities every
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fn field<T: DeserializeOwned>(v: &Value, key: &str) -> T {
|
|||
}
|
||||
|
||||
fn unhex(s: &str) -> Vec<u8> {
|
||||
assert!(s.len() % 2 == 0, "odd-length hex");
|
||||
assert!(s.len().is_multiple_of(2), "odd-length hex");
|
||||
(0..s.len())
|
||||
.step_by(2)
|
||||
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).expect("hex digit"))
|
||||
|
|
|
|||
|
|
@ -583,12 +583,11 @@ pub fn apply_delta(tree: &mut Widget, delta: &UiDelta) -> Result<(), ApplyError>
|
|||
/// need transactional semantics.)
|
||||
pub fn apply_deltas(tree: &mut Widget, deltas: &[UiDelta]) -> Result<usize, ApplyError> {
|
||||
for (i, d) in deltas.iter().enumerate() {
|
||||
apply_delta(tree, d).map_err(|e| {
|
||||
apply_delta(tree, d).inspect_err(|_e| {
|
||||
// Preserve the failing index in tracing by returning the
|
||||
// err as-is; consumers can compute "first N succeeded"
|
||||
// from the tree itself if needed.
|
||||
let _ = i;
|
||||
e
|
||||
})?;
|
||||
}
|
||||
Ok(deltas.len())
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ mod negative_vector_replay {
|
|||
"{name}: demotion list"
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::to_value(&verdict.max_profile).unwrap(),
|
||||
serde_json::to_value(verdict.max_profile).unwrap(),
|
||||
expected["max_profile"],
|
||||
"{name}: maximum permitted profile"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ mod hex {
|
|||
bytes.as_ref().iter().map(|b| format!("{b:02x}")).collect()
|
||||
}
|
||||
pub fn decode(s: &str) -> Result<Vec<u8>, ()> {
|
||||
if s.len() % 2 != 0 {
|
||||
if !s.len().is_multiple_of(2) {
|
||||
return Err(());
|
||||
}
|
||||
(0..s.len())
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ mod tiles3d_tests {
|
|||
for i in idx {
|
||||
bin.extend_from_slice(&i.to_le_bytes());
|
||||
}
|
||||
while bin.len() % 4 != 0 {
|
||||
while !bin.len().is_multiple_of(4) {
|
||||
bin.push(0);
|
||||
}
|
||||
let json = serde_json::json!({
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ impl FleetRecord {
|
|||
let mut idx = index;
|
||||
let mut siblings = Vec::new();
|
||||
while level.len() > 1 {
|
||||
let sib = if idx % 2 == 0 {
|
||||
let sib = if idx.is_multiple_of(2) {
|
||||
// sibling on the right (or self, duplicated, at an odd end)
|
||||
(*level.get(idx + 1).unwrap_or(&level[idx]), true)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ impl EdgeGraph {
|
|||
let node = self
|
||||
.nodes
|
||||
.get(said)
|
||||
.ok_or_else(|| AcdcError::EdgeMissing(*said))?;
|
||||
.ok_or(AcdcError::EdgeMissing(*said))?;
|
||||
Edge::parse_section(&node.e)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -505,11 +505,11 @@ pub fn states(world: &World) -> J {
|
|||
Dropped("non_shortest_integer"),
|
||||
),
|
||||
(
|
||||
canonical::encode(&Value::map([("melt", Value::map([("byte", Value::text(&byte.to_said_text()))]))])).unwrap(),
|
||||
canonical::encode(&Value::map([("melt", Value::map([("byte", Value::text(byte.to_said_text()))]))])).unwrap(),
|
||||
Dropped("malformed_input"),
|
||||
),
|
||||
(
|
||||
canonical::encode(&Value::map([("burn", Value::map([("byte", Value::text(&byte.to_said_text()))]))])).unwrap(),
|
||||
canonical::encode(&Value::map([("burn", Value::map([("byte", Value::text(byte.to_said_text()))]))])).unwrap(),
|
||||
Dropped("malformed_input"),
|
||||
),
|
||||
(
|
||||
|
|
@ -519,7 +519,7 @@ pub fn states(world: &World) -> J {
|
|||
(
|
||||
"proposal",
|
||||
Value::map([
|
||||
("cluster", Value::text(&cluster("A").to_said_text())),
|
||||
("cluster", Value::text(cluster("A").to_said_text())),
|
||||
("sequence", Value::Unsigned(0)),
|
||||
("change", Value::map([("action", Value::text("mint_anything"))])),
|
||||
]),
|
||||
|
|
@ -555,7 +555,7 @@ pub fn states(world: &World) -> J {
|
|||
canonical::encode(&Value::map([(
|
||||
"transfer",
|
||||
Value::map([
|
||||
("byte", Value::text(&byte.to_said_text())),
|
||||
("byte", Value::text(byte.to_said_text())),
|
||||
("transition", wire::to_value(&t).unwrap()),
|
||||
("memo", Value::text("lunch")),
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ pub struct OpenPaymentsClient;
|
|||
impl OpenPaymentsClient {
|
||||
/// Construct a default client.
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
Self
|
||||
}
|
||||
|
||||
/// Serialise a resource to JSON.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ impl MemoryStorage {
|
|||
#[async_trait]
|
||||
impl EventLogStorage for MemoryStorage {
|
||||
async fn append(&self, controller: &ControllerAid, event: KeyEvent) -> Result<()> {
|
||||
self.logs.entry(controller.clone()).or_default().push(event);
|
||||
self.logs.entry(*controller).or_default().push(event);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ impl Watcher {
|
|||
r.verify_signature()?;
|
||||
}
|
||||
|
||||
let controller = event.controller().clone();
|
||||
let controller = *event.controller();
|
||||
let sequence = event.sequence();
|
||||
let said = event.said();
|
||||
|
||||
let mut entry = self
|
||||
.observed_controllers
|
||||
.entry(controller.clone())
|
||||
.entry(controller)
|
||||
.or_default();
|
||||
let log = entry.value_mut();
|
||||
let bucket = log.by_sequence.entry(sequence).or_default();
|
||||
|
|
@ -121,7 +121,7 @@ impl Watcher {
|
|||
let a = bucket[0].event.said();
|
||||
let b = bucket[1].event.said();
|
||||
let signal = DuplicityDetected {
|
||||
controller: controller.clone(),
|
||||
controller,
|
||||
sequence,
|
||||
fork: (a, b),
|
||||
detected_at: Utc::now(),
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ async fn witness_refuses_contradicting_receipt_and_watcher_detects() {
|
|||
|
||||
fn clone_controller(src: &Controller) -> Controller {
|
||||
Controller {
|
||||
aid: src.aid.clone(),
|
||||
aid: src.aid,
|
||||
current_keys: src.current_keys.clone(),
|
||||
next_keys: src.next_keys.clone(),
|
||||
threshold: src.threshold,
|
||||
|
|
@ -323,7 +323,7 @@ fn clone_controller(src: &Controller) -> Controller {
|
|||
witnesses: src.witnesses.clone(),
|
||||
witness_threshold: src.witness_threshold,
|
||||
key_event_log: src.key_event_log.clone(),
|
||||
delegated_by: src.delegated_by.clone(),
|
||||
delegated_by: src.delegated_by,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ async fn delegation_child_anchors_to_parent() {
|
|||
|
||||
let ck = KeyPair::generate(&mut rng);
|
||||
let (child, dlg) = Controller::delegate(
|
||||
parent.aid.clone(),
|
||||
parent.aid,
|
||||
vec![ck],
|
||||
vec![KeyPair::generate(&mut rng)],
|
||||
Threshold(1),
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ fn translate(ev: SwarmEvent<SmartByteBehaviourEvent>) -> Option<NodeEvent> {
|
|||
..
|
||||
})) => Some(NodeEvent::DiscoveredViaKad(peer)),
|
||||
SwarmEvent::Behaviour(SmartByteBehaviourEvent::Relay(
|
||||
relay::Event::ReservationReqAccepted { src_peer_id: _, .. },
|
||||
relay::Event::ReservationReqAccepted { .. },
|
||||
)) => None,
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ fn an_issuer_is_added_by_the_others_and_only_after_the_delay() {
|
|||
classes(&state.apply_frame(&[two])),
|
||||
vec![Err("below_quorum")]
|
||||
);
|
||||
assert_eq!(classes(&state.apply_frame(&[three.clone()])), vec![Ok(())]);
|
||||
assert_eq!(classes(&state.apply_frame(std::slice::from_ref(&three))), vec![Ok(())]);
|
||||
assert_eq!(state.governance.pending.len(), 1);
|
||||
assert_eq!(state.governance.pending[0].effective, 2 + 1 + 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ fn inspect(path: &str) -> Result<(), String> {
|
|||
println!(" renditions: {}", m.renditions.len());
|
||||
println!();
|
||||
println!(" rendition table (deployer-preferred order):");
|
||||
println!(" {:>3} {:>10} {:<28} {}", "idx", "bytes", "capability", "kind");
|
||||
println!(" {:>3} {:>10} {:<28} kind", "idx", "bytes", "capability");
|
||||
for (i, (meta, payload)) in
|
||||
m.manifest.renditions.iter().zip(m.renditions.iter()).enumerate()
|
||||
{
|
||||
|
|
@ -851,7 +851,7 @@ fn capabilities() -> Result<(), String> {
|
|||
if native.is_empty() {
|
||||
println!(" (built without the codecs feature: this binary decodes nothing natively)");
|
||||
}
|
||||
println!(" {:<26} {:<11} {:<13} {:<14} {:<21} {}", "capability", "fidelity", "decode", "license", "replicate", "role");
|
||||
println!(" {:<26} {:<11} {:<13} {:<14} {:<21} role", "capability", "fidelity", "decode", "license", "replicate");
|
||||
println!(" {:-<26} {:-<11} {:-<13} {:-<14} {:-<21} {:-<11}", "", "", "", "", "", "");
|
||||
for &c in caps {
|
||||
let tier = wai::codecs::capability_tier(c)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ fn png_decode_null_size_out() {
|
|||
|
||||
#[test]
|
||||
fn flac_decode_garbage() {
|
||||
let garbage = vec![0u8; 64];
|
||||
let garbage = [0u8; 64];
|
||||
let mut out = empty_buf();
|
||||
let mut sr = 0u32;
|
||||
let rc = unsafe {
|
||||
|
|
@ -141,7 +141,7 @@ fn opus_encode_invalid_sr() {
|
|||
|
||||
#[test]
|
||||
fn opus_decode_garbage() {
|
||||
let garbage = vec![0u8; 16];
|
||||
let garbage = [0u8; 16];
|
||||
let mut out = empty_buf();
|
||||
let mut sr = 0u32;
|
||||
let rc = unsafe {
|
||||
|
|
@ -164,7 +164,7 @@ fn zstd_decode_garbage() {
|
|||
|
||||
#[test]
|
||||
fn xz_decode_garbage() {
|
||||
let garbage = vec![0u8; 32];
|
||||
let garbage = [0u8; 32];
|
||||
let mut out = empty_buf();
|
||||
let rc = unsafe {
|
||||
wai_text_xz_decode(garbage.as_ptr(), garbage.len(), &mut out)
|
||||
|
|
@ -245,7 +245,7 @@ fn av1_encode_zero_fps() {
|
|||
|
||||
#[test]
|
||||
fn av1_decode_garbage() {
|
||||
let garbage = vec![0u8; 64];
|
||||
let garbage = [0u8; 64];
|
||||
let mut out = empty_buf();
|
||||
let mut n = 0u32; let mut h = 0u32; let mut w = 0u32;
|
||||
let mut fn_ = 0u32; let mut fd_ = 0u32;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ fn a_sequence_header_larger_than_the_framing_header_is_refused_before_it_allocat
|
|||
// pixels, so it refuses the stream's sequence header instead of allocating its
|
||||
// frames and leaving the size check to the decoded picture.
|
||||
let unit = av1_unit(256, 256, rav1e::color::ChromaSampling::Cs420, 8, [100, 128, 128]);
|
||||
let e = why(av1_decode(&framing(1, 16, 16, &[unit.clone()])));
|
||||
let e = why(av1_decode(&framing(1, 16, 16, std::slice::from_ref(&unit))));
|
||||
assert!(!e.contains("256×256 frame"), "the frame was decoded before it was refused: {e}");
|
||||
assert!(av1_decode(&framing(1, 256, 256, &[unit])).is_ok());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue