2022-07-15 05:26:07 +00:00
|
|
|
use monero_serai::{
|
2022-12-05 22:25:09 +00:00
|
|
|
wallet::{ReceivedOutput, SpendableOutput},
|
2022-12-07 15:08:04 +00:00
|
|
|
transaction::Transaction,
|
2022-07-15 05:26:07 +00:00
|
|
|
};
|
2022-04-29 00:41:43 +00:00
|
|
|
|
2022-12-05 22:25:09 +00:00
|
|
|
mod runner;
|
|
|
|
|
|
|
|
test!(
|
|
|
|
spend_miner_output,
|
|
|
|
(
|
|
|
|
|_, mut builder: Builder, addr| async move {
|
|
|
|
builder.add_payment(addr, 5);
|
|
|
|
(builder.build().unwrap(), ())
|
|
|
|
},
|
2022-12-07 15:08:04 +00:00
|
|
|
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
2022-12-05 22:25:09 +00:00
|
|
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
|
|
|
assert_eq!(output.commitment().amount, 5);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
spend_multiple_outputs,
|
|
|
|
(
|
|
|
|
|_, mut builder: Builder, addr| async move {
|
|
|
|
builder.add_payment(addr, 1000000000000);
|
|
|
|
builder.add_payment(addr, 2000000000000);
|
|
|
|
(builder.build().unwrap(), ())
|
|
|
|
},
|
2022-12-07 15:08:04 +00:00
|
|
|
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
2022-12-05 22:25:09 +00:00
|
|
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
|
|
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
|
|
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
|
|
|
assert_eq!(outputs[1].commitment().amount, 2000000000000);
|
|
|
|
outputs
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
|rpc, mut builder: Builder, addr, mut outputs: Vec<ReceivedOutput>| async move {
|
|
|
|
for output in outputs.drain(..) {
|
|
|
|
builder.add_input(SpendableOutput::from(&rpc, output).await.unwrap());
|
2022-05-18 04:53:13 +00:00
|
|
|
}
|
2022-12-05 22:25:09 +00:00
|
|
|
builder.add_payment(addr, 6);
|
|
|
|
(builder.build().unwrap(), ())
|
|
|
|
},
|
2022-12-07 15:08:04 +00:00
|
|
|
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
2022-12-05 22:25:09 +00:00
|
|
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
|
|
|
assert_eq!(output.commitment().amount, 6);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|