Skip to content

Commit

Permalink
fix: refresh last state even no proved state, again
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape committed Jan 8, 2024
1 parent 7837fa2 commit 030c0e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/protocols/light_client/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ impl PeerState {
let new_state = Self::RequestFirstLastState { when_sent };
Ok(new_state)
}
Self::OnlyHasLastState { .. } => Ok(self),
Self::Ready {
last_state,
prove_state,
Expand Down
17 changes: 15 additions & 2 deletions src/tests/protocols/light_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,20 @@ async fn refresh_all_peers() {

protocol.notify(nc.context(), REFRESH_PEERS_TOKEN).await;

// TODO FIXME A request `GetLastState` should be sent.
assert!(nc.sent_messages().borrow().is_empty());
let content = packed::GetLastState::new_builder()
.subscribe(true.pack())
.build();
let get_last_state_message = packed::LightClientMessage::new_builder()
.set(content)
.build()
.as_bytes();
assert_eq!(
nc.sent_messages().borrow().clone(),
vec![(
SupportProtocols::LightClient.protocol_id(),
peer_index,
get_last_state_message
)]
);
}
}

0 comments on commit 030c0e4

Please sign in to comment.