Skip to content

Commit

Permalink
Standardize test addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 19, 2024
1 parent b6cbd09 commit 6bc62c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
12 changes: 8 additions & 4 deletions crates/packet-forward/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,13 @@ fn events_kept_on_errors() {
push_event_attr(
&mut attributes,
"escrow-account".to_owned(),
"Barbara".to_string(),
addresses::ESCROW_ACCOUNT.to_string(),
);
push_event_attr(
&mut attributes,
"sender".to_owned(),
addresses::A.to_string(),
);
push_event_attr(&mut attributes, "sender".to_owned(), "Bob".to_string());
push_event_attr(
&mut attributes,
"receiver".to_owned(),
Expand All @@ -238,8 +242,8 @@ fn events_kept_on_errors() {
&mut extras,
Left((&packet, packet_data)),
fwd_metadata,
String::from("Bob").into(),
String::from("Barbara").into(),
addresses::A.to_string().into(),
addresses::ESCROW_ACCOUNT.to_string().into(),
coin_on_this_chain,
),
);
Expand Down
21 changes: 15 additions & 6 deletions crates/packet-forward/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ use ibc_testkit::testapp::ibc::applications::transfer::types::DummyTransferModul

use super::*;

pub mod addresses {
pub const A: &str = "a1arndt";
#[allow(dead_code)]
pub const B: &str = "b1bertha";
pub const C: &str = "c1copernicus";

pub const NULL: &str = "NULL";
pub const ESCROW_ACCOUNT: &str = "ibc-ics20-escrow-account";
}

// NOTE: Assume we have three chains: A, B, and C. The tests will be set
// up as if we were chain B, forwarding a packet from A to C.
pub mod channels {
Expand All @@ -27,8 +37,6 @@ pub mod base_denoms {
pub const C: &str = "uchungus";
}

pub const ESCROW_ACCOUNT: &str = "ibc-ics20-escrow-account";

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum FailurePoint {
BeforeSendTransfer,
Expand Down Expand Up @@ -340,7 +348,7 @@ impl<M> PfmContext for Store<M> {
_channel: &ChannelId,
_original_sender: &Signer,
) -> Result<Signer, Self::Error> {
Ok(ESCROW_ACCOUNT.to_string().into())
Ok(addresses::ESCROW_ACCOUNT.to_string().into())
}

fn timeout_timestamp(
Expand Down Expand Up @@ -516,8 +524,9 @@ pub fn get_dummy_packet_data_with_fwd_meta(

pub fn get_dummy_packet_data_with_memo(transfer_amount: u64, memo: String) -> PacketData {
PacketData {
sender: String::from("PACKET-SENDER").into(),
receiver: String::from("PACKET-RECEIVER").into(),
sender: addresses::A.to_string().into(),
// NB: the ICS-20 receiver field is overriden
receiver: addresses::NULL.to_string().into(),
token: get_dummy_coin(transfer_amount),
memo: memo.into(),
}
Expand All @@ -542,7 +551,7 @@ pub fn get_dummy_packet_with_data(seq: u64, packet_data: &PacketData) -> Packet

pub fn get_dummy_fwd_metadata() -> msg::ForwardMetadata {
msg::ForwardMetadata {
receiver: String::from("receiver-on-c").into(),
receiver: addresses::C.to_string().into(),
port: PortId::transfer(),
channel: ChannelId::new(channels::BC),
timeout: None,
Expand Down

0 comments on commit 6bc62c8

Please sign in to comment.