Skip to content

Commit

Permalink
Fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Oct 28, 2024
1 parent 9838b4a commit d026a1e
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions src/run_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,41 +1300,6 @@ mod tests {
}
}

fn check(res: (NodePtr, &str)) -> NodePtr {
assert_eq!(res.1, "");
res.0
}

fn run_test_case(t: &RunProgramTest) {
use crate::chia_dialect::ChiaDialect;
use crate::test_ops::node_eq;
let mut allocator = Allocator::new();

let program = check(parse_exp(&mut allocator, t.prg));
let args = check(parse_exp(&mut allocator, t.args));
let expected_result = &t.result.map(|v| check(parse_exp(&mut allocator, v)));

let dialect = ChiaDialect::new(t.flags);
println!("prg: {}", t.prg);
match run_program(&mut allocator, &dialect, program, args, t.cost) {
Ok(Reduction(cost, prg_result)) => {
assert!(node_eq(&allocator, prg_result, expected_result.unwrap()));
assert_eq!(cost, t.cost);

// now, run the same program again but with the cost limit 1 too low, to
// ensure it fails with the correct error
let expected_cost_exceeded =
run_program(&mut allocator, &dialect, program, args, t.cost - 1).unwrap_err();
assert_eq!(expected_cost_exceeded.1, "cost exceeded");
}
Err(err) => {
println!("FAILED: {}", err.1);
assert_eq!(err.1, t.err);
assert!(expected_result.is_none());
}
}
}

// the test cases for this test consists of:
// prg: the program to run inside the softfork guard
// cost: the expected cost of the program (the test adds the apply-operator)
Expand Down

0 comments on commit d026a1e

Please sign in to comment.