fix contract context retries

This commit is contained in:
wiesche
2026-09-11 19:55:25 +02:00
parent 9c21ee3525
commit 2b6b58a093
7 changed files with 86 additions and 31 deletions
+26 -11
View File
@@ -208,6 +208,16 @@ fn contract_revoke_resume_impl(test_dir: &'static str) -> Result<(), wallet::Err
create_wallets(vec![vec![("default", 4)]], test_dir).unwrap();
let wallet1 = wallets[0].0.clone();
let mask1 = wallets[0].1.as_ref();
let args = ContractNewArgsAPI {
setup_args: ContractSetupArgsAPI {
selection_args: common::contract_selection_args(),
net_change: Some(-1_000_000_000),
num_participants: 2,
add_outputs: true,
..Default::default()
},
..Default::default()
};
// Send (with early lock), locking an input under the contract tx.
let mut slate = Slate::blank(0, true);
@@ -216,21 +226,26 @@ fn contract_revoke_resume_impl(test_dir: &'static str) -> Result<(), wallet::Err
mask1,
PathBuf::from(test_dir),
|api, m| {
let args = &ContractNewArgsAPI {
setup_args: ContractSetupArgsAPI {
selection_args: common::contract_selection_args(),
net_change: Some(-1_000_000_000),
num_participants: 2,
add_outputs: true,
..Default::default()
},
..Default::default()
};
slate = api.contract_new(m, args)?;
slate = api.contract_new(m, &args)?;
Ok(())
},
)?;
assert_eq!(slate.state, SlateState::Standard1);
{
wallet_inst!(wallet1, w);
let retried =
libwallet::contract::new(w, mask1, &args.setup_args, args.ttl_blocks, Some(slate.id))?;
assert_eq!(retried.id, slate.id);
assert_eq!(retried.fee_fields, slate.fee_fields);
assert_eq!(
retried.participant_data[0].public_nonce,
slate.participant_data[0].public_nonce
);
assert_eq!(
retried.participant_data[0].public_blind_excess,
slate.participant_data[0].public_blind_excess
);
}
let mut tx_id = 0;
wallet::controller::owner_single_use(
+28
View File
@@ -667,6 +667,34 @@ fn contract_srs_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
},
)?;
// Keep our fee when setup is retried with the original slate
let sender_args = ContractSetupArgsAPI {
selection_args: common::contract_selection_args(),
net_change: Some(-1_000_000_000),
..Default::default()
};
let receiver_args = ContractSetupArgsAPI {
selection_args: common::contract_selection_args(),
net_change: Some(1_000_000_000),
..Default::default()
};
let incoming = {
wallet_inst!(send_wallet, w);
libwallet::contract::new(w, send_mask, &sender_args, None, None)?
};
let signed = {
wallet_inst!(recv_wallet, w);
let first = libwallet::contract::setup(w, recv_mask, &incoming, &receiver_args)?;
let retried = libwallet::contract::setup(w, recv_mask, &incoming, &receiver_args)?;
assert_eq!(retried.fee_fields, first.fee_fields);
libwallet::contract::sign(w, recv_mask, &incoming, &receiver_args)?
};
{
wallet_inst!(send_wallet, w);
let signed = libwallet::contract::sign(w, send_mask, &signed, &sender_args)?;
assert_eq!(signed.state, SlateState::Standard3);
}
// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));