From 699b87de9215c342258062e6ee3d965f91e18e13 Mon Sep 17 00:00:00 2001 From: redlarva <91685111+redlarva@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:22:06 +0545 Subject: [PATCH] fix: e2e and integration test (#75) --- contracts/cosmwasm-vm/cw-xcall/src/dapp.rs | 2 +- contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs | 8 ++++---- contracts/cosmwasm-vm/cw-xcall/src/lib.rs | 10 ++++------ contracts/cosmwasm-vm/cw-xcall/tests/test_admin.rs | 3 +-- scripts/optimize-cosmwasm.sh | 3 ++- scripts/optimize-jar.sh | 5 +++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-xcall/src/dapp.rs b/contracts/cosmwasm-vm/cw-xcall/src/dapp.rs index 5d84e164..76455951 100644 --- a/contracts/cosmwasm-vm/cw-xcall/src/dapp.rs +++ b/contracts/cosmwasm-vm/cw-xcall/src/dapp.rs @@ -24,7 +24,7 @@ impl<'a> CwCallService<'a> { id: reply_id, msg: cosm_msg, gas_limit: None, - reply_on: cosmwasm_std::ReplyOn::Never, + reply_on: cosmwasm_std::ReplyOn::Always, }; Ok(submessage) diff --git a/contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs b/contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs index 2bcfdc17..ddeb0063 100644 --- a/contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs +++ b/contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs @@ -1,12 +1,11 @@ use cosmwasm_std::DepsMut; use cosmwasm_std::MessageInfo; -use cosmwasm_std::SubMsgResult; -use cosmwasm_std::{Deps, Env, Reply, Response}; + +use cosmwasm_std::{Env, Response}; use crate::error::ContractError; use crate::events::event_rollback_executed; use crate::state::{CwCallService, EXECUTE_ROLLBACK_ID}; -use crate::types::LOG_PREFIX; impl<'a> CwCallService<'a> { /// This function executes a rollback operation for a previously made call request. @@ -42,7 +41,7 @@ impl<'a> CwCallService<'a> { .unwrap(); let from = self.get_own_network_address(deps.as_ref().storage, &env)?; - let sub_msg = self.call_dapp_handle_message( + let mut sub_msg = self.call_dapp_handle_message( info, // the original caller is stored as from in call request call_request.from().clone(), @@ -51,6 +50,7 @@ impl<'a> CwCallService<'a> { call_request.protocols().clone(), EXECUTE_ROLLBACK_ID, )?; + sub_msg.reply_on = cosmwasm_std::ReplyOn::Never; let event = event_rollback_executed(sequence_no); diff --git a/contracts/cosmwasm-vm/cw-xcall/src/lib.rs b/contracts/cosmwasm-vm/cw-xcall/src/lib.rs index e3caeb59..457df968 100644 --- a/contracts/cosmwasm-vm/cw-xcall/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-xcall/src/lib.rs @@ -23,7 +23,7 @@ use crate::{ event_xcall_message_sent, }, msg::{InstantiateMsg, QueryMsg}, - state::{CwCallService, EXECUTE_CALL_ID, EXECUTE_ROLLBACK_ID, SEND_CALL_MESSAGE_REPLY_ID}, + state::{CwCallService, EXECUTE_CALL_ID}, types::{ call_request::CallRequest, message::{CSMessage, CallServiceMessageType}, @@ -35,17 +35,15 @@ use crate::{ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{ - ensure, ensure_eq, entry_point, to_binary, Addr, Api, Binary, CosmosMsg, Deps, DepsMut, Env, - Event, MessageInfo, QuerierWrapper, Reply, Response, StdError, StdResult, Storage, SubMsg, - SubMsgResult, WasmMsg, + ensure, ensure_eq, entry_point, to_binary, Addr, Api, Binary, Deps, DepsMut, Env, Event, + MessageInfo, QuerierWrapper, Reply, Response, StdError, StdResult, Storage, SubMsg, }; use cw2::set_contract_version; use cw_storage_plus::{Item, Map}; use cw_xcall_lib::xcall_msg::ExecuteMsg; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use thiserror::Error; /// This function instantiates a contract using the CwCallService. diff --git a/contracts/cosmwasm-vm/cw-xcall/tests/test_admin.rs b/contracts/cosmwasm-vm/cw-xcall/tests/test_admin.rs index 4a202ed9..270439d7 100644 --- a/contracts/cosmwasm-vm/cw-xcall/tests/test_admin.rs +++ b/contracts/cosmwasm-vm/cw-xcall/tests/test_admin.rs @@ -3,8 +3,7 @@ mod setup; use account::*; use cosmwasm_std::{testing::mock_env, Addr}; -use cw2::{get_contract_version, ContractVersion}; -use cw_xcall::{state::CwCallService, MigrateMsg}; +use cw_xcall::state::CwCallService; use cw_xcall_lib::xcall_msg::ExecuteMsg; use setup::test::*; diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index d6b1548d..be2cfee0 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -9,7 +9,7 @@ RUSTC_VERS="1.69.0" MAX_WASM_SIZE=800 # 800 KB -PROJECTS=("cw-xcall" "cw-mock-dapp" "cw-mock-dapp-multi") +PROJECTS=("cw-xcall" "cw-xcall-lib") # Install wasm-opt binary if ! which wasm-opt; then @@ -65,6 +65,7 @@ rename_wasm_with_version() { local wasm_file="artifacts/archway/${project_path//-/_}.wasm" if [[ -f "$wasm_file" ]]; then + cp "$wasm_file" "${wasm_file%.wasm}_latest.wasm" mv "$wasm_file" "${wasm_file%.wasm}_${version}.wasm" echo "Renamed: ${wasm_file} -> ${wasm_file%.wasm}_${version}.wasm" else diff --git a/scripts/optimize-jar.sh b/scripts/optimize-jar.sh index 5bd5f38e..e031cffc 100755 --- a/scripts/optimize-jar.sh +++ b/scripts/optimize-jar.sh @@ -8,9 +8,10 @@ cd contracts/javascore cd - for jar in $(find . -type f -name "*optimized.jar" | grep /build/libs/); do - NAME=$(basename "$jar" .jar)${SUFFIX}.jar + NAME=$(basename "$jar" .jar).jar echo "Creating intermediate hash for ${NAME}..." sha256sum -- "$jar" | tee -a artifacts/icon/checksums_intermediate.txt - echo "Copying $NAME ..." + echo "Copying $NAME" cp "$jar" "artifacts/icon/$NAME" + cp "$jar" "artifacts/icon/${NAME%%-[0-9]*.[0-9]*.[0-9]*-optimized.jar}-latest.jar" done