Skip to content

Commit

Permalink
get_event is sued to query for the first empty response too
Browse files Browse the repository at this point in the history
  • Loading branch information
liamsi committed May 23, 2020
1 parent ff97e71 commit 52b6ce4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tendermint/src/rpc/event_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl EventListener {
}

/// Get the next event from the websocket
pub async fn get_event(&mut self) -> Result<TMEventData, Box<dyn stdError>> {
pub async fn get_event(&mut self) -> Result<Option<TMEventData>, Box<dyn stdError>> {
let msg = self
.socket
.next()
Expand Down Expand Up @@ -111,9 +111,9 @@ pub enum TMEventData {
/// Event data from a subscription
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ResultEvent {
query: String,
data: TMEventData,
events: HashMap<String, Vec<String>>,
query: Option<String>,
data: Option<TMEventData>,
events: Option<HashMap<String, Vec<String>>>,
}
impl response::Response for ResultEvent {}

Expand Down
3 changes: 2 additions & 1 deletion tendermint/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ mod rpc {
// client.subscribe("tm.event='NewBlock'".to_owned()).await.unwrap();

// Collect and throw away the response to subscribe
client.get_event().await.unwrap();
let empty = client.get_event().await.unwrap();
assert!(empty.is_none());

// Loop here is helpful when debugging parsing of JSON events
// loop{
Expand Down

0 comments on commit 52b6ce4

Please sign in to comment.