diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 47db607c..da0b68c4 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1,4 +1,4 @@ ead6981fb868b4eb91a11c12f6b35f9320ebdb24ef90867cfd1e12afcbf2ec0a ibc_transfer.wasm -183df19e69fa3df61ea7b6f213f855ed16a01d36d48cc5317218c7b3bdcabf58 neutron_interchain_queries.wasm +545b0c7d43927767617dc74820108af20dd250ae3f70326cd2f9cba63bb650ef neutron_interchain_queries.wasm bff6464e045915d4286718630624a1bcb3b535d49808539225eedf9eedc2830f neutron_interchain_txs.wasm 577c821c8667df4cb1c34bb0ff80af5cc96c8f42a7286e1b2a7e7fd76ef7d689 reflect.wasm diff --git a/artifacts/neutron_interchain_queries.wasm b/artifacts/neutron_interchain_queries.wasm index 4a4271b9..a5cf2ade 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 bda1ef5e..4fee8922 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -172,6 +172,69 @@ }, "additionalProperties": false }, + { + "description": "Used only in integration tests framework to simulate failures.", + "type": "object", + "required": [ + "integration_tests_register_query_empty_keys" + ], + "properties": { + "integration_tests_register_query_empty_keys": { + "type": "object", + "required": [ + "connection_id" + ], + "properties": { + "connection_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Used only in integration tests framework to simulate failures.", + "type": "object", + "required": [ + "integration_tests_register_query_empty_path" + ], + "properties": { + "integration_tests_register_query_empty_path": { + "type": "object", + "required": [ + "connection_id" + ], + "properties": { + "connection_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Used only in integration tests framework to simulate failures.", + "type": "object", + "required": [ + "integration_tests_register_query_empty_id" + ], + "properties": { + "integration_tests_register_query_empty_id": { + "type": "object", + "required": [ + "connection_id" + ], + "properties": { + "connection_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, { "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", diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index d86ebdf3..0dd21fc9 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -17,6 +17,7 @@ use cosmos_sdk_proto::cosmos::tx::v1beta1::{TxBody, TxRaw}; use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, }; +use neutron_sdk::interchain_queries::register_queries::register_interchain_query_msg; use prost::Message as ProstMessage; use crate::msg::{ @@ -42,7 +43,7 @@ use neutron_sdk::{NeutronError, NeutronResult}; use crate::integration_tests_mock_handlers::{set_kv_query_mock, unset_kv_query_mock}; use neutron_sdk::interchain_queries::types::{ - TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, + QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD, }; use serde_json_wasm; @@ -109,6 +110,15 @@ pub fn execute( ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), ExecuteMsg::IntegrationTestsSetKvQueryMock {} => set_kv_query_mock(deps), ExecuteMsg::IntegrationTestsUnsetKvQueryMock {} => unset_kv_query_mock(deps), + ExecuteMsg::IntegrationTestsRegisterQueryEmptyId { connection_id } => { + register_query_empty_id(deps, env, connection_id) + } + ExecuteMsg::IntegrationTestsRegisterQueryEmptyPath { connection_id } => { + register_query_empty_path(deps, env, connection_id) + } + ExecuteMsg::IntegrationTestsRegisterQueryEmptyKeys { connection_id } => { + register_query_empty_keys(deps, env, connection_id) + } } } @@ -165,6 +175,65 @@ pub fn register_transfers_query( Ok(Response::new().add_message(msg)) } +pub fn register_query_empty_id( + deps: DepsMut, + env: Env, + connection_id: String, +) -> NeutronResult> { + let kv_key = KVKey { + path: "test".to_string(), + key: Binary(vec![]), + }; + let msg = register_interchain_query_msg( + deps, + env, + connection_id, + QueryType::KV, + vec![kv_key], + String::new(), + 10, + )?; + Ok(Response::new().add_message(msg)) +} + +pub fn register_query_empty_path( + deps: DepsMut, + env: Env, + connection_id: String, +) -> NeutronResult> { + let kv_key = KVKey { + path: "".to_string(), + key: Binary("test".as_bytes().to_vec()), + }; + let msg = register_interchain_query_msg( + deps, + env, + connection_id, + QueryType::KV, + vec![kv_key], + String::new(), + 10, + )?; + Ok(Response::new().add_message(msg)) +} + +pub fn register_query_empty_keys( + deps: DepsMut, + env: Env, + connection_id: String, +) -> NeutronResult> { + let msg = register_interchain_query_msg( + deps, + env, + connection_id, + QueryType::KV, + vec![], + String::new(), + 10, + )?; + Ok(Response::new().add_message(msg)) +} + pub fn update_interchain_query( query_id: u64, new_keys: Option>, diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index d8f5b039..4885ecb6 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -36,6 +36,18 @@ pub enum ExecuteMsg { query_id: u64, }, /// Used only in integration tests framework to simulate failures. + IntegrationTestsRegisterQueryEmptyKeys { + connection_id: String, + }, + /// Used only in integration tests framework to simulate failures. + IntegrationTestsRegisterQueryEmptyPath { + connection_id: String, + }, + /// Used only in integration tests framework to simulate failures. + IntegrationTestsRegisterQueryEmptyId { + connection_id: String, + }, + /// 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. diff --git a/packages/neutron-sdk/src/interchain_queries/mod.rs b/packages/neutron-sdk/src/interchain_queries/mod.rs index 9ab8c997..05449b37 100644 --- a/packages/neutron-sdk/src/interchain_queries/mod.rs +++ b/packages/neutron-sdk/src/interchain_queries/mod.rs @@ -14,7 +14,7 @@ pub mod helpers; pub mod queries; -mod register_queries; +pub mod register_queries; pub mod types; pub use register_queries::{ diff --git a/packages/neutron-sdk/src/interchain_queries/register_queries.rs b/packages/neutron-sdk/src/interchain_queries/register_queries.rs index 74cc5626..213ef3c9 100644 --- a/packages/neutron-sdk/src/interchain_queries/register_queries.rs +++ b/packages/neutron-sdk/src/interchain_queries/register_queries.rs @@ -15,7 +15,7 @@ use schemars::_serde_json::to_string; #[allow(clippy::too_many_arguments)] /// Creates a message to register an Interchain Query with provided params -fn register_interchain_query_msg( +pub fn register_interchain_query_msg( _deps: DepsMut, _env: Env, connection_id: String,