goas: add isolated test for zone fund constraint

This commit is contained in:
David Rusu 2024-08-19 20:46:48 +04:00
parent 341c8b44d3
commit a4e52b75aa
3 changed files with 23 additions and 4 deletions

View File

@ -157,7 +157,7 @@ pub fn prove_zone_stf(
ledger::DeathProof::from_risc0(goas_risc0_proofs::ZONE_STATE_ID, receipt)
}
pub fn prove_zone_fund_withdraw(
pub fn prove_zone_fund_constraint(
in_zone_funds: cl::PartialTxInputWitness,
zone_note: cl::PartialTxOutputWitness,
out_zone_state: &StateWitness,
@ -289,4 +289,23 @@ mod tests {
ptx_root: ptx.commit().root(),
}))
}
#[test]
fn test_prove_zone_fund_constraint() {
let zone =
ZoneNotes::new_with_balances("ZONE", BTreeMap::from_iter([]), &mut rand::thread_rng());
let ptx = PartialTxWitness {
inputs: vec![zone.fund_input_witness()],
outputs: vec![zone.state_note],
};
let proof =
prove_zone_fund_constraint(ptx.input_witness(0), ptx.output_witness(0), &zone.state);
assert!(proof.verify(DeathConstraintPublic {
nf: zone.fund_input_witness().nullifier(),
ptx_root: ptx.commit().root(),
}))
}
}

View File

@ -111,7 +111,7 @@ fn test_atomic_transfer() {
),
(
zone_a_start.fund_input_witness().nullifier(),
executor::prove_zone_fund_withdraw(
executor::prove_zone_fund_constraint(
atomic_transfer_ptx.input_witness(2), // input fund note
atomic_transfer_ptx.output_witness(0), // output state note
&zone_a_end.state,
@ -129,7 +129,7 @@ fn test_atomic_transfer() {
),
(
zone_b_start.fund_input_witness().nullifier(),
executor::prove_zone_fund_withdraw(
executor::prove_zone_fund_constraint(
atomic_transfer_ptx.input_witness(4), // input fund note (input #1)
atomic_transfer_ptx.output_witness(2), // output state note (output #0)
&zone_b_end.state,

View File

@ -73,7 +73,7 @@ fn test_withdrawal() {
),
(
zone_start.fund_input_witness().nullifier(),
executor::prove_zone_fund_withdraw(
executor::prove_zone_fund_constraint(
withdraw_ptx.input_witness(1), // input fund note (input #1)
withdraw_ptx.output_witness(0), // output state note (output #0)
&zone_end.state,