Run latest nightly clippy

Also runs clippy on the tests and updates the CI accordingly
This commit is contained in:
Luke Parker
2023-01-01 04:18:23 -05:00
parent bff5f33616
commit 5599a052ad
23 changed files with 70 additions and 73 deletions

View File

@@ -6,8 +6,7 @@ test!(
add_single_data_less_than_255,
(
|_, mut builder: Builder, addr| async move {
// make a data that is less than 255 bytes
let arbitrary_data = Vec::from("this is an arbitrary data less than 255 bytes");
let arbitrary_data = vec![b'\0', 254];
// make sure we can add to tx
let result = builder.add_data(arbitrary_data.clone());
@@ -16,11 +15,11 @@ test!(
builder.add_payment(addr, 5);
(builder.build().unwrap(), (arbitrary_data,))
},
|rpc: Rpc, signed: Transaction, mut scanner: Scanner, state: (Vec<u8>,)| async move {
|rpc: Rpc, signed: Transaction, mut scanner: Scanner, data: (Vec<u8>,)| async move {
let tx = rpc.get_transaction(signed.hash()).await.unwrap();
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
assert_eq!(output.commitment().amount, 5);
assert_eq!(output.arbitrary_data()[0], state.0);
assert_eq!(output.arbitrary_data()[0], data.0);
},
),
);
@@ -29,26 +28,22 @@ test!(
add_multiple_data_less_than_255,
(
|_, mut builder: Builder, addr| async move {
// make a data that is less than 255 bytes
let arbitrary_data = Vec::from("this is an arbitrary data less than 255 bytes");
let data = vec![b'\0', 254];
// add tx multiple times
// Add tx multiple times
for _ in 0 .. 5 {
let result = builder.add_data(arbitrary_data.clone());
let result = builder.add_data(data.clone());
assert!(result.is_ok());
}
builder.add_payment(addr, 5);
(builder.build().unwrap(), (arbitrary_data,))
(builder.build().unwrap(), data)
},
|rpc: Rpc, signed: Transaction, mut scanner: Scanner, state: (Vec<u8>,)| async move {
|rpc: Rpc, signed: Transaction, mut scanner: Scanner, data: Vec<u8>| async move {
let tx = rpc.get_transaction(signed.hash()).await.unwrap();
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
assert_eq!(output.commitment().amount, 5);
let data = output.arbitrary_data();
for i in 0 .. 5 {
assert_eq!(data[i], state.0);
}
assert_eq!(output.arbitrary_data(), vec![data; 5]);
},
),
);
@@ -57,23 +52,24 @@ test!(
add_single_data_more_than_255,
(
|_, mut builder: Builder, addr| async move {
// make a data that is bigger than 255 bytes
let mut arbitrary_data = vec![];
for _ in 0 .. 256 {
arbitrary_data.push(b'a');
}
// 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 tx
let mut result = builder.add_payment(addr, 5).add_data(arbitrary_data.clone());
assert_eq!(result, Err(TransactionError::TooMuchData));
// 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 re-try
arbitrary_data.swap_remove(0);
result = builder.add_data(arbitrary_data);
// Reduce data size and retry. The data will now be 255 bytes long, exactly
data.pop();
assert!(builder.add_data(data.clone()).is_ok());
assert!(result.is_ok());
(builder.build().unwrap(), ())
builder.add_payment(addr, 5);
(builder.build().unwrap(), data)
},
|rpc: Rpc, signed: Transaction, mut scanner: Scanner, data: Vec<u8>| async move {
let tx = rpc.get_transaction(signed.hash()).await.unwrap();
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
assert_eq!(output.commitment().amount, 5);
assert_eq!(output.arbitrary_data(), vec![data]);
},
|_, _, _, _| async move {},
),
);

View File

@@ -1,5 +1,4 @@
use core::ops::Deref;
use std::sync::Mutex;
use lazy_static::lazy_static;
@@ -8,6 +7,8 @@ use rand_core::OsRng;
use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar};
use tokio::sync::Mutex;
use monero_serai::{
Protocol, random_scalar,
wallet::{
@@ -87,7 +88,7 @@ macro_rules! async_sequential {
$(
#[tokio::test]
async fn $name() {
let guard = runner::SEQUENTIAL.lock().unwrap();
let guard = runner::SEQUENTIAL.lock().await;
let local = tokio::task::LocalSet::new();
local.run_until(async move {
if let Err(err) = tokio::task::spawn_local(async move { $body }).await {
@@ -146,6 +147,7 @@ macro_rules! test {
type Builder = SignableTransactionBuilder;
// Run each function as both a single signer and as a multisig
#[allow(clippy::redundant_closure_call)]
for multisig in [false, true] {
// Only run the multisig variant if multisig is enabled
if multisig {
@@ -225,7 +227,7 @@ macro_rules! test {
);
}
frost::tests::sign_without_caching(&mut OsRng, machines, &vec![])
frost::tests::sign_without_caching(&mut OsRng, machines, &[])
}
}
}