Skip to content

M2 Integration Test#4

Merged
vincentpalma merged 7 commits intofeature/spending-conditionsfrom
mint-verify
Aug 4, 2025
Merged

M2 Integration Test#4
vincentpalma merged 7 commits intofeature/spending-conditionsfrom
mint-verify

Conversation

@YofiY
Copy link
Collaborator

@YofiY YofiY commented Aug 3, 2025

No description provided.

@YofiY YofiY requested a review from vincentpalma August 3, 2025 16:46
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());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this pls

#[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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@vincentpalma vincentpalma merged commit 9948cee into feature/spending-conditions Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants