mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
Have Monero test runner evaluate an Eventuality for all signed TXs
This commit is contained in:
@@ -4,7 +4,6 @@ use monero_serai::transaction::Transaction;
|
|||||||
use monero_wallet::{
|
use monero_wallet::{
|
||||||
rpc::Rpc,
|
rpc::Rpc,
|
||||||
address::{AddressType, MoneroAddress},
|
address::{AddressType, MoneroAddress},
|
||||||
send::Eventuality,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod runner;
|
mod runner;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use monero_wallet::{
|
|||||||
block::Block,
|
block::Block,
|
||||||
rpc::{Rpc, FeeRate},
|
rpc::{Rpc, FeeRate},
|
||||||
address::{Network, AddressType, MoneroAddress},
|
address::{Network, AddressType, MoneroAddress},
|
||||||
ViewPair, GuaranteedViewPair, WalletOutput, Scanner,
|
DEFAULT_LOCK_WINDOW, ViewPair, GuaranteedViewPair, WalletOutput, Scanner,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod builder;
|
mod builder;
|
||||||
@@ -88,15 +88,8 @@ pub async fn mine_until_unlocked(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mine until tx's outputs are unlocked
|
// Mine until tx's outputs are unlocked
|
||||||
let o_indexes: Vec<u64> = rpc.get_o_indexes(tx_hash).await.unwrap();
|
for _ in 0 .. (DEFAULT_LOCK_WINDOW - 1) {
|
||||||
while rpc
|
rpc.generate_blocks(addr, 1).await.unwrap();
|
||||||
.get_unlocked_outputs(&o_indexes, height, false)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.into_iter()
|
|
||||||
.any(|output| output.is_none())
|
|
||||||
{
|
|
||||||
height = rpc.generate_blocks(addr, 1).await.unwrap().1 + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
block.unwrap()
|
block.unwrap()
|
||||||
@@ -210,7 +203,7 @@ macro_rules! test {
|
|||||||
ViewPair,
|
ViewPair,
|
||||||
DecoySelection,
|
DecoySelection,
|
||||||
Scanner,
|
Scanner,
|
||||||
send::{Change, SignableTransaction},
|
send::{Change, SignableTransaction, Eventuality},
|
||||||
};
|
};
|
||||||
|
|
||||||
use runner::{
|
use runner::{
|
||||||
@@ -274,12 +267,14 @@ macro_rules! test {
|
|||||||
let spend = spend.clone();
|
let spend = spend.clone();
|
||||||
#[cfg(feature = "multisig")]
|
#[cfg(feature = "multisig")]
|
||||||
let keys = keys.clone();
|
let keys = keys.clone();
|
||||||
async move {
|
|
||||||
if !multisig {
|
let eventuality = Eventuality::from(tx.clone());
|
||||||
|
|
||||||
|
let tx = if !multisig {
|
||||||
tx.sign(&mut OsRng, &spend).unwrap()
|
tx.sign(&mut OsRng, &spend).unwrap()
|
||||||
} else {
|
} else {
|
||||||
#[cfg(not(feature = "multisig"))]
|
#[cfg(not(feature = "multisig"))]
|
||||||
panic!("Multisig branch called without the multisig feature");
|
panic!("multisig branch called without the multisig feature");
|
||||||
#[cfg(feature = "multisig")]
|
#[cfg(feature = "multisig")]
|
||||||
{
|
{
|
||||||
let mut machines = HashMap::new();
|
let mut machines = HashMap::new();
|
||||||
@@ -289,8 +284,12 @@ macro_rules! test {
|
|||||||
|
|
||||||
frost::tests::sign_without_caching(&mut OsRng, machines, &[])
|
frost::tests::sign_without_caching(&mut OsRng, machines, &[])
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
assert_eq!(&eventuality.extra(), &tx.prefix().extra);
|
||||||
|
assert!(eventuality.matches(&tx));
|
||||||
|
|
||||||
|
tx
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Generate a distinct wallet for each transaction to prevent overlap
|
// TODO: Generate a distinct wallet for each transaction to prevent overlap
|
||||||
@@ -312,7 +311,7 @@ macro_rules! test {
|
|||||||
|
|
||||||
let (tx, state) = ($first_tx)(rpc.clone(), builder, next_addr).await;
|
let (tx, state) = ($first_tx)(rpc.clone(), builder, next_addr).await;
|
||||||
let fee_rate = tx.fee_rate().clone();
|
let fee_rate = tx.fee_rate().clone();
|
||||||
let signed = sign(tx).await;
|
let signed = sign(tx);
|
||||||
rpc.publish_transaction(&signed).await.unwrap();
|
rpc.publish_transaction(&signed).await.unwrap();
|
||||||
let block =
|
let block =
|
||||||
mine_until_unlocked(&rpc, &random_address().2, signed.hash()).await;
|
mine_until_unlocked(&rpc, &random_address().2, signed.hash()).await;
|
||||||
@@ -333,7 +332,7 @@ macro_rules! test {
|
|||||||
*carried_state.downcast().unwrap()
|
*carried_state.downcast().unwrap()
|
||||||
).await;
|
).await;
|
||||||
let fee_rate = tx.fee_rate().clone();
|
let fee_rate = tx.fee_rate().clone();
|
||||||
let signed = sign(tx).await;
|
let signed = sign(tx);
|
||||||
rpc.publish_transaction(&signed).await.unwrap();
|
rpc.publish_transaction(&signed).await.unwrap();
|
||||||
let block =
|
let block =
|
||||||
mine_until_unlocked(&rpc, &random_address().2, signed.hash()).await;
|
mine_until_unlocked(&rpc, &random_address().2, signed.hash()).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user