Open reactive-firewall opened 1 month ago
🤔 how can we design this feature or features to be SOLID and account for the ability to use different handlers for the HEAR server to handle each and possibly other custom handlers from client code.
The transcoding should be as simple as described above in the description.
To retrieve the hex string from the process
p
in this test function, you can capture the standard output of the receiver process and reconstruct the binary data. Here's how you can modify your test function:1. Modify the Receiver to Output the Hex String:
Ensure that the receiver process is configured to print the received message in hexadecimal format to
stdout
. You may need to adjust the receiver function in yourmulticast
module to do this.2. Update the Test Function to Capture
stdout
:When starting the receiver process in your test, set
stdout=subprocess.PIPE
to capture the output.3. Send the Message and Capture the Output:
After sending the message from the sender, wait for the receiver process to finish and then read the captured output.
4. Reconstruct the Binary Data from the Hex String:
Decode the hex string received from the receiver process back into binary data.
5. Verify that the Sent and Received Data Match:
Add an assertion to verify that the original data matches the data received by the receiver process.
Complete Modified Test Function:
Notes:
stdout
usingsubprocess.PIPE
, you can read the output directly from the receiver process.stderr
for debugging purposes.Example Using Base64 Encoding (Optional):
Sender Side:
Receiver Side:
Test Function Adjustments:
Benefits of Base64 Encoding:
Let me know if you have any questions or need further assistance!
🧠 Learnings used
``` Learnt from: reactive-firewall PR: reactive-firewall/multicast#110 File: docs/CI.md:32-32 Timestamp: 2024-09-17T06:40:42.918Z Learning: Reactive-firewall prefers to keep the word "own" in headings when emphasizing the reader's personal test. ``` --- ``` Learnt from: reactive-firewall PR: reactive-firewall/multicast#110 File: docs/USAGE.md:66-66 Timestamp: 2024-09-17T03:38:28.677Z Learning: Reactive-firewall prefers to use "Caveat" as a heading instead of "Caution". ``` --- ``` Learnt from: reactive-firewall PR: reactive-firewall/multicast#118 File: tests/check_pip:92-197 Timestamp: 2024-09-24T01:03:10.574Z Learning: Reactive-firewall prefers defining functions before they are called in Bash scripts to avoid errors due to Bash's sequential interpretation. ```_Originally posted by @coderabbitai[bot] in https://github.com/reactive-firewall/multicast/pull/139#discussion_r1780693414_