Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c431aad9c9 | |||
| 50b978cd8b | |||
| e6d8f33b41 | |||
| ecdfa88d21 |
6 changed files with 10 additions and 12 deletions
|
|
@ -1468,7 +1468,7 @@ mod tests {
|
||||||
let before = head(&mind);
|
let before = head(&mind);
|
||||||
let id = request.request_id.clone();
|
let id = request.request_id.clone();
|
||||||
let (answer, outcome) = stored(ask(&mut mind, &decider("y"), request.clone()));
|
let (answer, outcome) = stored(ask(&mut mind, &decider("y"), request.clone()));
|
||||||
assert_eq!(outcome, DeskOutcome::Refused { code: DeskRefusal::BadRetraction, retracts: sent.2.map(|target| s(target)) }, "{what}");
|
assert_eq!(outcome, DeskOutcome::Refused { code: DeskRefusal::BadRetraction, retracts: sent.2.map(s) }, "{what}");
|
||||||
assert_eq!(head(&mind), before + 1, "{what} is stored");
|
assert_eq!(head(&mind), before + 1, "{what} is stored");
|
||||||
// The record keeps what was sent: the choice, the note and the target it named.
|
// The record keeps what was sent: the choice, the note and the target it named.
|
||||||
let record = held(&mind, &answer);
|
let record = held(&mind, &answer);
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,7 @@ impl<S: MindStore> Mind<S> {
|
||||||
let Some(PipelineDocument::DeskAnswer(stored)) = docs.find(PipelineKind::DeskAnswer, &key) else { return Err(unreadable_key()) };
|
let Some(PipelineDocument::DeskAnswer(stored)) = docs.find(PipelineKind::DeskAnswer, &key) else { return Err(unreadable_key()) };
|
||||||
let fork = stored.fork.0.as_str();
|
let fork = stored.fork.0.as_str();
|
||||||
let counted_answer_id = counted_answer(&docs, fork).map(|counted| answer_seq(fork, &counted).map(n_text).ok_or_else(unreadable_key)).transpose()?;
|
let counted_answer_id = counted_answer(&docs, fork).map(|counted| answer_seq(fork, &counted).map(n_text).ok_or_else(unreadable_key)).transpose()?;
|
||||||
Ok((DeskResponse::Answered { answer: project(&key, stored)?, counted_answer_id, as_of: image.head }))
|
Ok(DeskResponse::Answered { answer: project(&key, stored)?, counted_answer_id, as_of: image.head })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ mod tests {
|
||||||
fn view(document: PipelineDocument, ordinal: u64) -> PipelineDocumentView {
|
fn view(document: PipelineDocument, ordinal: u64) -> PipelineDocumentView {
|
||||||
let key = pipeline_key(&document).unwrap();
|
let key = pipeline_key(&document).unwrap();
|
||||||
let id = PipelineRef { kind: document.kind(), id: s(&key) };
|
let id = PipelineRef { kind: document.kind(), id: s(&key) };
|
||||||
let faculty = if ordinal % 2 == 0 { Faculty::Hands } else { Faculty::Soul };
|
let faculty = if ordinal.is_multiple_of(2) { Faculty::Hands } else { Faculty::Soul };
|
||||||
let admission = AdmissionFacts {
|
let admission = AdmissionFacts {
|
||||||
receipt_id: format!("receipt-{ordinal}"),
|
receipt_id: format!("receipt-{ordinal}"),
|
||||||
admitted_at: format!("2026-11-08T16:{ordinal:02}:00Z"),
|
admitted_at: format!("2026-11-08T16:{ordinal:02}:00Z"),
|
||||||
|
|
@ -226,7 +226,7 @@ mod tests {
|
||||||
let to_source = [held.clone(), vec![moved(RECEIVER, 4)]].concat();
|
let to_source = [held.clone(), vec![moved(RECEIVER, 4)]].concat();
|
||||||
assert_eq!(plan(&slug(CAMPAIGN), &slug(RECEIVER), &slug(RECEIVER), to_source), Err(ImportFault::SourceIsReceiver));
|
assert_eq!(plan(&slug(CAMPAIGN), &slug(RECEIVER), &slug(RECEIVER), to_source), Err(ImportFault::SourceIsReceiver));
|
||||||
let other_root = view(
|
let other_root = view(
|
||||||
resolution(r(K::Campaign, &format!("elsewhere:campaign:self")), ResolutionOutcome::Moved { to: slug(RECEIVER) }),
|
resolution(r(K::Campaign, "elsewhere:campaign:self"), ResolutionOutcome::Moved { to: slug(RECEIVER) }),
|
||||||
4,
|
4,
|
||||||
);
|
);
|
||||||
assert_eq!(plan_of([held, vec![other_root]].concat()), Err(ImportFault::NotMoved), "another root's move does not move this one");
|
assert_eq!(plan_of([held, vec![other_root]].concat()), Err(ImportFault::NotMoved), "another root's move does not move this one");
|
||||||
|
|
|
||||||
|
|
@ -663,7 +663,6 @@ fn an_import_never_cites_or_resolves_a_follow_up_the_receiver_wrote() {
|
||||||
let native = follow_up("FU-N", r(K::Question, &q1));
|
let native = follow_up("FU-N", r(K::Question, &q1));
|
||||||
let native_ref = r(K::FollowUp, &pipeline_key(&native).unwrap());
|
let native_ref = r(K::FollowUp, &pipeline_key(&native).unwrap());
|
||||||
committed(admit(&mut recv, vec![native]));
|
committed(admit(&mut recv, vec![native]));
|
||||||
let before = head(&recv);
|
|
||||||
// An imported record that withdraws the receiver's own follow-up mixes a replay into her work.
|
// An imported record that withdraws the receiver's own follow-up mixes a replay into her work.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
refusal(import_from_kiko(&mut recv, vec![resolution(native_ref.clone(), ResolutionOutcome::Withdrawn { reason: "x".into() })])),
|
refusal(import_from_kiko(&mut recv, vec![resolution(native_ref.clone(), ResolutionOutcome::Withdrawn { reason: "x".into() })])),
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ fn zero_width(c: char) -> bool {
|
||||||
pub fn scrub(text: &str) -> Scrubbed {
|
pub fn scrub(text: &str) -> Scrubbed {
|
||||||
let mut hits = Vec::new();
|
let mut hits = Vec::new();
|
||||||
let mut stripped: String = text.chars().filter(|c| !zero_width(*c)).collect();
|
let mut stripped: String = text.chars().filter(|c| !zero_width(*c)).collect();
|
||||||
let passes: [(ScrubKind, fn(&str, usize) -> Option<usize>); 6] = [
|
let passes: [(ScrubKind, Finder); 6] = [
|
||||||
(ScrubKind::PemBlock, pem_block),
|
(ScrubKind::PemBlock, pem_block),
|
||||||
(ScrubKind::AuthorizationHeader, authorization_line),
|
(ScrubKind::AuthorizationHeader, authorization_line),
|
||||||
(ScrubKind::AccessToken, access_token),
|
(ScrubKind::AccessToken, access_token),
|
||||||
|
|
@ -176,7 +176,10 @@ pub fn scrub(text: &str) -> Scrubbed {
|
||||||
if hits.is_empty() { Scrubbed { text: text.to_owned(), hits } } else { Scrubbed { text: urls, hits } }
|
if hits.is_empty() { Scrubbed { text: text.to_owned(), hits } } else { Scrubbed { text: urls, hits } }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_matches(text: &str, kind: ScrubKind, find: fn(&str, usize) -> Option<usize>, hits: &mut Vec<ScrubKind>) -> String {
|
/// A scrub pass: finds the end of one secret starting at a byte offset, if one starts there.
|
||||||
|
type Finder = fn(&str, usize) -> Option<usize>;
|
||||||
|
|
||||||
|
fn replace_matches(text: &str, kind: ScrubKind, find: Finder, hits: &mut Vec<ScrubKind>) -> String {
|
||||||
let mut out = String::with_capacity(text.len());
|
let mut out = String::with_capacity(text.len());
|
||||||
let mut at = 0;
|
let mut at = 0;
|
||||||
while at < text.len() {
|
while at < text.len() {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use huginn_mind::desk_wire::{
|
||||||
ForkList, ForkOption, ForkRecord, ForkRefusal, ForkRefusalCode, ForkRef, ListSchema, ListStatus, RecordSchema,
|
ForkList, ForkOption, ForkRecord, ForkRefusal, ForkRefusalCode, ForkRef, ListSchema, ListStatus, RecordSchema,
|
||||||
};
|
};
|
||||||
use huginn_mind::envelope::{OperationFailure, decode_desk_request, encode_desk_failure, encode_desk_request, encode_desk_response};
|
use huginn_mind::envelope::{OperationFailure, decode_desk_request, encode_desk_failure, encode_desk_request, encode_desk_response};
|
||||||
use huginn_mind::eureka_pipeline::{AccountId, DeskAuthority, Short, Slug};
|
use huginn_mind::eureka_pipeline::{AccountId, DeskAuthority, Slug};
|
||||||
|
|
||||||
const RUNTIME: &str = "huginn-eureka";
|
const RUNTIME: &str = "huginn-eureka";
|
||||||
/// Account ids as Bifrost sends them: `UserAccount.Id` rendered lowercase D-format
|
/// Account ids as Bifrost sends them: `UserAccount.Id` rendered lowercase D-format
|
||||||
|
|
@ -38,10 +38,6 @@ const NON_DECIDER: &str = "9e8d7c6b-5a49-4382-b1a0-f9e8d7c6b5a4";
|
||||||
/// synthetic: the hash is CultLib's sample digest, not this question's.
|
/// synthetic: the hash is CultLib's sample digest, not this question's.
|
||||||
const FORK: &str = "eureka-substrate:question:desk-listing-authority";
|
const FORK: &str = "eureka-substrate:question:desk-listing-authority";
|
||||||
|
|
||||||
fn s(text: &str) -> Short {
|
|
||||||
Short(text.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn a(text: &str) -> AccountId {
|
fn a(text: &str) -> AccountId {
|
||||||
AccountId(text.into())
|
AccountId(text.into())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue