diff --git a/src/protocols/light_client/peers.rs b/src/protocols/light_client/peers.rs index 86b3674..314bf68 100644 --- a/src/protocols/light_client/peers.rs +++ b/src/protocols/light_client/peers.rs @@ -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, diff --git a/src/tests/protocols/light_client/mod.rs b/src/tests/protocols/light_client/mod.rs index 5b41df5..623ad99 100644 --- a/src/tests/protocols/light_client/mod.rs +++ b/src/tests/protocols/light_client/mod.rs @@ -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 + )] + ); } }