Skip to content

Commit

Permalink
chore: update github actions and fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev committed Apr 13, 2024
1 parent 2558448 commit 4222de1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 38 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
with:
command: check

test:
name: Test Suite
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -27,12 +27,14 @@ jobs:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: test
command: fmt
args: --all -- --check

fmt:
name: Rustfmt
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -41,14 +43,14 @@ jobs:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
components: clippy
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
command: clippy
args: --all --all-targets --all-features --no-deps -- -D warnings

clippy:
name: Clippy
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -57,8 +59,21 @@ jobs:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
command: build
args: --workspace

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
6 changes: 3 additions & 3 deletions db/src/memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod tests {
let mut memory_db: MemoryDb<[u8; 4], [u16; 8]> = MemoryDb::new();
let key = [1u8, 2, 3, 4];
let value = [1u16, 1, 2, 3, 5, 8, 13, 21];
assert_ok!(memory_db.write(key, value.clone()));
assert_ok!(memory_db.write(key, value));
assert_ok_eq!(memory_db.read(&key), Some(value));
}

Expand All @@ -55,10 +55,10 @@ mod tests {
let value1 = [0u16, 1, 1, 2, 3, 5, 8, 13];
let value2 = [1u16, 1, 2, 3, 5, 8, 13, 21];

assert_ok!(memory_db.write(key, value1.clone()));
assert_ok!(memory_db.write(key, value1));
assert_ok_eq!(memory_db.read(&key), Some(value1));

assert_ok!(memory_db.write(key, value2.clone()));
assert_ok!(memory_db.write(key, value2));
assert_ok_eq!(memory_db.read(&key), Some(value2));
}
}
44 changes: 22 additions & 22 deletions merkle_old/src/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ mod test {
tree.set_raw(b"first", b"value".to_vec());
tree.set_raw(b"second", b"value".to_vec());

let first = tree.get_raw(&&b"first"[..]);
let first = tree.get_raw(&b"first"[..]);
assert!(first.is_some());
let second = tree.get_raw(&&b"second"[..]);
let second = tree.get_raw(&b"second"[..]);
assert!(second.is_some());
}

Expand All @@ -142,7 +142,7 @@ mod test {
let mut tree = MerklePatriciaTrie::default();

tree.set_raw(&[0x0], b"value".to_vec());
let first = tree.get_raw(&&[0x0][..]);
let first = tree.get_raw(&[0x0][..]);
assert!(first.is_some());
}

Expand All @@ -166,7 +166,7 @@ mod test {
let values = paths.clone();

for (path, value) in paths.iter().zip(values.iter()) {
tree.set_raw(&path, value.clone());
tree.set_raw(path, value.clone());
}

for (path, value) in paths.iter().zip(values.iter()) {
Expand All @@ -184,11 +184,11 @@ mod test {
tree.set_raw(&[16], vec![0]);
tree.set_raw(&[16, 0], vec![0]);

let item = tree.get_raw(&vec![16]);
let item = tree.get_raw(&[16]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[0]);

let item = tree.get_raw(&vec![16, 0]);
let item = tree.get_raw(&[16, 0]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[0]);
}
Expand All @@ -200,11 +200,11 @@ mod test {
tree.set_raw(&[0, 0], vec![0, 0]);
tree.set_raw(&[1, 0], vec![1, 0]);

let item = tree.get_raw(&vec![1, 0]);
let item = tree.get_raw(&[1, 0]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[1, 0]);

let item = tree.get_raw(&vec![0, 0]);
let item = tree.get_raw(&[0, 0]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[0, 0]);
}
Expand All @@ -225,23 +225,23 @@ mod test {
);
tree.set_raw(&[138, 101, 157], vec![138, 101, 157]);

let item = tree.get_raw(&vec![26, 192, 44, 251]);
let item = tree.get_raw(&[26, 192, 44, 251]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[26, 192, 44, 251]);

let item = tree.get_raw(&vec![195, 132, 220, 124, 112, 201, 70, 128, 235]);
let item = tree.get_raw(&[195, 132, 220, 124, 112, 201, 70, 128, 235]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[195, 132, 220, 124, 112, 201, 70, 128, 235]);

let item = tree.get_raw(&vec![126, 138, 25, 245, 146]);
let item = tree.get_raw(&[126, 138, 25, 245, 146]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[126, 138, 25, 245, 146]);

let item = tree.get_raw(&vec![129, 176, 66, 2, 150, 151, 180, 60, 124]);
let item = tree.get_raw(&[129, 176, 66, 2, 150, 151, 180, 60, 124]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[129, 176, 66, 2, 150, 151, 180, 60, 124]);

let item = tree.get_raw(&vec![138, 101, 157]);
let item = tree.get_raw(&[138, 101, 157]);
assert!(item.is_some());
assert_eq!(item.unwrap(), &[138, 101, 157]);
}
Expand Down Expand Up @@ -288,9 +288,9 @@ mod test {
tree.set_raw(&[0xC8], vec![0xC8]);
tree.set_raw(&[0xC8, 0x00], vec![0xC8, 0x00]);

assert_eq!(tree.get_raw(&vec![0x00]), Some(vec![0x00]));
assert_eq!(tree.get_raw(&vec![0xC8]), Some(vec![0xC8]));
assert_eq!(tree.get_raw(&vec![0xC8, 0x00]), Some(vec![0xC8, 0x00]));
assert_eq!(tree.get_raw(&[0x00]), Some(vec![0x00]));
assert_eq!(tree.get_raw(&[0xC8]), Some(vec![0xC8]));
assert_eq!(tree.get_raw(&[0xC8, 0x00]), Some(vec![0xC8, 0x00]));
}

#[test]
Expand All @@ -304,12 +304,12 @@ mod test {
tree.set_raw(&[0x19, 0x00], vec![0x19, 0x00]);
tree.set_raw(&[0x1A], vec![0x1A]);

assert_eq!(tree.get_raw(&vec![0x00]), Some(vec![0x00]));
assert_eq!(tree.get_raw(&vec![0x01]), Some(vec![0x01]));
assert_eq!(tree.get_raw(&vec![0x10]), Some(vec![0x10]));
assert_eq!(tree.get_raw(&vec![0x19]), Some(vec![0x19]));
assert_eq!(tree.get_raw(&vec![0x19, 0x00]), Some(vec![0x19, 0x00]));
assert_eq!(tree.get_raw(&vec![0x1A]), Some(vec![0x1A]));
assert_eq!(tree.get_raw(&[0x00]), Some(vec![0x00]));
assert_eq!(tree.get_raw(&[0x01]), Some(vec![0x01]));
assert_eq!(tree.get_raw(&[0x10]), Some(vec![0x10]));
assert_eq!(tree.get_raw(&[0x19]), Some(vec![0x19]));
assert_eq!(tree.get_raw(&[0x19, 0x00]), Some(vec![0x19, 0x00]));
assert_eq!(tree.get_raw(&[0x1A]), Some(vec![0x1A]));
}

#[test]
Expand Down

0 comments on commit 4222de1

Please sign in to comment.