Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow altering messages exchanged by roles in test env #1228

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jbesraa
Copy link
Contributor

@jbesraa jbesraa commented Oct 18, 2024

resolves #1227

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 19.36%. Comparing base (73f51db) to head (bf97853).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1228   +/-   ##
=======================================
  Coverage   19.36%   19.36%           
=======================================
  Files         164      164           
  Lines       10811    10811           
=======================================
  Hits         2094     2094           
  Misses       8717     8717           
Flag Coverage Δ
binary_codec_sv2-coverage 0.00% <ø> (ø)
binary_serde_sv2-coverage 3.65% <ø> (ø)
binary_sv2-coverage 5.46% <ø> (ø)
bip32_derivation-coverage 0.00% <ø> (ø)
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <ø> (ø)
common_messages_sv2-coverage 0.13% <ø> (ø)
const_sv2-coverage 0.00% <ø> (ø)
error_handling-coverage 0.00% <ø> (ø)
framing_sv2-coverage 0.29% <ø> (ø)
jd_client-coverage 0.00% <ø> (ø)
jd_server-coverage 8.13% <ø> (ø)
job_declaration_sv2-coverage 0.00% <ø> (ø)
key-utils-coverage 2.39% <ø> (ø)
mining-coverage 2.51% <ø> (ø)
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage 4.35% <ø> (ø)
pool_sv2-coverage 1.38% <ø> (ø)
protocols 24.72% <ø> (ø)
roles 6.63% <ø> (ø)
roles_logic_sv2-coverage 8.06% <ø> (ø)
sv1-mining-device-coverage 0.00% <ø> (ø)
sv2_ffi-coverage 0.00% <ø> (ø)
template_distribution_sv2-coverage 0.00% <ø> (ø)
translator_sv2-coverage 9.61% <ø> (ø)
utils 25.13% <ø> (ø)
v1-coverage 2.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

🐰 Bencher Report

Branch1228/merge
Testbedsv1

⚠️ WARNING: The following Measure does not have a Threshold. Without a Threshold, no Alerts will ever be generated!

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds CLI flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
client-submit-serialize📈 view plot
⚠️ NO THRESHOLD
6,540.80
client-submit-serialize-deserialize📈 view plot
⚠️ NO THRESHOLD
7,579.40
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle📈 view plot
⚠️ NO THRESHOLD
8,181.50
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle📈 view plot
⚠️ NO THRESHOLD
932.93
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize📈 view plot
⚠️ NO THRESHOLD
724.19
client-sv1-authorize-serialize/client-sv1-authorize-serialize📈 view plot
⚠️ NO THRESHOLD
253.31
client-sv1-get-authorize/client-sv1-get-authorize📈 view plot
⚠️ NO THRESHOLD
155.98
client-sv1-get-submit📈 view plot
⚠️ NO THRESHOLD
6,358.60
client-sv1-get-subscribe/client-sv1-get-subscribe📈 view plot
⚠️ NO THRESHOLD
273.47
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle📈 view plot
⚠️ NO THRESHOLD
771.18
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize📈 view plot
⚠️ NO THRESHOLD
634.92
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize📈 view plot
⚠️ NO THRESHOLD
206.43
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

🐰 Bencher Report

Branch1228/merge
Testbedsv2

⚠️ WARNING: The following Measures do not have a Threshold. Without a Threshold, no Alerts will ever be generated!

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds CLI flag.

Click to view all benchmark results
BenchmarkEstimated Cyclesestimated cyclesInstructionsinstructionsL1 AccessesaccessesL2 AccessesaccessesRAM Accessesaccesses
client_sv2_handle_message_common📈 view plot
⚠️ NO THRESHOLD
2,083.00📈 view plot
⚠️ NO THRESHOLD
473.00📈 view plot
⚠️ NO THRESHOLD
738.00📈 view plot
⚠️ NO THRESHOLD
3.00📈 view plot
⚠️ NO THRESHOLD
38.00
client_sv2_handle_message_mining📈 view plot
⚠️ NO THRESHOLD
8,208.00📈 view plot
⚠️ NO THRESHOLD
2,137.00📈 view plot
⚠️ NO THRESHOLD
3,158.00📈 view plot
⚠️ NO THRESHOLD
37.00📈 view plot
⚠️ NO THRESHOLD
139.00
client_sv2_mining_message_submit_standard📈 view plot
⚠️ NO THRESHOLD
6,281.00📈 view plot
⚠️ NO THRESHOLD
1,750.00📈 view plot
⚠️ NO THRESHOLD
2,551.00📈 view plot
⚠️ NO THRESHOLD
18.00📈 view plot
⚠️ NO THRESHOLD
104.00
client_sv2_mining_message_submit_standard_serialize📈 view plot
⚠️ NO THRESHOLD
14,628.00📈 view plot
⚠️ NO THRESHOLD
4,694.00📈 view plot
⚠️ NO THRESHOLD
6,763.00📈 view plot
⚠️ NO THRESHOLD
40.00📈 view plot
⚠️ NO THRESHOLD
219.00
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
27,460.00📈 view plot
⚠️ NO THRESHOLD
10,585.00📈 view plot
⚠️ NO THRESHOLD
15,405.00📈 view plot
⚠️ NO THRESHOLD
80.00📈 view plot
⚠️ NO THRESHOLD
333.00
client_sv2_open_channel📈 view plot
⚠️ NO THRESHOLD
4,387.00📈 view plot
⚠️ NO THRESHOLD
1,461.00📈 view plot
⚠️ NO THRESHOLD
2,157.00📈 view plot
⚠️ NO THRESHOLD
12.00📈 view plot
⚠️ NO THRESHOLD
62.00
client_sv2_open_channel_serialize📈 view plot
⚠️ NO THRESHOLD
13,944.00📈 view plot
⚠️ NO THRESHOLD
5,064.00📈 view plot
⚠️ NO THRESHOLD
7,329.00📈 view plot
⚠️ NO THRESHOLD
35.00📈 view plot
⚠️ NO THRESHOLD
184.00
client_sv2_open_channel_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
22,699.00📈 view plot
⚠️ NO THRESHOLD
8,027.00📈 view plot
⚠️ NO THRESHOLD
11,674.00📈 view plot
⚠️ NO THRESHOLD
77.00📈 view plot
⚠️ NO THRESHOLD
304.00
client_sv2_setup_connection📈 view plot
⚠️ NO THRESHOLD
4,681.00📈 view plot
⚠️ NO THRESHOLD
1,502.00📈 view plot
⚠️ NO THRESHOLD
2,276.00📈 view plot
⚠️ NO THRESHOLD
12.00📈 view plot
⚠️ NO THRESHOLD
67.00
client_sv2_setup_connection_serialize📈 view plot
⚠️ NO THRESHOLD
16,106.00📈 view plot
⚠️ NO THRESHOLD
5,963.00📈 view plot
⚠️ NO THRESHOLD
8,666.00📈 view plot
⚠️ NO THRESHOLD
39.00📈 view plot
⚠️ NO THRESHOLD
207.00
client_sv2_setup_connection_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
35,496.00📈 view plot
⚠️ NO THRESHOLD
14,855.00📈 view plot
⚠️ NO THRESHOLD
21,821.00📈 view plot
⚠️ NO THRESHOLD
96.00📈 view plot
⚠️ NO THRESHOLD
377.00
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

🐰 Bencher Report

Branch1228/merge
Testbedsv2

⚠️ WARNING: The following Measure does not have a Threshold. Without a Threshold, no Alerts will ever be generated!

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds CLI flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
client_sv2_handle_message_common📈 view plot
⚠️ NO THRESHOLD
44.91
client_sv2_handle_message_mining📈 view plot
⚠️ NO THRESHOLD
73.14
client_sv2_mining_message_submit_standard📈 view plot
⚠️ NO THRESHOLD
14.65
client_sv2_mining_message_submit_standard_serialize📈 view plot
⚠️ NO THRESHOLD
267.73
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
592.70
client_sv2_open_channel📈 view plot
⚠️ NO THRESHOLD
147.54
client_sv2_open_channel_serialize📈 view plot
⚠️ NO THRESHOLD
285.45
client_sv2_open_channel_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
376.01
client_sv2_setup_connection📈 view plot
⚠️ NO THRESHOLD
160.54
client_sv2_setup_connection_serialize📈 view plot
⚠️ NO THRESHOLD
456.92
client_sv2_setup_connection_serialize_deserialize📈 view plot
⚠️ NO THRESHOLD
978.28
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

🐰 Bencher Report

Branch1228/merge
Testbedsv1

⚠️ WARNING: The following Measures do not have a Threshold. Without a Threshold, no Alerts will ever be generated!

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds CLI flag.

Click to view all benchmark results
BenchmarkEstimated Cyclesestimated cyclesInstructionsinstructionsL1 AccessesaccessesL2 AccessesaccessesRAM Accessesaccesses
get_authorize📈 view plot
⚠️ NO THRESHOLD
8,515.00📈 view plot
⚠️ NO THRESHOLD
3,772.00📈 view plot
⚠️ NO THRESHOLD
5,295.00📈 view plot
⚠️ NO THRESHOLD
7.00📈 view plot
⚠️ NO THRESHOLD
91.00
get_submit📈 view plot
⚠️ NO THRESHOLD
95,430.00📈 view plot
⚠️ NO THRESHOLD
59,522.00📈 view plot
⚠️ NO THRESHOLD
85,510.00📈 view plot
⚠️ NO THRESHOLD
45.00📈 view plot
⚠️ NO THRESHOLD
277.00
get_subscribe📈 view plot
⚠️ NO THRESHOLD
8,034.00📈 view plot
⚠️ NO THRESHOLD
2,848.00📈 view plot
⚠️ NO THRESHOLD
3,984.00📈 view plot
⚠️ NO THRESHOLD
12.00📈 view plot
⚠️ NO THRESHOLD
114.00
serialize_authorize📈 view plot
⚠️ NO THRESHOLD
12,298.00📈 view plot
⚠️ NO THRESHOLD
5,343.00📈 view plot
⚠️ NO THRESHOLD
7,458.00📈 view plot
⚠️ NO THRESHOLD
9.00📈 view plot
⚠️ NO THRESHOLD
137.00
serialize_deserialize_authorize📈 view plot
⚠️ NO THRESHOLD
24,897.00📈 view plot
⚠️ NO THRESHOLD
9,920.00📈 view plot
⚠️ NO THRESHOLD
14,017.00📈 view plot
⚠️ NO THRESHOLD
34.00📈 view plot
⚠️ NO THRESHOLD
306.00
serialize_deserialize_handle_authorize📈 view plot
⚠️ NO THRESHOLD
30,435.00📈 view plot
⚠️ NO THRESHOLD
12,097.00📈 view plot
⚠️ NO THRESHOLD
17,140.00📈 view plot
⚠️ NO THRESHOLD
55.00📈 view plot
⚠️ NO THRESHOLD
372.00
serialize_deserialize_handle_submit📈 view plot
⚠️ NO THRESHOLD
126,589.00📈 view plot
⚠️ NO THRESHOLD
73,363.00📈 view plot
⚠️ NO THRESHOLD
105,189.00📈 view plot
⚠️ NO THRESHOLD
115.00📈 view plot
⚠️ NO THRESHOLD
595.00
serialize_deserialize_handle_subscribe📈 view plot
⚠️ NO THRESHOLD
28,017.00📈 view plot
⚠️ NO THRESHOLD
9,666.00📈 view plot
⚠️ NO THRESHOLD
13,677.00📈 view plot
⚠️ NO THRESHOLD
61.00📈 view plot
⚠️ NO THRESHOLD
401.00
serialize_deserialize_submit📈 view plot
⚠️ NO THRESHOLD
115,479.00📈 view plot
⚠️ NO THRESHOLD
68,223.00📈 view plot
⚠️ NO THRESHOLD
97,934.00📈 view plot
⚠️ NO THRESHOLD
65.00📈 view plot
⚠️ NO THRESHOLD
492.00
serialize_deserialize_subscribe📈 view plot
⚠️ NO THRESHOLD
23,439.00📈 view plot
⚠️ NO THRESHOLD
8,225.00📈 view plot
⚠️ NO THRESHOLD
11,589.00📈 view plot
⚠️ NO THRESHOLD
39.00📈 view plot
⚠️ NO THRESHOLD
333.00
serialize_submit📈 view plot
⚠️ NO THRESHOLD
99,827.00📈 view plot
⚠️ NO THRESHOLD
61,566.00📈 view plot
⚠️ NO THRESHOLD
88,352.00📈 view plot
⚠️ NO THRESHOLD
48.00📈 view plot
⚠️ NO THRESHOLD
321.00
serialize_subscribe📈 view plot
⚠️ NO THRESHOLD
11,375.00📈 view plot
⚠️ NO THRESHOLD
4,195.00📈 view plot
⚠️ NO THRESHOLD
5,840.00📈 view plot
⚠️ NO THRESHOLD
15.00📈 view plot
⚠️ NO THRESHOLD
156.00
🐰 View full continuous benchmarking report in Bencher

Handle scenario when TP responds with `SetupConnectionError` to a pool
Because we dont want to fail here, but rather fail when we assert the
messages exchanged between the pool and TP(or others)
@jbesraa jbesraa force-pushed the 2024-10-18-allow-sniffer-to-alter-msgs branch from 961caa7 to bf97853 Compare October 31, 2024 07:42
@plebhash
Copy link
Collaborator

after discussing with @jbesraa on the call today, we will potentially pivot this approach towards adding a new primitive (aside to the Sniffer) that is simplified and just "mocks" a dummy role, essentially expecting predefined messages and also responding with predefined messages

@plebhash
Copy link
Collaborator

plebhash commented Oct 31, 2024

(let's assume this new primitive will be called Mock, final name could be changed later)

Mock is created in a way that it has some predefined stack of pair messages, where each pair has:

  • some expected message
  • response to the expected message

this stack is represented as a Vec<(AnyMessage, AnyMessage)>


as discussed in the call, here's a dummy test (pseudocode) that could be used to drive the development of this new primitive, at least from a conceptual perspective

the scenario here is:

  • Mock is created to mimic a TP
  • Sniffer is placed between Pool and Mock
  • Pool sends SetupConnection upstream
    • Sniffer logs SetupConnection into its messages_from_downstream queue
    • Mock is already expecting a SetupConnection
  • Mock replies with SetupConnection.Error
    • Sniffer logs SetupConnection.Error into messages_from_upstream
    • Pool receives SetupConnection.Error
#[tokio::test]
async fn test_tp_mock_setup_connection_error() {
    let mock_tp_addr = common::get_available_address();
    let sniffer_addr = common::get_available_address();
    let pool_addr = common::get_available_address();

    let mock_tp_expected_setup_connection = ...
    let mock_tp_response_setup_connection_error = ...

    let mock_tp_message_pair = (mock_tp_expected_setup_connection, mock_tp_response_setup_connection_error);

    // this is a very simple test where we only have one pair
    // but the generic case could have multiple pairs
    // the order of each (expected, response) pair within the Vec is also important
    let mock_tp_message_pair_vec = vec![mock_tp_message_pair];

    let mut mock = common::start_mock(mock_tp_addr, mock_tp_message_pair_vec).await;

    let sniffer = common::start_sniffer(sniffer_addr, mock_tp_addr).await;
    let pool = common::start_pool(Some(pool_addr), Some(sniffer_addr)).await;

    assert_common_message!(&sniffer.next_downstream_message(), SetupConnection);

    // this specific assertion is essentially proving that mock_tp is behaving as expected
    assert_common_message!(&sniffer.next_upstream_message(), SetupConnectionError);

   // here it could be interesting to assert the internal state of pool after receiveing SetupConnectionError
   // but essentially this is somewhat outside of the scope of this PR, since we just want to add a new primitive to the IT framework and not necessarily improve testing around the pool role implementation
   // if this assertion proves too challenging, it can be left for some future work
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functionality to response to a role with alterd message in integration tests
2 participants