Serialize and hash custom predicates (#90)
* Print pods from SignedPodBuilder * Add additional print to test printing SignedPodBuilder * Mock-prove and print MainPod * Implement ToFields for custom predicates and dependencies * Test: print serialization of a recursive batch * Rearrange serialization of CustomPredicate so args_len is always in the same position * Serialize predicates with first entry nonzero to avoid collision with padding * Off by one error in ethdos test BatchSelf(2) * cargo fmt * not a typo * Typos, trying again
This commit is contained in:
parent
05c21ebe6a
commit
a37b96ab4f
8 changed files with 262 additions and 39 deletions
|
|
@ -171,13 +171,16 @@ fn resolve_wildcard(args: &[&str], priv_args: &[&str], v: &HashOrWildcardStr) ->
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::middleware::{CustomPredicateRef, PodType};
|
||||
use crate::middleware::{CustomPredicateRef, Params, PodType};
|
||||
|
||||
#[test]
|
||||
fn test_custom_pred() {
|
||||
use NativePredicate as NP;
|
||||
use StatementTmplBuilder as STB;
|
||||
|
||||
let params = Params::default();
|
||||
params.print_serialized_sizes();
|
||||
|
||||
let mut builder = CustomPredicateBatchBuilder::new("eth_friend".into());
|
||||
let _eth_friend = builder.predicate_and(
|
||||
// arguments:
|
||||
|
|
@ -239,7 +242,7 @@ mod tests {
|
|||
builder.predicates.last().unwrap()
|
||||
);
|
||||
|
||||
let eth_dos_distance = Predicate::BatchSelf(3);
|
||||
let eth_dos_distance = Predicate::BatchSelf(2);
|
||||
|
||||
// next chunk builds:
|
||||
let eth_dos_distance_ind = builder.predicate_and(
|
||||
|
|
@ -311,5 +314,9 @@ mod tests {
|
|||
"b.2. eth_dos_distance = {}",
|
||||
builder.predicates.last().unwrap()
|
||||
);
|
||||
|
||||
let eth_dos_batch_b = builder.finish();
|
||||
let fields = eth_dos_batch_b.to_fields(params);
|
||||
println!("Batch b, serialized: {:?}", fields);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue