diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 07687a82..81969155 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1,5 +1,5 @@ 94c97b03bf43e1d2064f7255b0cbdecf9eb3cbb90aee04ac885f11dd744f07d7 ibc_transfer.wasm -07586abddaff15b84725b5266d39564acd1929c22b64efd2af9db06a99e924df neutron_interchain_queries.wasm +115c0b64f0ce6bb2299e9deb35dc238dc059fbf3971c7e4a0f4819e88c687595 neutron_interchain_queries.wasm 94b991497c807fbb3fd9b7c95458029a9fd2c39fe08aff6211a5ef0f3173a087 neutron_interchain_txs.wasm beecb5de00039e7104117060c66c2ece4ff85ea30ea1bc3c884f15b778e7ea87 neutron_validators_test.wasm 2e7a0f168de97eebf4080df6f9fe23987fc96ac5852f29ca6c489dee7b10e6dd reflect.wasm diff --git a/artifacts/neutron_interchain_queries.wasm b/artifacts/neutron_interchain_queries.wasm index 072d3a83..58207dbe 100644 Binary files a/artifacts/neutron_interchain_queries.wasm and b/artifacts/neutron_interchain_queries.wasm differ diff --git a/contracts/neutron_interchain_queries/schema/execute_msg.json b/contracts/neutron_interchain_queries/schema/execute_msg.json index 4a7999f0..3210566f 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -372,10 +372,10 @@ "description": "Used only in integration tests framework to simulate failures. After executing this message, contract will attempt to alter state, zero out kv query statistics and then fail, all of this happening in sudo kv callback handler.", "type": "object", "required": [ - "integration_tests_set_kv_query_mock" + "integration_tests_set_query_mock" ], "properties": { - "integration_tests_set_kv_query_mock": { + "integration_tests_set_query_mock": { "type": "object" } }, @@ -385,10 +385,10 @@ "description": "Used only in integration tests framework to simulate failures. After executing this message, contract will revert back to normal behaviour.", "type": "object", "required": [ - "integration_tests_unset_kv_query_mock" + "integration_tests_unset_query_mock" ], "properties": { - "integration_tests_unset_kv_query_mock": { + "integration_tests_unset_query_mock": { "type": "object" } }, diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 06063b49..2f6e69b5 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -26,8 +26,8 @@ use crate::msg::{ KvCallbackStatsResponse, MigrateMsg, QueryMsg, }; use crate::state::{ - IntegrationTestsKvMock, Transfer, INTEGRATION_TESTS_KV_MOCK, KV_CALLBACK_STATS, RECIPIENT_TXS, - TRANSFERS, + IntegrationTestsQueryMock, Transfer, INTEGRATION_TESTS_QUERY_MOCK, KV_CALLBACK_STATS, + RECIPIENT_TXS, TRANSFERS, }; use neutron_sdk::bindings::msg::NeutronMsg; use neutron_sdk::bindings::query::{InterchainQueries, QueryRegisteredQueryResponse}; @@ -45,7 +45,7 @@ use neutron_sdk::interchain_queries::{ use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; -use crate::integration_tests_mock_handlers::{set_kv_query_mock, unset_kv_query_mock}; +use crate::integration_tests_mock_handlers::{set_query_mock, unset_query_mock}; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD, @@ -123,8 +123,8 @@ pub fn execute( new_recipient, } => update_interchain_query(query_id, new_keys, new_update_period, new_recipient), ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), - ExecuteMsg::IntegrationTestsSetKvQueryMock {} => set_kv_query_mock(deps), - ExecuteMsg::IntegrationTestsUnsetKvQueryMock {} => unset_kv_query_mock(deps), + ExecuteMsg::IntegrationTestsSetQueryMock {} => set_query_mock(deps), + ExecuteMsg::IntegrationTestsUnsetQueryMock {} => unset_query_mock(deps), ExecuteMsg::IntegrationTestsRegisterQueryEmptyId { connection_id } => { register_query_empty_id(deps, env, connection_id) } @@ -380,6 +380,12 @@ pub fn sudo_tx_query_result( _height: u64, data: Binary, ) -> NeutronResult { + if let Some(IntegrationTestsQueryMock::Enabled {}) = + INTEGRATION_TESTS_QUERY_MOCK.may_load(deps.storage)? + { + // simulate error on tx query submit for integration tests + return Err(NeutronError::IntegrationTestsMock {}); + } // Decode the transaction data let tx: TxRaw = TxRaw::decode(data.as_slice())?; let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; @@ -504,8 +510,8 @@ pub fn sudo_kv_query_result( .as_str(), ); - if let Some(IntegrationTestsKvMock::Enabled {}) = - INTEGRATION_TESTS_KV_MOCK.may_load(deps.storage)? + if let Some(IntegrationTestsQueryMock::Enabled {}) = + INTEGRATION_TESTS_QUERY_MOCK.may_load(deps.storage)? { // doesn't really matter whatever data we try to save here, it should all be reverted // since we return an error in this branch anyway. in fact, this branch exists for the diff --git a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs index 954c0f43..d606b8d4 100644 --- a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs @@ -1,17 +1,15 @@ -use crate::state::{IntegrationTestsKvMock, INTEGRATION_TESTS_KV_MOCK}; +use crate::state::{IntegrationTestsQueryMock, INTEGRATION_TESTS_QUERY_MOCK}; use cosmwasm_std::{DepsMut, Response}; use neutron_sdk::bindings::msg::NeutronMsg; use neutron_sdk::bindings::query::InterchainQueries; use neutron_sdk::NeutronResult; -pub fn set_kv_query_mock(deps: DepsMut) -> NeutronResult> { - INTEGRATION_TESTS_KV_MOCK.save(deps.storage, &IntegrationTestsKvMock::Enabled)?; +pub fn set_query_mock(deps: DepsMut) -> NeutronResult> { + INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Enabled)?; Ok(Response::default()) } -pub fn unset_kv_query_mock( - deps: DepsMut, -) -> NeutronResult> { - INTEGRATION_TESTS_KV_MOCK.save(deps.storage, &IntegrationTestsKvMock::Disabled)?; +pub fn unset_query_mock(deps: DepsMut) -> NeutronResult> { + INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Disabled)?; Ok(Response::default()) } diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index 97f8c89d..f97968f0 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -71,10 +71,10 @@ pub enum ExecuteMsg { /// After executing this message, contract will attempt to alter state, /// zero out kv query statistics and then fail, all of this happening /// in sudo kv callback handler. - IntegrationTestsSetKvQueryMock {}, + IntegrationTestsSetQueryMock {}, /// Used only in integration tests framework to simulate failures. /// After executing this message, contract will revert back to normal behaviour. - IntegrationTestsUnsetKvQueryMock {}, + IntegrationTestsUnsetQueryMock {}, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/contracts/neutron_interchain_queries/src/state.rs b/contracts/neutron_interchain_queries/src/state.rs index 1fcd6b52..28ec6b6c 100644 --- a/contracts/neutron_interchain_queries/src/state.rs +++ b/contracts/neutron_interchain_queries/src/state.rs @@ -17,11 +17,11 @@ pub struct Transfer { pub amount: String, } -pub const INTEGRATION_TESTS_KV_MOCK: Item = +pub const INTEGRATION_TESTS_QUERY_MOCK: Item = Item::new("integration_tests_kv_mock"); #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub enum IntegrationTestsKvMock { +pub enum IntegrationTestsQueryMock { Enabled, Disabled, }