mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Rename the coins folder to networks (#583)
* Rename the coins folder to networks Ethereum isn't a coin. It's a network. Resolves #357. * More renames of coins -> networks in orchestration * Correct paths in tests/ * cargo fmt
This commit is contained in:
80
networks/monero/wallet/tests/eventuality.rs
Normal file
80
networks/monero/wallet/tests/eventuality.rs
Normal file
@@ -0,0 +1,80 @@
|
||||
use curve25519_dalek::constants::ED25519_BASEPOINT_POINT;
|
||||
|
||||
use monero_serai::transaction::Transaction;
|
||||
use monero_wallet::{
|
||||
rpc::Rpc,
|
||||
address::{AddressType, MoneroAddress},
|
||||
};
|
||||
|
||||
mod runner;
|
||||
|
||||
test!(
|
||||
eventuality,
|
||||
(
|
||||
|_, mut builder: Builder, _| async move {
|
||||
// Add a standard address, a payment ID address, a subaddress, and a guaranteed address
|
||||
// Each have their own slight implications to eventualities
|
||||
builder.add_payment(
|
||||
MoneroAddress::new(
|
||||
Network::Mainnet,
|
||||
AddressType::Legacy,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
),
|
||||
1,
|
||||
);
|
||||
builder.add_payment(
|
||||
MoneroAddress::new(
|
||||
Network::Mainnet,
|
||||
AddressType::LegacyIntegrated([0xaa; 8]),
|
||||
ED25519_BASEPOINT_POINT,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
),
|
||||
2,
|
||||
);
|
||||
builder.add_payment(
|
||||
MoneroAddress::new(
|
||||
Network::Mainnet,
|
||||
AddressType::Subaddress,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
),
|
||||
3,
|
||||
);
|
||||
builder.add_payment(
|
||||
MoneroAddress::new(
|
||||
Network::Mainnet,
|
||||
AddressType::Featured { subaddress: false, payment_id: None, guaranteed: true },
|
||||
ED25519_BASEPOINT_POINT,
|
||||
ED25519_BASEPOINT_POINT,
|
||||
),
|
||||
4,
|
||||
);
|
||||
let tx = builder.build().unwrap();
|
||||
let eventuality = Eventuality::from(tx.clone());
|
||||
assert_eq!(
|
||||
eventuality,
|
||||
Eventuality::read::<&[u8]>(&mut eventuality.serialize().as_ref()).unwrap()
|
||||
);
|
||||
(tx, eventuality)
|
||||
},
|
||||
|_, _, mut tx: Transaction, _, eventuality: Eventuality| async move {
|
||||
// 4 explicitly outputs added and one change output
|
||||
assert_eq!(tx.prefix().outputs.len(), 5);
|
||||
|
||||
// The eventuality's available extra should be the actual TX's
|
||||
assert_eq!(tx.prefix().extra, eventuality.extra());
|
||||
|
||||
// The TX should match
|
||||
assert!(eventuality.matches(&tx.clone().into()));
|
||||
|
||||
// Mutate the TX
|
||||
let Transaction::V2 { proofs: Some(ref mut proofs), .. } = tx else {
|
||||
panic!("TX wasn't RingCT")
|
||||
};
|
||||
proofs.base.commitments[0] += ED25519_BASEPOINT_POINT;
|
||||
// Verify it no longer matches
|
||||
assert!(!eventuality.matches(&tx.clone().into()));
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user