respect slate version

This commit is contained in:
wiesche
2026-09-07 18:53:36 +02:00
parent 538040865a
commit c613d82daf
9 changed files with 110 additions and 44 deletions
+18 -8
View File
@@ -84,7 +84,9 @@ fn slatepack_exchange_test_impl(
use_bin: bool,
use_armored: bool,
use_encryption: bool,
target_slate_version: Option<u16>,
) -> Result<(), libwallet::Error> {
let expected_slate_version = target_slate_version.unwrap_or(4);
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
@@ -236,6 +238,7 @@ fn slatepack_exchange_test_impl(
max_outputs: 500,
num_change_outputs: 1,
selection_strategy_is_use_all: true,
target_slate_version,
..Default::default()
};
let slate = api.init_send_tx(m, args)?;
@@ -261,6 +264,7 @@ fn slatepack_exchange_test_impl(
let (mut slatepack, mut slate) =
slate_from_packed(&send_file, use_armored, (&dec_key_2).as_ref())?;
assert_eq!(slate.version_info.version, expected_slate_version);
// wallet 2 receives file, completes, sends file back
wallet::controller::foreign_single_use(
@@ -293,7 +297,9 @@ fn slatepack_exchange_test_impl(
|api, m| {
let (_, mut slate) =
slate_from_packed(&receive_file, use_armored, (&dec_key_1).as_ref())?;
assert_eq!(slate.version_info.version, expected_slate_version);
slate = api.finalize_tx(m, &slate)?;
assert_eq!(slate.version_info.version, expected_slate_version);
// Output final file for reference
output_slatepack(&slate, &final_file, use_armored, use_bin, None, vec![])?;
api.post_tx(m, &slate, false)?;
@@ -357,6 +363,7 @@ fn slatepack_exchange_test_impl(
|api, m| {
let args = IssueInvoiceTxArgs {
amount: 1000000000,
target_slate_version,
..Default::default()
};
slate = api.issue_invoice_tx(m, args)?;
@@ -389,6 +396,7 @@ fn slatepack_exchange_test_impl(
let res = slate_from_packed(&send_file, use_armored, (&dec_key_1).as_ref())?;
slatepack = res.0;
slate = res.1;
assert_eq!(slate.version_info.version, expected_slate_version);
slate = api.process_invoice_tx(m, &slate, args)?;
api.tx_lock_outputs(m, &slate)?;
output_slatepack(
@@ -413,7 +421,9 @@ fn slatepack_exchange_test_impl(
// Wallet 2 receives the invoice transaction
let res = slate_from_packed(&receive_file, use_armored, (&dec_key_2).as_ref())?;
slate = res.1;
assert_eq!(slate.version_info.version, expected_slate_version);
slate = api.finalize_tx(&slate, false)?;
assert_eq!(slate.version_info.version, expected_slate_version);
output_slatepack(&slate, &final_file, use_armored, use_bin, None, vec![])?;
Ok(())
},
@@ -707,11 +717,11 @@ fn slatepack_address_validation(test_dir: &'static str) -> Result<(), libwallet:
}
#[test]
fn slatepack_exchange_json() {
let test_dir = "test_output/slatepack_exchange_json";
fn slatepack_exchange_json_v5() {
let test_dir = "test_output/slatepack_exchange_json_v5";
setup(test_dir);
// Json output
if let Err(e) = slatepack_exchange_test_impl(test_dir, false, false, false) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, false, false, false, Some(5)) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);
@@ -722,7 +732,7 @@ fn slatepack_exchange_bin() {
let test_dir = "test_output/slatepack_exchange_bin";
setup(test_dir);
// Bin output
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, false, false) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, false, false, None) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);
@@ -733,7 +743,7 @@ fn slatepack_exchange_armored() {
let test_dir = "test_output/slatepack_exchange_armored";
setup(test_dir);
// Bin output
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, true, true) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, true, true, None) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);
@@ -744,7 +754,7 @@ fn slatepack_exchange_json_enc() {
let test_dir = "test_output/slatepack_exchange_json_enc";
setup(test_dir);
// Json output
if let Err(e) = slatepack_exchange_test_impl(test_dir, false, false, true) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, false, false, true, None) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);
@@ -755,7 +765,7 @@ fn slatepack_exchange_bin_enc() {
let test_dir = "test_output/slatepack_exchange_bin_enc";
setup(test_dir);
// Bin output
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, false, true) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, false, true, None) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);
@@ -766,7 +776,7 @@ fn slatepack_exchange_armored_enc() {
let test_dir = "test_output/slatepack_exchange_armored_enc";
setup(test_dir);
// Bin output
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, true, true) {
if let Err(e) = slatepack_exchange_test_impl(test_dir, true, true, true, None) {
panic!("Libwallet Error: {}", e);
}
clean_output_dir(test_dir);