Skip to content

Commit

Permalink
Change MG test with flag filter logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourya742 committed Jul 18, 2024
1 parent aadd32d commit 906a6a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
19 changes: 6 additions & 13 deletions protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ impl<'decoder> SetupConnection<'decoder> {
let requires_async_job_mining_passed = (required >> 31) & 1 > 0;
let requires_async_job_mining_self = (available >> 31) & 1 > 0;

let specific_flags_check =
!requires_async_job_mining_self || requires_async_job_mining_passed;
let general_flags_check = (available & required) == required;

specific_flags_check && general_flags_check
match (requires_async_job_mining_self, requires_async_job_mining_passed) {
(true, true) => true,
(true, false) => true,
(false, true) => false,
(false, false) => true,
}
}
Protocol::TemplateDistributionProtocol | Protocol::JobDistributionProtocol => {
// These protocols do not define flags for setting up a connection.
Expand Down Expand Up @@ -423,14 +424,6 @@ mod test {
available_flags,
required_flags
));

let available_flags = 0b_0000_0000_0000_0000_0000_0000_0000_0000;
let required_flags = 0b_1000_0000_0000_0000_0000_0000_0000_0000;
assert!(!SetupConnection::check_flags(
protocol,
available_flags,
required_flags
));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion roles/jd-server/src/lib/job_declarator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ impl JobDeclarator {
let flag = setup_connection.flags;
let is_valid = SetupConnection::check_flags(
Protocol::JobDeclarationProtocol,
flag,
1,
flag,
);

if is_valid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
"role": "client",
"results": [
{
"type": "match_message_type",
"value": "0x02"
"type": "match_message_field",
"value": [
"CommonMessages",
"SetupConnectionSuccess",
[
[
"flags",
{"U32": 1}
]
]
]
}
],
"actiondoc": "This action sends SetupConnection and checks that .Error"
Expand Down

0 comments on commit 906a6a5

Please sign in to comment.