Skip to content

Commit

Permalink
Extend clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Nov 30, 2023
1 parent 0d62095 commit dcffe29
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- name: clippy
run: cargo clippy --workspace -- -D warnings
- name: clippy no-std
run: cargo clippy --workspace --no-default-features -- -D warnings
run: cargo clippy --workspace --no-default-features --all-targets -- -D warnings
- name: clippy with features
run: cargo clippy --workspace --features=with-codec,with-serde -- -D warnings
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
build:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion interpreter/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
self.0.map(|f| {
let fr = wrapper(f, current_opcode);
if current_opcode != Opcode(255) {
current_opcode.0 += current_opcode.0;
current_opcode.0 += 1;
}
fr
}),
Expand Down
3 changes: 3 additions & 0 deletions interpreter/src/memory.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use alloc::vec;

use crate::{ExitException, ExitFatal};
use alloc::vec::Vec;
use core::ops::{BitAnd, Not, Range};
Expand Down
25 changes: 13 additions & 12 deletions interpreter/tests/usability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const RET1: &str = "000000000000000000000000000000000000000000000000000000000000

#[test]
fn etable_wrap() {
let code = hex::decode(&CODE1).unwrap();
let data = hex::decode(&DATA1).unwrap();
let code = hex::decode(CODE1).unwrap();
let data = hex::decode(DATA1).unwrap();

let wrapped_etable = Etable::<_, _, Opcode>::core().wrap(|f, opcode_t| {
move |machine, handle, opcode, position| {
Expand All @@ -24,14 +24,15 @@ fn etable_wrap() {

let mut vm = Machine::new(Rc::new(code), Rc::new(data), 1024, 10000, ());
let result = vm.run(&mut (), &wrapped_etable);
assert_eq!(result, Capture::Exit(Ok(ExitSucceed::Returned.into())));
assert_eq!(vm.retval, hex::decode(&RET1).unwrap());
assert_eq!(result, Capture::Exit(Ok(ExitSucceed::Returned)));
assert_eq!(vm.retval, hex::decode(RET1).unwrap());
}

#[test]
#[allow(clippy::type_complexity)]
fn etable_wrap2() {
let code = hex::decode(&CODE1).unwrap();
let data = hex::decode(&DATA1).unwrap();
let code = hex::decode(CODE1).unwrap();
let data = hex::decode(DATA1).unwrap();

let wrapped_etable = Etable::core().wrap(
|f, opcode_t| -> Box<dyn Fn(&mut Machine<()>, &mut (), Opcode, usize) -> Control<Opcode>> {
Expand Down Expand Up @@ -87,7 +88,7 @@ impl RuntimeEnvironment for UnimplementedHandler {
}
}

impl<'a> RuntimeBaseBackend for UnimplementedHandler {
impl RuntimeBaseBackend for UnimplementedHandler {
fn balance(&self, _address: H160) -> U256 {
unimplemented!()
}
Expand All @@ -113,7 +114,7 @@ impl<'a> RuntimeBaseBackend for UnimplementedHandler {
}
}

impl<'a> RuntimeBackend for UnimplementedHandler {
impl RuntimeBackend for UnimplementedHandler {
fn original_storage(&self, _address: H160, _index: H256) -> H256 {
unimplemented!()
}
Expand Down Expand Up @@ -167,8 +168,8 @@ static RUNTIME_ETABLE: Etable<RuntimeState, UnimplementedHandler, Opcode> = Etab

#[test]
fn etable_runtime() {
let code = hex::decode(&CODE1).unwrap();
let data = hex::decode(&DATA1).unwrap();
let code = hex::decode(CODE1).unwrap();
let data = hex::decode(DATA1).unwrap();
let mut handler = UnimplementedHandler;

let mut vm = Machine::new(
Expand All @@ -193,6 +194,6 @@ fn etable_runtime() {
);

let res = vm.run(&mut handler, &RUNTIME_ETABLE).exit().unwrap();
assert_eq!(res, Ok(ExitSucceed::Returned.into()));
assert_eq!(vm.retval, hex::decode(&RET1).unwrap());
assert_eq!(res, Ok(ExitSucceed::Returned));
assert_eq!(vm.retval, hex::decode(RET1).unwrap());
}

0 comments on commit dcffe29

Please sign in to comment.