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

test: tendermint client update when client expires or validator set has changed #921

Merged
merged 26 commits into from
Oct 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d78333
add client expiry test
rnbguy Oct 13, 2023
90b006d
tm hostblock supports trusted next validator set
rnbguy Oct 13, 2023
6039366
fix validator change update test
rnbguy Oct 13, 2023
a2163f1
fix incorrect validator updates at each block
rnbguy Oct 13, 2023
7dfc285
add sad client update for validator change
rnbguy Oct 13, 2023
78f5eda
cargo fmt
rnbguy Oct 13, 2023
89ffdbf
catch up with main branch changes
rnbguy Oct 16, 2023
2d90996
update MockContextConfig with validator set history
rnbguy Oct 16, 2023
ef774cc
refactor tests with updated MockContextConfig
rnbguy Oct 16, 2023
2750e90
rm duplicate def of `on`
rnbguy Oct 16, 2023
25b9b4d
add todo for max_history_size and validator_set_history
rnbguy Oct 16, 2023
f05537a
consistent variable naming in tests
rnbguy Oct 17, 2023
e827067
bump typed-builder version
rnbguy Oct 17, 2023
bf55a97
rm redundant builder arguments
rnbguy Oct 17, 2023
87196d3
replace todo with panic
rnbguy Oct 17, 2023
122a570
mv Tendermint ClientStateConfig under ics07
rnbguy Oct 17, 2023
7f7f79f
use ctx_a with ctx_b instead of only ctx
rnbguy Oct 17, 2023
eb8798c
use client_id consistently
rnbguy Oct 17, 2023
6b47dc7
use mocks feature directly in dev-deps
rnbguy Oct 17, 2023
f7cc801
include trusting_period and max_clock_drift in mock light client config
rnbguy Oct 18, 2023
0d2d642
revert advance chain height with timestamp
rnbguy Oct 18, 2023
3020a41
update client expiry test
rnbguy Oct 18, 2023
1d3bba8
add test to check max_clock_drift
rnbguy Oct 18, 2023
554ac48
rm TODO comments in favor of gh issue
rnbguy Oct 18, 2023
0da962b
revert ctx_a renaming
rnbguy Oct 18, 2023
57180f9
add changelog entry
rnbguy Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update client expiry test
rnbguy committed Oct 18, 2023
commit 3020a41c64350624c055e7e97d846371ef92616a
40 changes: 10 additions & 30 deletions crates/ibc/src/core/ics02_client/handler/update_client.rs
Original file line number Diff line number Diff line change
@@ -121,7 +121,6 @@ where

#[cfg(test)]
mod tests {
use core::ops::Add;
use core::str::FromStr;
use core::time::Duration;

@@ -145,7 +144,7 @@ mod tests {
use crate::core::timestamp::Timestamp;
use crate::mock::client_state::{client_type as mock_client_type, MockClientState};
use crate::mock::context::{
AnyClientState, AnyConsensusState, MockClientConfig, MockContext, MockContextConfig,
AnyConsensusState, MockClientConfig, MockContext, MockContextConfig,
};
use crate::mock::header::MockHeader;
use crate::mock::host::{HostBlock, HostType};
@@ -883,7 +882,9 @@ mod tests {

let timestamp = Timestamp::now();

let mut ctx_a = MockContextConfig::builder()
let trusting_period = Duration::from_secs(64);

let mut ctx = MockContextConfig::builder()
.host_id(ChainId::new("mockgaiaA", 1).unwrap())
.latest_height(Height::new(1, 1).unwrap())
.latest_timestamp(timestamp)
@@ -895,39 +896,18 @@ mod tests {
.client_state_height(client_height)
.client_type(tm_client_type())
.latest_timestamp(timestamp)
.trusting_period(trusting_period)
.build(),
);

let mut ctx_b = MockContextConfig::builder()
.host_id(chain_id_b.clone())
.host_type(HostType::SyntheticTendermint)
.latest_height(update_height)
.latest_timestamp(timestamp)
.build();

while ctx.host_timestamp().expect("no error")
< (timestamp + trusting_period).expect("no error")
{
let client_state = match ctx_a.client_state(&client_id).unwrap() {
AnyClientState::Tendermint(tm_client_state) => tm_client_state,
_ => panic!("never fails. not mock client"),
};

let client_trusting_period = client_state.trusting_period;

let future_timestamp = ctx_a
.host_timestamp()
.expect("never fails")
.add(client_trusting_period)
.expect("overflow");

ctx_a.advance_host_chain_height_with_timestamp(future_timestamp);
ctx_b.advance_host_chain_height_with_timestamp(future_timestamp);
ctx.advance_host_chain_height();
}

let client_state = ctx_a.client_state(&client_id).unwrap();
let client_state = ctx.client_state(&client_id).unwrap();

assert!(client_state
.status(&ctx_a, &client_id)
.unwrap()
.is_expired());
assert!(client_state.status(&ctx, &client_id).unwrap().is_expired());
}
}