Skip to content

Commit 827dabd

Browse files
committed
test: span nit
1 parent 0dfe1ba commit 827dabd

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/payload/ext/span.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::{
2-
alloy::primitives::TxHash, prelude::*, reth::primitives::Recovered,
2+
alloy::primitives::TxHash,
3+
prelude::*,
4+
reth::primitives::Recovered,
35
};
46

57
/// Quality of Life extensions for the `Span` type.
@@ -107,13 +109,12 @@ impl<P: Platform> SpanExt<P> for Span<P> {
107109

108110
#[cfg(test)]
109111
mod span_ext_tests {
110-
use crate::{
111-
payload::{Span, SpanExt},
112-
prelude::{BlockContext, Checkpoint, Ethereum},
113-
test_utils::BlockContextMocked,
114-
};
115-
116112
use {
113+
crate::{
114+
payload::{Span, SpanExt},
115+
prelude::{BlockContext, Checkpoint, Ethereum},
116+
test_utils::BlockContextMocked,
117+
},
117118
alloy::{
118119
consensus::{EthereumTxEnvelope, TxEip4844},
119120
network::{TransactionBuilder, TxSignerSync},
@@ -154,7 +155,7 @@ mod span_ext_tests {
154155

155156
#[test]
156157
fn gas_and_blob_gas_used_sum_correctly() {
157-
let (block, _) = BlockContext::<Ethereum>::mocked();
158+
let block = BlockContext::<Ethereum>::mocked();
158159

159160
let root = block.start();
160161
let c1: Checkpoint<Ethereum> = root.barrier();
@@ -168,7 +169,7 @@ mod span_ext_tests {
168169

169170
#[test]
170171
fn contains_transaction_hash_works() {
171-
let (block, _) = BlockContext::<Ethereum>::mocked();
172+
let block = BlockContext::<Ethereum>::mocked();
172173

173174
let root = block.start();
174175
let c1: Checkpoint<Ethereum> = root.barrier();
@@ -184,7 +185,7 @@ mod span_ext_tests {
184185

185186
#[test]
186187
fn split_at_produces_valid_halves() {
187-
let (block, _) = BlockContext::<Ethereum>::mocked();
188+
let block = BlockContext::<Ethereum>::mocked();
188189

189190
let root = block.start();
190191
let c1: Checkpoint<Ethereum> = root.barrier();
@@ -203,7 +204,7 @@ mod span_ext_tests {
203204

204205
#[test]
205206
fn take_and_skip_are_consistent_with_split_at() {
206-
let (block, _) = BlockContext::<Ethereum>::mocked();
207+
let block = BlockContext::<Ethereum>::mocked();
207208

208209
let root = block.start();
209210
let c1: Checkpoint<Ethereum> = root.barrier();

src/payload/span.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,24 @@ mod tests {
192192

193193
#[test]
194194
fn span_between_linear_history() {
195-
let (block, _) = BlockContext::<Ethereum>::mocked();
195+
let block = BlockContext::<Ethereum>::mocked();
196196

197197
let checkpoint = block.start();
198198
let c1: Checkpoint<Ethereum> = checkpoint.barrier();
199199
let c2: Checkpoint<Ethereum> = c1.barrier();
200200

201201
// Direct ancestor-descendant pair
202-
let span = Span::<Ethereum>::between(&checkpoint, &c2).unwrap();
202+
let mut span = Span::<Ethereum>::between(&checkpoint, &c2).unwrap();
203203
assert_eq!(span.len(), 3);
204-
assert_eq!(span.first().unwrap(), &checkpoint);
204+
assert_eq!(span.pop_first().unwrap(), checkpoint);
205205
assert_eq!(span.len(), 2);
206-
assert_eq!(span.last().unwrap(), &c2);
206+
assert_eq!(span.pop_last().unwrap(), c2);
207+
assert_eq!(span.len(), 1);
207208
}
208209

209210
#[test]
210211
fn test_empty_span() {
211-
let (block, _) = BlockContext::<Ethereum>::mocked();
212+
let block = BlockContext::<Ethereum>::mocked();
212213

213214
let checkpoint = block.start();
214215

@@ -219,7 +220,7 @@ mod tests {
219220

220221
#[test]
221222
fn test_between_nonlinear_history() {
222-
let (block, _) = BlockContext::<Ethereum>::mocked();
223+
let block = BlockContext::<Ethereum>::mocked();
223224

224225
let checkpoint1 = block.start();
225226
let checkpoint2 = block.start();
@@ -230,7 +231,7 @@ mod tests {
230231

231232
#[test]
232233
fn into_iter_and_iterators_work() {
233-
let (block, _) = BlockContext::<Ethereum>::mocked();
234+
let block = BlockContext::<Ethereum>::mocked();
234235

235236
let root = block.start();
236237
let c1: Checkpoint<Ethereum> = root.barrier();
@@ -245,8 +246,7 @@ mod tests {
245246
assert_eq!(ids_from_iter[2], c2);
246247

247248
// into_iter()
248-
let ids_from_into_iter: Vec<_> =
249-
span.clone().into_iter().map(|c| c).collect();
249+
let ids_from_into_iter: Vec<_> = span.clone().into_iter().collect();
250250
assert_eq!(ids_from_iter, ids_from_into_iter);
251251
}
252252
}

0 commit comments

Comments
 (0)