Skip to content

Commit

Permalink
fix: error on duplicate packet (#790)
Browse files Browse the repository at this point in the history
* fix: error on duplicate packet

* chore: bump patch

* chore: fix lint

* fix: test

* chore: pass build
  • Loading branch information
ibrizsabin authored Nov 28, 2023
1 parent 5d2b31f commit 7291763
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exclude = ["contracts/cosmwasm-vm/archway"]
[workspace.package]
authors = ["Icon Foundation<[email protected]>"]
repository = "https://github.com/icon-project/ibc-integration.git"
version="0.1.0"
version="0.1.1"

[workspace.dependencies]
cosmwasm-std = {version="1.2.2",default-features = false,features = ["iterator", "ibc3","staking"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ impl<'a> CwIbcCoreContext<'a> {
packet_sequence,
)?;
if packet_already_received {
return Ok(Response::new().add_attribute("message", "Packet already received"));
return Err(ContractError::IbcPacketError {
error: PacketError::Other("Already Received".to_string()),
});
}

let connection_id = &channel_end.connection_hops()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ fn test_receive_packet_fails_on_invalid_counterparty() {
);
}

#[should_panic(expected = "IbcPacketError { error: Other(\"Already Received\") }")]
#[test]
fn test_receive_packet_no_op_on_packet_already_received() {
let contract = CwIbcCoreContext::default();
Expand Down Expand Up @@ -264,12 +265,9 @@ fn test_receive_packet_no_op_on_packet_already_received() {

mock_lightclient_query(test_context.mock_queries, &mut deps);

let res = contract.validate_receive_packet(deps.as_mut(), info, env, &msg);

assert_eq!(
res.unwrap().attributes[0].value,
"Packet already received".to_string()
)
let _res = contract
.validate_receive_packet(deps.as_mut(), info, env, &msg)
.unwrap();
}
#[test]
fn execute_receive_packet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ impl<'a> CwIbcConnection<'a> {
self.ensure_xcall_handler(deps.as_ref().storage, info.sender.clone())?;
println!("{LOG_PREFIX} Packet Validated");

let network_fee = self.get_network_fees(deps.as_ref().storage, nid.clone());
let network_fee = self.get_network_fees(deps.as_ref().storage, nid);
let mut total_fee = network_fee.send_packet_fee;

if sn > 0 {
total_fee = total_fee + network_fee.ack_fee;
total_fee += network_fee.ack_fee;
}
let config = self.get_config(deps.storage)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<'a> CwIbcConnection<'a> {
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
let owner = info.clone().sender;
let owner = info.sender;

self.add_owner(store, owner.clone())?;
self.update_admin(store, owner)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ mod account;
mod setup;
use account::*;

use cosmwasm_std::Addr;
use cw_xcall_ibc_connection::state::CwIbcConnection;
use setup::*;
#[test]
Expand Down

0 comments on commit 7291763

Please sign in to comment.