Skip to content

Commit

Permalink
chore(v1): add tests for mining.subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicat committed Jun 1, 2024
1 parent 23a62e7 commit 48f53d4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions protocols/v1/src/methods/client_to_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,36 @@ fn test_version_extension_with_no_bit_count() {
_ => panic!(),
};
}

#[test]
fn test_mining_subscribe_even_sized_extranonce() {
let client_message = r#"{"id":0,
"method": "mining.subscribe",
"params": ["user agent/version", "aaeeffdd"]
}"#;
let client_message: StandardRequest = serde_json::from_str(&client_message).unwrap();
Subscribe::try_from(client_message).unwrap();
}

#[test]
fn test_mining_subscribe_odd_sized_extranonce() {
let client_message = r#"{"id":0,
"method": "mining.subscribe",
"params": ["user agent/version", "aeeffdd"]
}"#;
let client_message: StandardRequest = serde_json::from_str(&client_message).unwrap();
Subscribe::try_from(client_message).unwrap();
}

#[test]
#[should_panic(
expected = "called `Result::unwrap()` on an `Err` value: HexError(InvalidHexCharacter { c: 'z', index: 0 })"
)]
fn test_mining_subscribe_invalid_extranonce() {
let client_message = r#"{"id":0,
"method": "mining.subscribe",
"params": ["user agent/version", "zxczxc"]
}"#;
let client_message: StandardRequest = serde_json::from_str(&client_message).unwrap();
Subscribe::try_from(client_message).unwrap();
}

0 comments on commit 48f53d4

Please sign in to comment.