MCPcopy Create free account
hub / github.com/base/base / validate

Method validate

acceptance/src/config.rs:74–184  ·  view source on GitHub ↗

Validates schema, schedules, endpoints and all observation bounds.

(&self)

Source from the content-addressed store, hash-verified

72
73 /// Validates schema, schedules, endpoints and all observation bounds.
74 pub fn validate(&self) -> Result<()> {
75 if self.schema_version != 1 {
76 bail!("unsupported schema_version {}; expected 1", self.schema_version);
77 }
78 Self::validate_id(&self.id, "scenario")?;
79 if self.description.trim().is_empty() {
80 bail!("description must not be empty");
81 }
82 if self.description.len() > MAX_DESCRIPTION_BYTES {
83 bail!("description must not exceed {MAX_DESCRIPTION_BYTES} bytes");
84 }
85 Self::validate_duration(self.timeout.0, "scenario timeout", 1, 3600)?;
86 if self.devnet.topology != "single-sequencer" {
87 bail!("unsupported topology {}; HA is not version-one", self.devnet.topology);
88 }
89 if self.devnet.l1.chain_id == 0 || self.devnet.l2.chain_id == 0 {
90 bail!("chain IDs must be non-zero");
91 }
92 if self.devnet.l2.verifier_l1_confirmations > 10_000 {
93 bail!("verifier_l1_confirmations must not exceed 10000");
94 }
95 Self::validate_duration(self.devnet.l1.slot_duration.0, "L1 slot duration", 1, 60)?;
96 if self.devnet.l1.slot_duration.0.subsec_nanos() != 0 {
97 bail!("L1 slot duration must use whole seconds");
98 }
99 Self::validate_duration_against(
100 self.readiness.timeout.0,
101 "readiness timeout",
102 Duration::from_secs(1),
103 self.timeout.0,
104 )?;
105 Self::validate_duration(self.readiness.request_timeout.0, "request timeout", 1, 30)?;
106 Self::validate_duration(self.readiness.poll_interval.0, "poll interval", 1, 30)?;
107 if self.readiness.request_timeout.0 > self.readiness.timeout.0 {
108 bail!("request timeout exceeds readiness timeout");
109 }
110 if self.checks.is_empty() {
111 bail!("at least one check is required");
112 }
113 if self.checks.len() > MAX_CHECKS {
114 bail!("no more than {MAX_CHECKS} checks are allowed");
115 }
116 let mut ids = BTreeSet::new();
117 let mut latest_after_fork = None;
118 for check in &self.checks {
119 Self::validate_id(check.id(), "check")?;
120 if !ids.insert(check.id().to_ascii_lowercase()) {
121 bail!("duplicate check id {}", check.id());
122 }
123 check.validate(self)?;
124 if let Some(start) = check.start() {
125 let fork = start.before_fork.as_ref().or(start.after_fork.as_ref());
126 let block = fork
127 .and_then(|fork| self.devnet.l2.forks.get(fork))
128 .and_then(ForkActivation::block);
129 if start.after_fork.is_some() {
130 latest_after_fork = latest_after_fork.max(block);
131 } else if let Some(block) = block {

Callers 7

loadMethod · 0.45
verified_forksMethod · 0.45
runMethod · 0.45
run_serverFunction · 0.45

Calls 15

is_someMethod · 0.80
maxMethod · 0.80
timeoutMethod · 0.80
newFunction · 0.50
is_emptyMethod · 0.45
lenMethod · 0.45
idMethod · 0.45
insertMethod · 0.45
startMethod · 0.45
as_refMethod · 0.45
getMethod · 0.45
blockMethod · 0.45