Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add IBC denom wrap/unwrap #579

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

SlayerAnsh
Copy link
Contributor

@SlayerAnsh SlayerAnsh commented Oct 14, 2024

Motivation

Added denom wrap/unwrap function in AOSQuerier to use in amp messages.

Implementation

  • Updated denom trace query to query ibc-registry service
  • Implemented get counterparty denom to get expected denom on receiving chain
  • Modified ibc_hooks_transfer message to use denom trace from ibc-registry service

Testing

  • Tests for ibc denom resolution were added with ibc channel query test

Version Changes

NA

Notes

These changes will be coupled with amp message denom handling logic

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced IBC message handling and channel management.
    • Introduced new methods for querying IBC registry and denomination information.
    • Added constants for IBC transfers and mock querier functionalities.
  • Bug Fixes

    • Improved validation checks for packet validity and sender authorization.
  • Documentation

    • Updated error message formats for better clarity.
  • Tests

    • Expanded test coverage for new IBC functionalities and error handling.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the handling of AMP messages and IBC functionalities across several Rust files. Key updates include renaming the generate_transfer_message function to generate_ibc_hook_transfer_message, enhancing authorization checks in the amp_receive function, and restructuring denomination handling in the ibc.rs file. Additionally, new constants and methods related to IBC operations have been introduced, while several outdated structures and functions have been removed to streamline the codebase.

Changes

File Path Change Summary
contracts/os/andromeda-kernel/src/execute.rs - Renamed generate_transfer_message to generate_ibc_hook_transfer_message.
- Updated handle_ibc_hooks to use the new function.
- Modified amp_receive for packet validity checks.
- Updated create to prevent cross-chain component creation without an owner.
- Simplified internal to handle RegisterUserCrossChain.
- Updated assign_channels for channel management.
contracts/os/andromeda-kernel/src/ibc.rs - Renamed generate_transfer_message to generate_ibc_hook_transfer_message.
- Added get_counterparty_denom function.
- Removed functions related to denomination tracing.
contracts/os/andromeda-kernel/src/proto.rs - Removed QueryDenomTraceRequest, QueryDenomTraceResponse, and DenomTrace structs.
packages/std/src/amp/mod.rs - Added constant IBC_REGISTRY_KEY.
packages/std/src/error.rs - Added method new to ContractError.
- Updated InvalidDenomTracePath error message format.
packages/std/src/os/aos_querier.rs - Added methods for querying IBC registry and denomination information.
- Introduced a test function for get_counterparty_denom.
packages/std/src/os/ibc_registry.rs - Added Hop struct and associated methods for path handling.
- Updated DenomInfo with a new constructor.
packages/std/src/os/mod.rs - Added constants TRANSFER_PORT and IBC_VERSION.
packages/std/src/testing/mock_querier.rs - Added constants for mock IBC interactions and updated WasmMockQuerier for handling IBC queries.

Possibly related PRs

Suggested labels

ci: skip-changelog

Suggested reviewers

  • crnbarr93
  • joemonem

Poem

In the code where rabbits play,
IBC hops and messages sway.
With hooks and channels, we refine,
A dance of data, oh so fine!
Through the fields of Rust we roam,
Crafting pathways, making code our home. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (3)
packages/std/src/os/mod.rs (1)

8-10: LGTM! Consider enhancing the comment for clarity.

The addition of these constants for IBC transfer is appropriate and follows good practices. The naming is clear and adheres to Rust conventions.

Consider expanding the comment to provide more context:

-// IBC transfer port
+// Constants for IBC (Inter-Blockchain Communication) transfer
+// TRANSFER_PORT: Standard port for IBC transfers
+// IBC_VERSION: Andromeda-specific IBC protocol version

This additional information could help other developers understand the purpose and significance of these constants more easily.

packages/std/src/os/ibc_registry.rs (1)

86-90: Consider adding documentation comments to the Hop struct and its fields

Adding documentation comments will improve code readability and help others understand the purpose of Hop, port_id, and channel_id.

contracts/os/andromeda-kernel/src/ibc.rs (1)

297-297: Add unit tests for new functions

The tests module is currently empty. It's important to add unit tests for the new functions get_counterparty_denom and generate_ibc_hook_transfer_message to ensure their correctness and prevent future regressions.

Do you want assistance in writing these unit tests or would you like me to open a GitHub issue to track this task?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c6c98d0 and 2878f78.

📒 Files selected for processing (9)
  • contracts/os/andromeda-kernel/src/execute.rs (2 hunks)
  • contracts/os/andromeda-kernel/src/ibc.rs (4 hunks)
  • contracts/os/andromeda-kernel/src/proto.rs (0 hunks)
  • packages/std/src/amp/mod.rs (1 hunks)
  • packages/std/src/error.rs (2 hunks)
  • packages/std/src/os/aos_querier.rs (4 hunks)
  • packages/std/src/os/ibc_registry.rs (3 hunks)
  • packages/std/src/os/mod.rs (1 hunks)
  • packages/std/src/testing/mock_querier.rs (7 hunks)
💤 Files with no reviewable changes (1)
  • contracts/os/andromeda-kernel/src/proto.rs
🧰 Additional context used
🔇 Additional comments (21)
packages/std/src/os/mod.rs (1)

9-10: Verify usage and consider future maintenance.

These constants are likely to be used in various parts of the codebase for IBC-related operations.

To ensure consistent usage, let's check where these constants are being used:

Consider the following for future maintenance:

  1. The IBC_VERSION constant might need updates in the future as the protocol evolves. Ensure there's a process in place to review and update this constant when necessary.
  2. If these constants are used in multiple places, consider creating a dedicated module for IBC-related constants to centralize their management.
✅ Verification successful

TRANSFER_PORT and IBC_VERSION are consistently used across the codebase with no issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of TRANSFER_PORT and IBC_VERSION constants

echo "Checking usage of TRANSFER_PORT:"
rg --type rust "TRANSFER_PORT"

echo "Checking usage of IBC_VERSION:"
rg --type rust "IBC_VERSION"

Length of output: 1719

packages/std/src/error.rs (2)

741-745: LGTM! New method enhances error creation.

The new new method provides a convenient way to create a ContractError::Std from a string error message. This addition improves the ease of use when creating standard errors.


719-720: LGTM! Verify existing error handling code.

The updated InvalidDenomTracePath variant provides more flexibility with an optional message. This change improves error reporting capabilities.

Please ensure that existing error handling code is updated to accommodate this change. Run the following script to find potential affected areas:

✅ Verification successful

Verification Successful! All usages of InvalidDenomTracePath have been updated to handle the new msg field appropriately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of InvalidDenomTracePath to verify error handling

# Search for InvalidDenomTracePath usage
rg --type rust "InvalidDenomTracePath" -C 3

Length of output: 2366

packages/std/src/os/ibc_registry.rs (8)

22-24: Constructor new for DenomInfo is correctly implemented

The function initializes DenomInfo with the provided base_denom and path.


92-96: Method to_trace in Hop is correctly implemented

The method correctly formats port_id and channel_id into a trace string.


126-131: Function hops_to_trace is correctly implemented

The function accurately concatenates the hop traces into a single string.


194-203: Test test_unwrap_path effectively validates unwrap_path with a standard path

The test correctly checks that the function parses the path into the expected hops.


205-219: Test test_hops_to_trace correctly verifies the functionality of hops_to_trace

The test ensures that the function produces the expected trace string from a given list of hops.


221-232: Test test_unwrap_path_invalid appropriately checks error handling for invalid paths

The test validates that unwrap_path returns the correct error when given a path with an odd number of segments.


234-239: Test test_empty_path confirms that an empty path returns an empty list of hops

The test ensures the function handles empty input correctly.


241-246: Test test_empty_hops_to_trace verifies that an empty list of hops results in an empty trace

The test confirms that hops_to_trace handles empty input as expected.

packages/std/src/os/aos_querier.rs (4)

152-159: Well-implemented ibc_registry_address_getter function

The function correctly queries the kernel's storage to retrieve the IBC Registry's address using IBC_REGISTRY_KEY. The implementation is consistent with existing patterns in the codebase and follows best practices.


258-270: Correct implementation of denom_trace_getter function

The function properly constructs the query to the IBC Registry to obtain the DenomInfo for a given denomination. Error handling is appropriately managed, and the use of query_wasm_smart aligns with the standard querying approach.


272-324: get_counterparty_denom function handles denomination transformations effectively

The function effectively calculates the counterparty denomination by handling both unwrapping and wrapping scenarios based on the denomination trace and source channel. The logic is sound, and error conditions are properly handled with meaningful error messages.


327-422: Comprehensive test coverage in test_get_counterparty_denom

The test function thoroughly covers various scenarios, including unwrapping, wrapping, multi-hop cases, and invalid channels. This ensures the reliability and correctness of the get_counterparty_denom function. Good job on including edge cases in your tests.

contracts/os/andromeda-kernel/src/execute.rs (1)

19-19: Import of generate_ibc_hook_transfer_message is correct

The function generate_ibc_hook_transfer_message has been properly imported from crate::ibc, ensuring it's available for use in this file.

packages/std/src/testing/mock_querier.rs (5)

4-10: Imports for IBC functionalities are correctly added

The new imports for IBC functionalities and related query messages are correctly added and are necessary for the enhanced IBC features.


41-42: Constant MOCK_IBC_REGISTRY_CONTRACT is correctly defined

The new constant MOCK_IBC_REGISTRY_CONTRACT is appropriately added and follows the existing naming conventions for mock contract addresses.


72-81: Definition of IBC-related constants is consistent and appropriate

The added constants for IBC denominations, paths, and channels are well-defined and maintain consistency with the existing codebase. They are essential for simulating IBC interactions in the mock environment.


201-201: Integrating MOCK_IBC_REGISTRY_CONTRACT into handle_query

The addition of MOCK_IBC_REGISTRY_CONTRACT in the handle_query function correctly routes IBC registry queries to the handle_ibc_registry_query method.


280-282: Adding support for IBC_REGISTRY_KEY in handle_kernel_query

The handling of IBC_REGISTRY_KEY in the handle_kernel_query function appropriately returns the MOCK_IBC_REGISTRY_CONTRACT address, enabling proper retrieval of the IBC registry contract within the kernel.

@@ -3,6 +3,7 @@ pub mod messages;
pub mod recipient;

pub const ADO_DB_KEY: &str = "adodb";
pub const IBC_REGISTRY_KEY: &str = "ibc-registry";
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Action Required: Replace hardcoded "ibc-registry" strings with IBC_REGISTRY_KEY constant.

  • Found hardcoded "ibc-registry" strings in:
    • packages/andromeda-testing/src/mock.rs (2 occurrences)

Please update these instances to use the IBC_REGISTRY_KEY constant to ensure consistency and maintainability.

🔗 Analysis chain

LGTM! Verify usage of the new constant.

The addition of IBC_REGISTRY_KEY constant is appropriate and aligns with the PR objectives. The naming convention and placement are consistent with other constants in this file.

To ensure the new constant is being utilized as intended, let's verify its usage across the codebase:

This will help confirm that the new constant is being used appropriately and that there are no remaining hardcoded instances of the "ibc-registry" string.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of IBC_REGISTRY_KEY constant

# Search for direct usage of the constant
echo "Searching for direct usage of IBC_REGISTRY_KEY:"
rg --type rust "IBC_REGISTRY_KEY"

# Search for the string literal "ibc-registry" to catch any hardcoded usage
echo "\nSearching for hardcoded 'ibc-registry' strings:"
rg --type rust '"ibc-registry"'

Length of output: 1259

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

packages/std/src/os/ibc_registry.rs Show resolved Hide resolved
};
let new_coin = Coin::new(funds.amount.u128(), new_denom);
let (counterparty_denom, _) = get_counterparty_denom(deps, &fund.denom, &channel)?;
let new_coin = Coin::new(fund.amount.u128(), counterparty_denom);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Possible incorrect token denomination in MsgTransfer

The MsgTransfer is being constructed with token: Some(fund.into()), which uses the original fund with the original denomination. However, after obtaining the counterparty denomination and creating new_coin, it seems the MsgTransfer should use new_coin to ensure the correct denomination is transferred to the counterparty.

Apply this diff to fix the issue:

-            token: Some(fund.into()),
+            token: Some(new_coin.into()),

Also applies to: 287-287

}

#[allow(clippy::too_many_arguments)]
pub fn generate_transfer_message(
pub fn generate_ibc_hook_transfer_message(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

All references to generate_transfer_message have not been updated

The following file still contains references to the old function name and should be updated to generate_ibc_hook_transfer_message:

  • contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs
🔗 Analysis chain

Ensure all references to generate_transfer_message are updated

The function generate_transfer_message has been renamed to generate_ibc_hook_transfer_message. Please verify that all references to the old function name within the codebase have been updated accordingly to prevent any potential issues.

Run the following script to check for any remaining references to generate_transfer_message:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of `generate_transfer_message` in the codebase

rg --type rust 'generate_transfer_message'

Length of output: 504

@@ -618,7 +618,7 @@ impl MsgHandler {
outgoing_packets.push(outgoing_state);
OUTGOING_IBC_HOOKS_PACKETS.save(deps.storage, &outgoing_packets)?;

let msg = generate_transfer_message(
let msg = generate_ibc_hook_transfer_message(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider reducing unnecessary cloning to improve performance

In the call to generate_ibc_hook_transfer_message, several clones are performed that might be unnecessary. Cloning can incur performance overhead, especially in tight loops or frequently called functions. Where possible, pass references instead of cloning values.

Apply this diff to reduce unnecessary cloning:

             let msg = generate_ibc_hook_transfer_message(
-                &deps.as_ref(),
-                recipient.clone(),
-                message.clone(),
-                msg_funds.clone(),
-                channel.clone(),
-                env.contract.address.to_string(),
-                channel_info.kernel_address.clone(),
+                deps.as_ref(),
+                &recipient,
+                &message,
+                msg_funds.clone(), // cloning might be necessary here
+                &channel,
+                env.contract.address.as_str(),
+                &channel_info.kernel_address,
                 env.block.time,
             )?;

Explanation:

  • Pass references for recipient, message, channel, and channel_info.kernel_address instead of cloning.
  • Use env.contract.address.as_str() to avoid allocating a new String.
  • Ensure that generate_ibc_hook_transfer_message accepts references for these parameters.

Committable suggestion was skipped due to low confidence.

Comment on lines +356 to +376
/// Handles all IBC Registry queries.
///
/// Returns `"ADOType"` for `ADOType` queries with code ID 1 and an error otherwise.
///
/// Returns an error for `CodeId` queries with key `FAKE_ADODB_KEY` and 1 otherwise.
fn handle_ibc_registry_query(&self, msg: &Binary) -> QuerierResult {
match from_json(msg).unwrap() {
IBCRegistryQueryMsg::DenomInfo { denom } => match denom.as_str() {
MOCK_OSMO_IBC_DENOM_ON_ANDR => SystemResult::Ok(ContractResult::Ok(
to_json_binary(&DenomInfo {
path: MOCK_OSMO_IBC_PATH.to_string(),
base_denom: MOCK_OSMO_NATIVE_DENOM.to_string(),
})
.unwrap(),
)),
_ => SystemResult::Ok(ContractResult::Err("Invalid Denom".to_string())),
},
_ => SystemResult::Ok(ContractResult::Err("Not implemented".to_string())),
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect function documentation in handle_ibc_registry_query

The documentation comments for handle_ibc_registry_query are incorrect and appear to be copied from another function. The comments mention ADOType and CodeId queries, which are not relevant to this function.

Please update the documentation to accurately describe the functionality of handle_ibc_registry_query. For example:

356-    /// Handles all IBC Registry queries.
357-
358-    /// Returns `"ADOType"` for `ADOType` queries with code ID 1 and an error otherwise.
359-
360-    /// Returns an error for `CodeId` queries with key `FAKE_ADODB_KEY` and 1 otherwise.
+    /// Handles all IBC Registry queries.
+
+    /// Returns `DenomInfo` for valid denominations and an error for invalid denominations.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Handles all IBC Registry queries.
///
/// Returns `"ADOType"` for `ADOType` queries with code ID 1 and an error otherwise.
///
/// Returns an error for `CodeId` queries with key `FAKE_ADODB_KEY` and 1 otherwise.
fn handle_ibc_registry_query(&self, msg: &Binary) -> QuerierResult {
match from_json(msg).unwrap() {
IBCRegistryQueryMsg::DenomInfo { denom } => match denom.as_str() {
MOCK_OSMO_IBC_DENOM_ON_ANDR => SystemResult::Ok(ContractResult::Ok(
to_json_binary(&DenomInfo {
path: MOCK_OSMO_IBC_PATH.to_string(),
base_denom: MOCK_OSMO_NATIVE_DENOM.to_string(),
})
.unwrap(),
)),
_ => SystemResult::Ok(ContractResult::Err("Invalid Denom".to_string())),
},
_ => SystemResult::Ok(ContractResult::Err("Not implemented".to_string())),
}
}
/// Handles all IBC Registry queries.
///
/// Returns `DenomInfo` for valid denominations and an error for invalid denominations.
fn handle_ibc_registry_query(&self, msg: &Binary) -> QuerierResult {
match from_json(msg).unwrap() {
IBCRegistryQueryMsg::DenomInfo { denom } => match denom.as_str() {
MOCK_OSMO_IBC_DENOM_ON_ANDR => SystemResult::Ok(ContractResult::Ok(
to_json_binary(&DenomInfo {
path: MOCK_OSMO_IBC_PATH.to_string(),
base_denom: MOCK_OSMO_NATIVE_DENOM.to_string(),
})
.unwrap(),
)),
_ => SystemResult::Ok(ContractResult::Err("Invalid Denom".to_string())),
},
_ => SystemResult::Ok(ContractResult::Err("Not implemented".to_string())),
}
}

Comment on lines +95 to +111
// Add IBC Channels to mocket
custom_querier.base.update_ibc(
TRANSFER_PORT,
&[IbcChannel::new(
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_ANDR_TO_OSMO_IBC_CHANNEL.to_string(),
},
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_OSMO_TO_ANDR_IBC_CHANNEL.to_string(),
},
IbcOrder::Unordered,
IBC_VERSION.to_string(),
String::from("connection-0"),
)],
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typo in comment and verify correct setup of IBC channels

There is a typo in the comment on line 95~: "mocket" should be "mock". The code correctly sets up the IBC channels in the mock querier, which is vital for testing IBC functionalities.

Apply this diff to fix the typo:

95-        // Add IBC Channels to mocket
95+        // Add IBC Channels to mock
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Add IBC Channels to mocket
custom_querier.base.update_ibc(
TRANSFER_PORT,
&[IbcChannel::new(
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_ANDR_TO_OSMO_IBC_CHANNEL.to_string(),
},
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_OSMO_TO_ANDR_IBC_CHANNEL.to_string(),
},
IbcOrder::Unordered,
IBC_VERSION.to_string(),
String::from("connection-0"),
)],
);
// Add IBC Channels to mock
custom_querier.base.update_ibc(
TRANSFER_PORT,
&[IbcChannel::new(
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_ANDR_TO_OSMO_IBC_CHANNEL.to_string(),
},
IbcEndpoint {
port_id: TRANSFER_PORT.to_string(),
channel_id: MOCK_OSMO_TO_ANDR_IBC_CHANNEL.to_string(),
},
IbcOrder::Unordered,
IBC_VERSION.to_string(),
String::from("connection-0"),
)],
);

@@ -3,6 +3,7 @@ pub mod messages;
pub mod recipient;

pub const ADO_DB_KEY: &str = "adodb";
pub const IBC_REGISTRY_KEY: &str = "ibc-registry";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

#[cfg(test)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a test module like so:

#[cfg(test)]
mod tests {
 use super::*;
 
  #[test]
  fn test_get_counterparty_denom() {
  // ...
  }
}


#[cfg(test)]
#[test]
fn test_get_counterparty_denom() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a test case based approach might be better

packages/std/src/os/ibc_registry.rs Show resolved Hide resolved
@@ -139,3 +190,57 @@ fn test_validate_denom() {
let valid_denom = default_denom_info.get_ibc_denom();
verify_denom(&valid_denom, &default_denom_info).unwrap()
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above with the test module

contracts/os/andromeda-kernel/src/ibc.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants