Skip to content

Commit

Permalink
More clippy-related fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
td202 committed Nov 12, 2024
1 parent ae81b31 commit c284cdf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn btree_get(b: &mut Criterion) {
b.bench_function("BTreeMap get", |b| {
b.iter(|| {
for w in words.iter() {
if tree.get(&w[..]).is_none() {
if !tree.contains_key(&w[..]) {
panic!("Failure.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion smart-contracts/wasm-chain-integration/benches/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Host<MeteringImport> for MeteringHost {
fn call(
&mut self,
f: &MeteringImport,
_memory: &mut Vec<u8>,
_memory: &mut [u8],
stack: &mut machine::RuntimeStack,
) -> machine::RunResult<Option<NoInterrupt>> {
match f.tag {
Expand Down
1 change: 1 addition & 0 deletions smart-contracts/wasm-chain-integration/src/v1/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type ReceiveInterruptedStateV1 = ReceiveInterruptedState<CompiledFunction>;
/// - In the remaining two cases the `output_return_value` is set to a pointer
/// to a freshly allocated vector. This vector must be deallocated with
/// [box_vec_u8_free] otherwise memory will be leaked.
///
/// In case of execution failure, a panic, or failure to parse a null pointer is
/// returned.
#[no_mangle]
Expand Down
12 changes: 6 additions & 6 deletions smart-contracts/wasm-chain-integration/src/v1/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const NUM_TESTS: u64 = 100000;
/// 1. Entries can be created.
/// 2. Created entries can be looked up.
/// 3. Writing to created entries and checking that the returned 'write length'
/// is accurate.
/// is accurate.
/// 4. Reading from an invalidated entry should return u32::MAX.
/// 5. Writing to an invalidated entry should return u32::MAX.
/// 6. Entries can be deleted check that equivalent entries are also
/// invalidated.
/// invalidated.
/// 7. Deleting already deleted entries returns u32::MAX
fn prop_create_write_read_delete() {
let prop = |inputs: Vec<(Vec<u8>, trie::Value)>| -> anyhow::Result<()> {
Expand Down Expand Up @@ -92,9 +92,9 @@ fn prop_create_write_read_delete() {
/// 1. Writing a buffer of MAX_ENTRY_SIZE succeeds.
/// 2. Reading a buffer of MAX_ENTRY_SIZE succeeds.
/// 3. Writing a buffer of MAX_ENTRY_SIZE + 1 only writes the first
/// MAX_ENTRY_SIZE bytes.
/// MAX_ENTRY_SIZE bytes.
/// 4. Reading a buffer of MAX_ENTRY_SIZE + 1 only returns the corresponding
/// MAX_ENTRY_SIZE bytes.
/// MAX_ENTRY_SIZE bytes.
/// 5. Test resizing to 0 bytes followed by a resize to MAX_ENTRY_SIZE
/// 6. Resizing above MAX_ENTRY_SIZE yields correct result
/// 7. Resizing without enough energy returns an Err.
Expand Down Expand Up @@ -309,10 +309,10 @@ fn test_prefix_removal_fails_if_out_of_energy() -> anyhow::Result<()> {
/// 1. Entries can be created
/// 2. Created entries can be looked up.
/// 3. Writing to created entries and that the returned 'write length' is
/// accurate.
/// accurate.
/// 4. Creating iterators and locking parts of the tree.
/// 5. Making sure that no locked areas can be subject of structural
/// modification.
/// modification.
fn prop_iterators() {
let prop = |inputs: Vec<(Vec<u8>, trie::Value)>| -> anyhow::Result<()> {
let mut loader = trie::Loader {
Expand Down
4 changes: 2 additions & 2 deletions smart-contracts/wasm-test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion smart-contracts/wasm-transform/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<I> Host<I> for TestHost {
fn call(
&mut self,
_f: &I,
_memory: &mut Vec<u8>,
_memory: &mut [u8],
_stack: &mut crate::machine::RuntimeStack,
) -> crate::machine::RunResult<Option<Self::Interrupt>> {
unimplemented!("No imports are allowed, so this can never be called in tests.")
Expand Down

0 comments on commit c284cdf

Please sign in to comment.