From 4bb1af05acb5fe16de250b770666fd8569bb398c Mon Sep 17 00:00:00 2001 From: Benjamin DENEUX Date: Wed, 8 Mar 2023 11:01:17 +0100 Subject: [PATCH] fix(storage): indicate max pin count in error --- Makefile.toml | 4 ++-- contracts/cw-storage/Cargo.toml | 6 +++--- contracts/cw-storage/src/contract.rs | 9 +++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 5f0dbbe7..4187ccf5 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -66,9 +66,9 @@ description = "Run all unit tests." env = { LLVM_PROFILE_FILE = "default.profraw", RUST_BACKTRACE = 1 } [tasks.test-coverage] -dependencies = ["install-tarpaulin"] -command = "cargo" args = ["tarpaulin", "-o", "lcov"] +command = "cargo" +dependencies = ["install-tarpaulin"] [tasks.install_wasm] script = ''' diff --git a/contracts/cw-storage/Cargo.toml b/contracts/cw-storage/Cargo.toml index 82efc3e1..fc715935 100644 --- a/contracts/cw-storage/Cargo.toml +++ b/contracts/cw-storage/Cargo.toml @@ -27,6 +27,7 @@ panic = 'abort' rpath = false [dependencies] +base16ct = "0.1.1" cosmwasm-schema.workspace = true cosmwasm-std.workspace = true cosmwasm-storage.workspace = true @@ -34,13 +35,12 @@ cw-storage-plus.workspace = true cw2.workspace = true schemars.workspace = true serde.workspace = true -thiserror.workspace = true sha2 = "0.10.6" -base16ct = "0.1.1" +thiserror.workspace = true [dev-dependencies] -cw-multi-test.workspace = true base64 = "0.21.0" +cw-multi-test.workspace = true [features] # for more explicit tests, cargo test --features=backtraces diff --git a/contracts/cw-storage/src/contract.rs b/contracts/cw-storage/src/contract.rs index 10201bab..15c28c4d 100644 --- a/contracts/cw-storage/src/contract.rs +++ b/contracts/cw-storage/src/contract.rs @@ -150,7 +150,9 @@ pub mod execute { Limits { max_object_pins: Some(max), .. - } if max < o.pin_count => Err(BucketError::MaxObjectPinsLimitExceeded.into()), + } if max < o.pin_count => { + Err(BucketError::MaxObjectPinsLimitExceeded(o.pin_count, max).into()) + } _ => { pins().save( deps.storage, @@ -777,7 +779,10 @@ mod tests { mock_info("pierre", &[]), ], expected_count: 3, - expected_error: Some(ContractError::Bucket(MaxObjectPinsLimitExceeded)), + expected_error: Some(ContractError::Bucket(MaxObjectPinsLimitExceeded( + Uint128::new(3), + Uint128::new(2), + ))), expected_object_pin_count: vec![ ( ObjectId::from(