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 Apr 24, 2024
1 parent d3d8d82 commit 9965470
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 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,35 @@ 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 9965470

Please sign in to comment.