M2 Integration Test#4
Merged
vincentpalma merged 7 commits intofeature/spending-conditionsfrom Aug 4, 2025
Merged
Conversation
…ted `Proof::dummy_prove`
vincentpalma
reviewed
Aug 3, 2025
crates/cashu/src/nuts/nutxx/mod.rs
Outdated
| let executable: Executable = serde_json::from_str(executable_json).unwrap(); | ||
| let program_hash = Poseidon::hash_array(&executable.program.bytecode); | ||
|
|
||
| // panic!("Program hash: {}", program_hash.to_hex_string()); |
crates/cashu/src/nuts/nutxx/mod.rs
Outdated
| #[test] | ||
| fn test_verify() { | ||
| let cairo_proof = include_str!("example_proof.json").to_string(); | ||
| let cairo_proof: String = include_str!("example_proof.json").to_string(); |
There was a problem hiding this comment.
also pls remove the : String to avoid merge conflicts with other branches
Comment on lines
+521
to
+582
| // Alice gets 100 sats | ||
| fund_wallet(wallet_alice.clone(), 100, None) | ||
| .await | ||
| .expect("Failed to fund wallet"); | ||
|
|
||
| let proofs = wallet_alice | ||
| .get_unspent_proofs() | ||
| .await | ||
| .expect("Could not get proofs"); | ||
|
|
||
| let keyset_id: Id = get_keyset_id(&mint_bob).await; | ||
|
|
||
| let program_hash = | ||
| Felt::from_hex("0x44ab272273ab3cd02a7cd222d0ca335826b7eeb3824d865bb5db5d0cc9e80e2") | ||
| .unwrap(); // TODO: hash cairo program | ||
|
|
||
| let desired_program_output_hash = Some(NutXXConditions { | ||
| output: Some( | ||
| Felt::from_hex("0x579E8877C7755365D5EC1EC7D3A94A457EFF5D1F40482BBE9729C064CDEAD2") | ||
| .unwrap(), | ||
| ), | ||
| }); | ||
|
|
||
| let spending_conditions = | ||
| SpendingConditions::new_cairo(program_hash, desired_program_output_hash); | ||
|
|
||
| let pre_swap = PreMintSecrets::with_conditions( | ||
| keyset_id, | ||
| 100.into(), | ||
| &SplitTarget::default(), | ||
| &spending_conditions, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | ||
|
|
||
| let keys = mint_bob.pubkeys().keysets.first().cloned().unwrap().keys; | ||
|
|
||
| let post_swap = mint_bob.process_swap_request(swap_request).await.unwrap(); | ||
|
|
||
| let mut proofs = construct_proofs( | ||
| post_swap.signatures, | ||
| pre_swap.rs(), | ||
| pre_swap.secrets(), | ||
| &keys, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let pre_swap = PreMintSecrets::random(keyset_id, 100.into(), &SplitTarget::default()).unwrap(); | ||
|
|
||
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | ||
|
|
||
| // Listen for status updates on all input proof pks | ||
| let public_keys_to_listen: Vec<_> = swap_request | ||
| .inputs() | ||
| .ys() | ||
| .unwrap() | ||
| .iter() | ||
| .map(|pk| pk.to_string()) | ||
| .collect(); | ||
|
|
||
| let mut listener = mint_bob |
There was a problem hiding this comment.
Suggested change
| // Alice gets 100 sats | |
| fund_wallet(wallet_alice.clone(), 100, None) | |
| .await | |
| .expect("Failed to fund wallet"); | |
| let proofs = wallet_alice | |
| .get_unspent_proofs() | |
| .await | |
| .expect("Could not get proofs"); | |
| let keyset_id: Id = get_keyset_id(&mint_bob).await; | |
| let program_hash = | |
| Felt::from_hex("0x44ab272273ab3cd02a7cd222d0ca335826b7eeb3824d865bb5db5d0cc9e80e2") | |
| .unwrap(); // TODO: hash cairo program | |
| let desired_program_output_hash = Some(NutXXConditions { | |
| output: Some( | |
| Felt::from_hex("0x579E8877C7755365D5EC1EC7D3A94A457EFF5D1F40482BBE9729C064CDEAD2") | |
| .unwrap(), | |
| ), | |
| }); | |
| let spending_conditions = | |
| SpendingConditions::new_cairo(program_hash, desired_program_output_hash); | |
| let pre_swap = PreMintSecrets::with_conditions( | |
| keyset_id, | |
| 100.into(), | |
| &SplitTarget::default(), | |
| &spending_conditions, | |
| ) | |
| .unwrap(); | |
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | |
| let keys = mint_bob.pubkeys().keysets.first().cloned().unwrap().keys; | |
| let post_swap = mint_bob.process_swap_request(swap_request).await.unwrap(); | |
| let mut proofs = construct_proofs( | |
| post_swap.signatures, | |
| pre_swap.rs(), | |
| pre_swap.secrets(), | |
| &keys, | |
| ) | |
| .unwrap(); | |
| let pre_swap = PreMintSecrets::random(keyset_id, 100.into(), &SplitTarget::default()).unwrap(); | |
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | |
| // Listen for status updates on all input proof pks | |
| let public_keys_to_listen: Vec<_> = swap_request | |
| .inputs() | |
| .ys() | |
| .unwrap() | |
| .iter() | |
| .map(|pk| pk.to_string()) | |
| .collect(); | |
| let mut listener = mint_bob | |
| // Alice gets 100 sats | |
| fund_wallet(wallet_alice.clone(), 100, None) | |
| .await | |
| .expect("Failed to fund wallet"); | |
| let proofs = wallet_alice | |
| .get_unspent_proofs() | |
| .await | |
| .expect("Could not get proofs"); | |
| let keyset_id: Id = get_keyset_id(&mint_bob).await; | |
| let program_hash = | |
| Felt::from_hex("0x44ab272273ab3cd02a7cd222d0ca335826b7eeb3824d865bb5db5d0cc9e80e2") | |
| .unwrap(); // TODO: hash cairo program | |
| let desired_program_output_hash = Some(NutXXConditions { | |
| output: Some( | |
| Felt::from_hex("0x579E8877C7755365D5EC1EC7D3A94A457EFF5D1F40482BBE9729C064CDEAD2") | |
| .unwrap(), | |
| ), | |
| }); | |
| let spending_conditions = | |
| SpendingConditions::new_cairo(program_hash, desired_program_output_hash); | |
| let pre_swap = PreMintSecrets::with_conditions( | |
| keyset_id, | |
| 100.into(), | |
| &SplitTarget::default(), | |
| &spending_conditions, | |
| ) | |
| .unwrap(); | |
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | |
| let keys = mint_bob.pubkeys().keysets.first().cloned().unwrap().keys; | |
| let post_swap = mint_bob.process_swap_request(swap_request).await.unwrap(); | |
| let mut proofs = construct_proofs( | |
| post_swap.signatures, | |
| pre_swap.rs(), | |
| pre_swap.secrets(), | |
| &keys, | |
| ) | |
| .unwrap(); | |
| let pre_swap = PreMintSecrets::random(keyset_id, 100.into(), &SplitTarget::default()).unwrap(); | |
| let swap_request = SwapRequest::new(proofs.clone(), pre_swap.blinded_messages()); | |
| // Listen for status updates on all input proof pks | |
| let public_keys_to_listen: Vec<_> = swap_request | |
| .inputs() | |
| .ys() | |
| .unwrap() | |
| .iter() | |
| .map(|pk| pk.to_string()) | |
| .collect(); | |
| let mut listener = mint_bob |
style: group lines for better readability, a blank line after each line of code is too much: hurts eyes and takes up too much vertical space
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.