-
Notifications
You must be signed in to change notification settings - Fork 326
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
Test clear_packet
behavior
#1881
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4525967
Cleaned up clear_packets logic from RelayPath.
adizere 70f0642
changelog
adizere 0f9e32d
Test on ordered channel relaying behavior
soareschen 9bcd6d3
Merge remote-tracking branch 'origin/adi/1872' into soares/ordered-ch…
soareschen a98aaf2
Test now shows correct behavior
soareschen 55be646
Change test names to target clear_packet test
soareschen c050643
Merge remote-tracking branch 'origin/master' into soares/ordered-chan…
soareschen c37a5a2
Add tools/ directory to CI trigger
soareschen 41e9522
Add tools/ directory to integration-test CI trigger
soareschen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
- Fixed bug where Hermes cleared packets at startup, despite | ||
`clear_on_start = false` ([#1872](https://github.com/informalsystems/ibc-rs/issues/1872)) | ||
`clear_on_start = false` ([#1872](https://github.com/informalsystems/ibc-rs/issues/1872)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
use ibc_relayer::supervisor::{spawn_supervisor, SupervisorHandle, SupervisorOptions}; | ||
|
||
use crate::ibc::denom::derive_ibc_denom; | ||
use crate::prelude::*; | ||
use crate::util::random::random_u64_range; | ||
|
||
#[test] | ||
fn test_clear_packet() -> Result<(), Error> { | ||
run_binary_channel_test(&ClearPacketTest) | ||
} | ||
pub struct ClearPacketTest; | ||
|
||
impl TestOverrides for ClearPacketTest { | ||
fn modify_relayer_config(&self, config: &mut Config) { | ||
// Disabling clear_on_start should make the relayer not | ||
// relay any packet it missed before starting. | ||
config.mode.packets.clear_on_start = false; | ||
config.mode.packets.clear_interval = 0; | ||
} | ||
|
||
// Do not start supervisor at the beginning of test | ||
fn spawn_supervisor( | ||
&self, | ||
_config: &SharedConfig, | ||
_registry: &SharedRegistry<impl ChainHandle>, | ||
) -> Result<Option<SupervisorHandle>, Error> { | ||
Ok(None) | ||
} | ||
} | ||
|
||
impl BinaryChannelTest for ClearPacketTest { | ||
fn run<ChainA: ChainHandle, ChainB: ChainHandle>( | ||
&self, | ||
_config: &TestConfig, | ||
chains: ConnectedChains<ChainA, ChainB>, | ||
channel: ConnectedChannel<ChainA, ChainB>, | ||
) -> Result<(), Error> { | ||
let denom_a = chains.node_a.denom(); | ||
|
||
let wallet_a = chains.node_a.wallets().user1().cloned(); | ||
let wallet_b = chains.node_b.wallets().user1().cloned(); | ||
|
||
let balance_a = chains | ||
.node_a | ||
.chain_driver() | ||
.query_balance(&wallet_a.address(), &denom_a)?; | ||
|
||
let amount1 = random_u64_range(1000, 5000); | ||
|
||
info!( | ||
"Performing IBC transfer with amount {}, which should *not* be relayed", | ||
amount1 | ||
); | ||
|
||
chains.node_a.chain_driver().transfer_token( | ||
&channel.port_a.as_ref(), | ||
&channel.channel_id_a.as_ref(), | ||
&wallet_a.address(), | ||
&wallet_b.address(), | ||
amount1, | ||
&denom_a, | ||
)?; | ||
|
||
sleep(Duration::from_secs(1)); | ||
|
||
// Spawn the supervisor only after the first IBC trasnfer | ||
let _supervisor = spawn_supervisor( | ||
chains.config.clone(), | ||
chains.registry.clone(), | ||
None, | ||
SupervisorOptions { | ||
health_check: false, | ||
force_full_scan: false, | ||
}, | ||
)?; | ||
|
||
sleep(Duration::from_secs(1)); | ||
|
||
let amount2 = random_u64_range(1000, 5000); | ||
|
||
info!( | ||
"Performing IBC transfer with amount {}, which should be relayed", | ||
amount2 | ||
); | ||
|
||
chains.node_a.chain_driver().transfer_token( | ||
&channel.port_a.as_ref(), | ||
&channel.channel_id_a.as_ref(), | ||
&wallet_a.address(), | ||
&wallet_b.address(), | ||
amount2, | ||
&denom_a, | ||
)?; | ||
|
||
sleep(Duration::from_secs(1)); | ||
|
||
let denom_b = derive_ibc_denom( | ||
&channel.port_b.as_ref(), | ||
&channel.channel_id_b.as_ref(), | ||
&denom_a, | ||
)?; | ||
|
||
// Wallet on chain A should have both amount deducted. | ||
chains.node_a.chain_driver().assert_eventual_wallet_amount( | ||
&wallet_a.as_ref(), | ||
balance_a - amount1 - amount2, | ||
&denom_a, | ||
)?; | ||
|
||
// Wallet on chain B should only receive the second IBC transfer | ||
chains.node_b.chain_driver().assert_eventual_wallet_amount( | ||
&wallet_b.as_ref(), | ||
amount2, | ||
&denom_b.as_ref(), | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is pretty neat being able to capture this advanced case in such a simple way.