merge staging

This commit is contained in:
wiesche
2026-09-15 22:30:41 +02:00
12 changed files with 146 additions and 40 deletions
+38
View File
@@ -124,6 +124,44 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
)?;
assert_eq!(slate.state, SlateState::Invoice1);
let receive_result = wallet::controller::foreign_single_use(
wallet1.clone(),
PathBuf::from(test_dir),
mask1_i.clone(),
|api| api.receive_tx(&slate, None, None).map(|_| ()),
);
assert_eq!(receive_result, Err(libwallet::Error::SlateState));
wallet::controller::owner_single_use(
wallet1.clone(),
mask1,
PathBuf::from(test_dir),
|api, m| {
let (_, txs) = api.retrieve_txs(m, false, None, Some(slate.id), None)?;
assert!(txs.is_empty());
Ok(())
},
)?;
// receive must reject every slate state except S1
for state in [
SlateState::Unknown,
SlateState::Standard2,
SlateState::Standard3,
SlateState::Invoice1,
SlateState::Invoice2,
SlateState::Invoice3,
] {
let mut bad_slate = slate.clone();
bad_slate.state = state.clone();
let res = wallet::controller::foreign_single_use(
wallet1.clone(),
PathBuf::from(test_dir),
mask1_i.clone(),
|api| api.receive_tx(&bad_slate, None, None).map(|_| ()),
);
assert_eq!(res, Err(libwallet::Error::SlateState), "state {}", state);
}
wallet::controller::owner_single_use(
wallet1.clone(),
mask1,
+23 -1
View File
@@ -23,7 +23,7 @@ use grin_core as core;
use self::core::core::transaction;
use self::core::core::Transaction;
use self::core::global;
use self::libwallet::{InitTxArgs, OutputStatus, Slate, SlateState};
use self::libwallet::{InitTxArgs, OutputStatus, Slate, SlateState, GRIN_BLOCK_HEADER_VERSION};
use impls::test_framework::{self, LocalWalletClient};
use std::convert::TryInto;
use std::path::PathBuf;
@@ -105,6 +105,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
// assert wallet contents
// and a single use api for a send command
let amount = 60_000_000_000;
let header_version = core::consensus::header_version(chain.head().unwrap().height).0;
let mut slate = Slate::blank(1, false);
wallet::controller::owner_single_use(
wallet1.clone(),
@@ -124,6 +125,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
let slate_i = sender_api.init_send_tx(m, args)?;
assert_eq!(slate_i.state, SlateState::Standard1);
assert_eq!(slate_i.version_info.block_header_version, header_version);
// Check we are creating a tx with the expected lock_height of 0.
// We will check this produces a Plain kernel later.
@@ -131,6 +133,26 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
assert_eq!(slate.state, SlateState::Standard2);
// wallet2 already has this slate, so accepted versions fail on the duplicate check
for bhv in 1..=GRIN_BLOCK_HEADER_VERSION + 1 {
let mut s = slate_i.clone();
s.version_info.block_header_version = bhv;
let res = wallet::controller::foreign_single_use(
wallet2.clone(),
PathBuf::from(test_dir),
mask2_i.clone(),
|api| api.receive_tx(&s, None, None).map(|_| ()),
);
if bhv <= GRIN_BLOCK_HEADER_VERSION {
assert!(matches!(
res,
Err(libwallet::Error::TransactionAlreadyReceived(_))
));
} else {
assert!(matches!(res, Err(libwallet::Error::Compatibility(_))));
}
}
sender_api.tx_lock_outputs(m, &slate)?;
slate = sender_api.finalize_tx(m, &slate)?;
assert_eq!(slate.state, SlateState::Standard3);