Skip to content

Commit

Permalink
fix: Basic state broken due to key change (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel-figure authored Nov 19, 2024
1 parent 5d0d896 commit 4f65e6d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "asset-classification-smart-contract"
version = "3.4.0"
version = "3.4.1"
authors = [
"Jake Schwartz <[email protected]>",
"Pierce Trey <[email protected]>",
Expand Down
12 changes: 11 additions & 1 deletion src/core/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};

use super::error::ContractError;

const STATE_V2_KEY: &str = "state_v2";
const STATE_V2_KEY: &str = "\x00\x08state_v2"; // Special characters added to allow seamless upgrade from cosmwasm-storage to cw-storage-plus
pub const STATE_V2: Item<StateV2> = Item::new(STATE_V2_KEY);

const FEE_PAYMENT_DETAIL_NAMESPACE: &str = "fee_payment_detail";
Expand Down Expand Up @@ -564,4 +564,14 @@ mod tests {
err,
);
}

#[test]
fn test_basic_state_key_is_expected_value() {
assert_eq!(
"000873746174655f7632",
cosmwasm_std::to_hex(crate::core::state::STATE_V2_KEY.as_bytes())
.as_str()
.to_lowercase()
);
}
}
7 changes: 3 additions & 4 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use uuid::Uuid;
fn get_contract_wasm_bytes() -> &'static Vec<u8> {
use std::sync::OnceLock;

static OPTIMIZED_CONTRACT_WASM_PATH: OnceLock<Vec<u8>> = OnceLock::new();
OPTIMIZED_CONTRACT_WASM_PATH.get_or_init(|| {
static OPTIMIZED_CONTRACT_WASM: OnceLock<Vec<u8>> = OnceLock::new();
OPTIMIZED_CONTRACT_WASM.get_or_init(|| {
let file_path = std::env::var("OPTIMIZED_CONTRACT_WASM_PATH").unwrap_or(String::from(
"./artifacts/asset_classification_smart_contract.wasm",
));
Expand Down Expand Up @@ -62,9 +62,8 @@ fn happy_path_onboard_and_verify_asset() {
});

let wasm = Wasm::new(&app);
let wasm_byte_code = get_contract_wasm_bytes();
let store_res = wasm
.store_code(&wasm_byte_code, None, admin)
.store_code(get_contract_wasm_bytes(), None, admin)
.expect("storing the WASM code should succeed");
let code_id = store_res.data.code_id;
assert_eq!(code_id, 1);
Expand Down

0 comments on commit 4f65e6d

Please sign in to comment.