mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 09:27:36 +00:00
a646ec5aaa
commit e0a9e8825d6c22c797fb84e26ed6ef10136ca9c2 Author: Luke Parker <lukeparker5132@gmail.com> Date: Fri Jan 6 04:24:08 2023 -0500 Remove Scanner::address It either needed to return an Option, panic on misconfiguration, or return a distinct Scanner type based on burning bug immunity to offer this API properly. Panicking wouldn't be proper, and the Option<Address> would've been... awkward. The new register_subaddress function, maintaining the needed functionality, also provides further clarity on the intended side effect of the previously present Scanner::address function. commit 7359360ab2fc8c9255c6f58250c214252ce217a4 Author: Luke Parker <lukeparker5132@gmail.com> Date: Fri Jan 6 01:35:02 2023 -0500 fmt/clippy from last commit commit 80d912fc19cd268f3b019a9d9961a48b2c45e828 Author: Luke Parker <lukeparker5132@gmail.com> Date: Thu Jan 5 19:36:49 2023 -0500 Add Substrate "assets" pallet While over-engineered for our purposes, it's still usable. Also cleans the runtime a bit. commit 2ed2944b6598d75bdc3c995aaf39b717846207de Author: Luke Parker <lukeparker5132@gmail.com> Date: Wed Jan 4 23:09:58 2023 -0500 Remove the timestamp pallet It was needed for contracts, which has since been removed. We now no longer need it. commit 7fc1fc2dccecebe1d94cb7b4c00f2b5cb271c87b Author: Luke Parker <lukeparker5132@gmail.com> Date: Wed Jan 4 22:52:41 2023 -0500 Initial validator sets pallet (#187) * Initial work on a Validator Sets pallet * Update Validator Set docs per current discussions * Update validator-sets primitives and storage handling * Add validator set pallets to deny.toml * Remove Curve from primitives Since we aren't reusing keys across coins, there's no reason for it to be on-chain (as previously planned). * Update documentation on Validator Sets * Use Twox64Concat instead of Identity Ensures an even distribution of keys. While xxhash is breakable, these keys aren't manipulatable by users. * Add math ops on Amount and define a coin as 1e8 * Add validator-sets to the runtime and remove contracts Also removes the randomness pallet which was only required by the contracts runtime. Does not remove the contracts folder yet so they can still be referred to while validator-sets is under development. Does remove them from Cargo.toml. * Add vote function to validator-sets * Remove contracts folder * Create an event for the Validator Sets pallet * Remove old contracts crates from deny.toml * Remove line from staking branch * Remove staking from runtime * Correct VS Config in runtime * cargo update * Resolve a few PR comments on terminology * Create a serai-primitives crate Move types such as Amount/Coin out of validator-sets. Will be expanded in the future. * Fixes for last commit * Don't reserve set 0 * Further fixes * Add files meant for last commit * Remove Staking transfer commit 3309295911d22177bd68972d138aea2f8658eb5f Author: Luke Parker <lukeparker5132@gmail.com> Date: Wed Jan 4 06:17:00 2023 -0500 Reorder coins in README by market cap commit db5d19cad33ccf067d876b7f5b7cca47c228e2fc Author: Luke Parker <lukeparker5132@gmail.com> Date: Wed Jan 4 06:07:58 2023 -0500 Update README commit 606484d744b1c6cc408382994c77f1def25d3e7d Author: Luke Parker <lukeparker5132@gmail.com> Date: Wed Jan 4 03:17:36 2023 -0500 cargo update commit3a319b229f
Author: akildemir <aeg_asd@hotmail.com> Date: Wed Jan 4 16:26:25 2023 +0300 update address public API design commitd9fa88fa76
Author: akildemir <aeg_asd@hotmail.com> Date: Mon Jan 2 13:35:06 2023 +0300 fix clippy error commitcc722e897b
Merge:cafa9b3
eeca440
Author: akildemir <aeg_asd@hotmail.com> Date: Mon Jan 2 11:39:04 2023 +0300 Merge https://github.com/serai-dex/serai into develop commitcafa9b361e
Author: akildemir <aeg_asd@hotmail.com> Date: Mon Jan 2 11:38:26 2023 +0300 fix build errors commitce5b5f2b37
Merge:f502d67
49c4acf
Author: akildemir <aeg_asd@hotmail.com> Date: Sun Jan 1 15:16:25 2023 +0300 Merge https://github.com/serai-dex/serai into develop commitf502d67282
Author: akildemir <aeg_asd@hotmail.com> Date: Thu Dec 22 13:13:09 2022 +0300 fix pr issues commit26ffb226d4
Author: akildemir <aeg_asd@hotmail.com> Date: Thu Dec 22 13:11:43 2022 +0300 remove extraneous rpc call commit0e829f8531
Author: akildemir <aeg_asd@hotmail.com> Date: Thu Dec 15 13:56:53 2022 +0300 add scan tests commit5123c7f121
Author: akildemir <aeg_asd@hotmail.com> Date: Thu Dec 15 13:56:13 2022 +0300 add new address functions & comments
72 lines
2.2 KiB
Rust
72 lines
2.2 KiB
Rust
use monero_serai::{wallet::TransactionError, transaction::Transaction};
|
|
|
|
mod runner;
|
|
|
|
test!(
|
|
add_single_data_less_than_255,
|
|
(
|
|
|_, mut builder: Builder, addr| async move {
|
|
let arbitrary_data = vec![b'\0', 254];
|
|
|
|
// make sure we can add to tx
|
|
let result = builder.add_data(arbitrary_data.clone());
|
|
assert!(result.is_ok());
|
|
|
|
builder.add_payment(addr, 5);
|
|
(builder.build().unwrap(), (arbitrary_data,))
|
|
},
|
|
|_, tx: Transaction, mut scanner: Scanner, data: (Vec<u8>,)| async move {
|
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
|
assert_eq!(output.commitment().amount, 5);
|
|
assert_eq!(output.arbitrary_data()[0], data.0);
|
|
},
|
|
),
|
|
);
|
|
|
|
test!(
|
|
add_multiple_data_less_than_255,
|
|
(
|
|
|_, mut builder: Builder, addr| async move {
|
|
let data = vec![b'\0', 254];
|
|
|
|
// Add tx multiple times
|
|
for _ in 0 .. 5 {
|
|
let result = builder.add_data(data.clone());
|
|
assert!(result.is_ok());
|
|
}
|
|
|
|
builder.add_payment(addr, 5);
|
|
(builder.build().unwrap(), data)
|
|
},
|
|
|_, tx: Transaction, mut scanner: Scanner, data: Vec<u8>| async move {
|
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
|
assert_eq!(output.commitment().amount, 5);
|
|
assert_eq!(output.arbitrary_data(), vec![data; 5]);
|
|
},
|
|
),
|
|
);
|
|
|
|
test!(
|
|
add_single_data_more_than_255,
|
|
(
|
|
|_, mut builder: Builder, addr| async move {
|
|
// Make a data that is bigger than 255 bytes
|
|
let mut data = vec![b'a'; 256];
|
|
|
|
// Make sure we get an error if we try to add it to the TX
|
|
assert_eq!(builder.add_data(data.clone()), Err(TransactionError::TooMuchData));
|
|
|
|
// Reduce data size and retry. The data will now be 255 bytes long, exactly
|
|
data.pop();
|
|
assert!(builder.add_data(data.clone()).is_ok());
|
|
|
|
builder.add_payment(addr, 5);
|
|
(builder.build().unwrap(), data)
|
|
},
|
|
|_, tx: Transaction, mut scanner: Scanner, data: Vec<u8>| async move {
|
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
|
assert_eq!(output.commitment().amount, 5);
|
|
assert_eq!(output.arbitrary_data(), vec![data]);
|
|
},
|
|
),
|
|
);
|