chore: enums for statement and op types (#69)

* Experiment with statement & op enums

* Clean-up & fixes

* More clean-up

* Add argument length checks

* More clean-up

* Place statement and operation logic in submodules
This commit is contained in:
Ahmad Afuni 2025-02-20 19:08:29 +10:00 committed by GitHub
parent 83a4f8969f
commit c2d23b0b1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 891 additions and 606 deletions

View file

@ -208,14 +208,24 @@ pub fn tickets_sign_pod_builder(params: &Params) -> SignedPodBuilder {
builder
}
pub fn tickets_pod_builder(params: &Params, signed_pod: &SignedPod, expected_event_id: i64, expect_consumed: bool, blacklisted_emails: &Value) -> MainPodBuilder {
pub fn tickets_pod_builder(
params: &Params,
signed_pod: &SignedPod,
expected_event_id: i64,
expect_consumed: bool,
blacklisted_emails: &Value,
) -> MainPodBuilder {
// Create a main pod referencing this signed pod with some statements
let mut builder = MainPodBuilder::new(params);
builder.add_signed_pod(signed_pod);
builder.pub_op(op!(eq, (signed_pod, "eventId"), expected_event_id));
builder.pub_op(op!(eq, (signed_pod, "isConsumed"), expect_consumed));
builder.pub_op(op!(eq, (signed_pod, "isRevoked"), false));
builder.pub_op(op!(not_contains, blacklisted_emails, (signed_pod, "attendeeEmail")));
builder.pub_op(op!(
not_contains,
blacklisted_emails,
(signed_pod, "attendeeEmail")
));
builder
}
@ -223,5 +233,11 @@ pub fn tickets_pod_full_flow() -> MainPodBuilder {
let params = Params::default();
let builder = tickets_sign_pod_builder(&params);
let signed_pod = builder.sign(&mut MockSigner { pk: "test".into() }).unwrap();
tickets_pod_builder(&params, &signed_pod, 123, true, &Value::Dictionary(Dictionary::new(&HashMap::new())))
tickets_pod_builder(
&params,
&signed_pod,
123,
true,
&Value::Dictionary(Dictionary::new(&HashMap::new())),
)
}