From d0b00a5072dd365bdf40110ac10a43a86b7684b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20K=C3=BCl=C3=A7e?= Date: Wed, 4 Aug 2021 18:55:59 +0300 Subject: [PATCH] Apply review recommendations --- contracts/cw20-merkle-airdrop/src/contract.rs | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/contracts/cw20-merkle-airdrop/src/contract.rs b/contracts/cw20-merkle-airdrop/src/contract.rs index d512e7faf..dae2bb678 100644 --- a/contracts/cw20-merkle-airdrop/src/contract.rs +++ b/contracts/cw20-merkle-airdrop/src/contract.rs @@ -7,6 +7,7 @@ use cosmwasm_std::{ use cw2::{get_contract_version, set_contract_version}; use cw20::Cw20ExecuteMsg; use cw_storage_plus::U8Key; +use sha2::Digest; use std::convert::TryInto; use crate::error::ContractError; @@ -15,7 +16,6 @@ use crate::msg::{ MerkleRootResponse, MigrateMsg, QueryMsg, }; use crate::state::{Config, CLAIM, CONFIG, LATEST_STAGE, MERKLE_ROOT}; -use sha2::Digest; // Version info, for migration info const CONTRACT_NAME: &str = "crates.io:cw20-merkle-airdrop"; @@ -241,7 +241,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result, } - fn read_test_data(path: &str) -> Encoded { - use std::fs::File; - use std::io::BufReader; - - // Open the file in read-only mode with buffer. - let file = File::open(path).unwrap(); - let reader = BufReader::new(file); - - serde_json::from_reader(reader).unwrap() - } - #[test] fn claim() { // Run test 1 let mut deps = mock_dependencies(&[]); - let test_data = read_test_data(TEST_DATA_1); + let test_data: Encoded = from_slice(TEST_DATA_1).unwrap(); let msg = InstantiateMsg { owner: Some("owner0000".to_string()), @@ -452,7 +441,7 @@ mod tests { // Second test - let test_data = read_test_data(TEST_DATA_2); + let test_data: Encoded = from_slice(TEST_DATA_2).unwrap(); // check claimed let res = execute(deps.as_mut(), env, info, msg).unwrap_err(); assert_eq!(res, ContractError::Claimed {});