-
Notifications
You must be signed in to change notification settings - Fork 516
Closed
Labels
Description
This builds on what is done in #253 and adds some simpler demos as defined in our milestone:
Add a mockHandler that plays ping-pong:
- version is "ping" or "pong" (both acceptable)
- on version negotiation the "Try" side will switch the version (if "ping" requested, counterparty does "pong" and visa versa)
- stores a counter in state (starts at 0)
- Packets are JSON, only valid ones look like
{"ping": 5}
- Receiver will add the value to the local state and return acknowledgement
- Acknowledgement is either
{"error": "message here"}
or{"success": {"pong": 14}}
or whatever the updated state is - On receiving acknowledgement, if a success, then that "remoteState" is stored. If error, increment "numErrors"
This handler has "localState" and "remoteState". Receiving a "ping" packet will increment "localState". Getting a "pong" acknowlegdement will set "remoteState".
Once this is build, a few scenarios:
- Proper connection (show version is swapped from original request), sending packets with coordinators, it works well
- Send
{"random": "data"}
packet and verify we get an"error"
acknowledgement back (numErrors == 1) - Try connecting with invalid version (transfer) and show channel will not get established