Skip to content

Commit

Permalink
Add channelId to websocket event (#1605)
Browse files Browse the repository at this point in the history
Thanks to recent changes, the channelId is available in ChannelStateChanged.
We now propagate this information to websocket channel events.
  • Loading branch information
t-bast authored Dec 7, 2020
1 parent 8cfa3f5 commit a2a980c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class ChannelEventSerializer extends CustomSerializer[ChannelEvent](_ => ( {
)
case e: ChannelStateChanged => JObject(
JField("type", JString("channel-state-changed")),
JField("channelId", JString(e.channelId.toHex)),
JField("remoteNodeId", JString(e.remoteNodeId.toString())),
JField("previousState", JString(e.previousState.toString)),
JField("currentState", JString(e.currentState.toString))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
system.eventStream.publish(chcr)
wsClient.expectMessage(expectedSerializedChcr)

val chsc = ChannelStateChanged(system.deadLetters, null, system.deadLetters, bobNodeId, OFFLINE, NORMAL, null)
val expectedSerializedChsc = """{"type":"channel-state-changed","remoteNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","previousState":"OFFLINE","currentState":"NORMAL"}"""
val chsc = ChannelStateChanged(system.deadLetters, ByteVector32.One, system.deadLetters, bobNodeId, OFFLINE, NORMAL, null)
val expectedSerializedChsc = """{"type":"channel-state-changed","channelId":"0100000000000000000000000000000000000000000000000000000000000000","remoteNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","previousState":"OFFLINE","currentState":"NORMAL"}"""
assert(serialization.write(chsc) === expectedSerializedChsc)
system.eventStream.publish(chsc)
wsClient.expectMessage(expectedSerializedChsc)
Expand Down

0 comments on commit a2a980c

Please sign in to comment.