Skip to content

Commit

Permalink
Customizable sleep time for packet relay in ibc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed May 28, 2024
1 parent c792d05 commit d778188
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions crates/tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;
check_balances(&port_id_b, &channel_id_b, &test_a, &test_b)?;

// Transfer 50000 received over IBC on Chain B
Expand Down Expand Up @@ -257,7 +257,7 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;
check_balances_after_back(&port_id_b, &channel_id_b, &test_a, &test_b)?;

// Send a token to the shielded address on Chain A
Expand All @@ -284,7 +284,7 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;
check_shielded_balances(&port_id_b, &channel_id_b, &test_a, &test_b)?;

// Shielded transfer to an invalid receiver address (refund)
Expand All @@ -301,7 +301,7 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;
// The balance should not be changed
check_shielded_balances(&port_id_b, &channel_id_b, &test_a, &test_b)?;

Expand Down Expand Up @@ -330,7 +330,7 @@ fn run_ledger_ibc_with_hermes() -> Result<()> {
let hermes = run_hermes(&test_a)?;
let _bg_hermes = hermes.background();

wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;
// The balance should not be changed
check_shielded_balances(&port_id_b, &channel_id_b, &test_a, &test_b)?;

Expand Down Expand Up @@ -388,7 +388,7 @@ fn ibc_namada_gaia() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test, None)?;

// Check the received token on Gaia
let token_addr = find_address(&test, APFEL)?;
Expand All @@ -406,7 +406,7 @@ fn ibc_namada_gaia() -> Result<()> {
&port_id_gaia,
&channel_id_gaia,
)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test, None)?;

// Check the token on Namada
check_balance(&test, ALBERT, APFEL, 999900)?;
Expand All @@ -422,7 +422,7 @@ fn ibc_namada_gaia() -> Result<()> {
&port_id_gaia,
&channel_id_gaia,
)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test, None)?;

// Check the token on Namada
let ibc_denom = format!("{port_id_namada}/{channel_id_namada}/{GAIA_COIN}");
Expand All @@ -443,7 +443,7 @@ fn ibc_namada_gaia() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test, None)?;
// Check the received token on Gaia
check_gaia_balance(&test_gaia, GAIA_USER, GAIA_COIN, 900)?;

Expand All @@ -457,7 +457,7 @@ fn ibc_namada_gaia() -> Result<()> {
&port_id_gaia,
&channel_id_gaia,
)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test_gaia)?;
wait_for_packet_relay(&port_id_gaia, &channel_id_gaia, &test_gaia, None)?;

// Check the token on Namada
let ibc_denom = format!("{port_id_namada}/{channel_id_namada}/{GAIA_COIN}");
Expand Down Expand Up @@ -489,7 +489,7 @@ fn ibc_namada_gaia() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test, None)?;
check_balance(&test, AB_VIEWING_KEY, &ibc_denom, 40)?;
check_gaia_balance(&test_gaia, GAIA_USER, GAIA_COIN, 810)?;

Expand Down Expand Up @@ -648,7 +648,7 @@ fn proposal_ibc_token_inflation() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, Some(20))?;

// wait the next epoch to dispense the rewrad
wait_epochs(&test_b, MASP_EPOCH_MULTIPLIER)?;
Expand Down Expand Up @@ -780,7 +780,7 @@ fn ibc_rate_limit() -> Result<()> {
None,
false,
)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a)?;
wait_for_packet_relay(&port_id_a, &channel_id_a, &test_a, None)?;

// Check the balance on Chain B
let ibc_denom = format!("{port_id_b}/{channel_id_b}/nam");
Expand Down Expand Up @@ -981,6 +981,7 @@ fn wait_for_packet_relay(
port_id: &PortId,
channel_id: &ChannelId,
test: &Test,
seconds: Option<u64>,
) -> Result<()> {
let args = [
"--json",
Expand All @@ -995,7 +996,7 @@ fn wait_for_packet_relay(
channel_id.as_str(),
];
for _ in 0..10 {
sleep(10);
sleep(seconds.unwrap_or(10));
let mut hermes = run_hermes_cmd(test, args, Some(40))?;
// Check no pending packet
if hermes
Expand Down

0 comments on commit d778188

Please sign in to comment.