Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions integration_test/tests/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ fn mining__get_block_template__modelled() {
#[test]
fn mining__get_mining_info() {
let node = Node::with_wallet(Wallet::Default, &[]);
node.fund_wallet();

let json: GetMiningInfo = node.client.get_mining_info().expect("rpc");

// Up to v28 (i.e., not 29_0) there is no error converting into model.
#[cfg(feature = "v28_and_below")]
let _: mtype::GetMiningInfo = json.into_model();
let model: mtype::GetMiningInfo = json.into_model();

// v29 onwards
#[cfg(not(feature = "v28_and_below"))]
{
let model: Result<mtype::GetMiningInfo, GetMiningInfoError> = json.into_model();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to keep this line with the explicit Result type. The reason we do this is to ensure that we exported all the error types correctly. In the past before we did this we forgot a bunch of them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR most of the 'weird' stuff here is for a specific reason, not always obvious. Feel free to ask about anything that looks odd. Also if anything is non-uniform them we probably made a mistake - it happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, thanks for the info

model.unwrap();
}
let model: mtype::GetMiningInfo = {
let result: Result<mtype::GetMiningInfo, GetMiningInfoError> = json.into_model();
result.unwrap()
};

assert!(model.network_hash_ps > 0.0);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do what you think is best but to me it looks like the only real changes needed to this test are adding the wallet funding and adding the assertion on network_hash_ps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and actioned, thanks @tcharding!

#[test]
Expand Down
2 changes: 1 addition & 1 deletion types/src/model/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub struct GetMiningInfo {
/// The current target (v29 onwards).
pub target: Option<Target>,
/// The network hashes per second.
pub network_hash_ps: i64,
pub network_hash_ps: f64,
/// The size of the mempool.
pub pooled_tx: i64,
/// Minimum feerate of packages selected for block inclusion.
Expand Down
2 changes: 1 addition & 1 deletion types/src/v17/mining/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub struct GetMiningInfo {
pub difficulty: f64,
/// The network hashes per second.
#[serde(rename = "networkhashps")]
pub network_hash_ps: i64,
pub network_hash_ps: f64,
/// The size of the mempool.
#[serde(rename = "pooledtx")]
pub pooled_tx: i64,
Expand Down
2 changes: 1 addition & 1 deletion types/src/v28/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct GetMiningInfo {
pub difficulty: f64,
/// The network hashes per second.
#[serde(rename = "networkhashps")]
pub network_hash_ps: i64,
pub network_hash_ps: f64,
/// The size of the mempool.
#[serde(rename = "pooledtx")]
pub pooled_tx: i64,
Expand Down
2 changes: 1 addition & 1 deletion types/src/v29/mining/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct GetMiningInfo {
pub target: String,
/// The network hashes per second.
#[serde(rename = "networkhashps")]
pub network_hash_ps: i64,
pub network_hash_ps: f64,
/// The size of the mempool.
#[serde(rename = "pooledtx")]
pub pooled_tx: i64,
Expand Down
2 changes: 1 addition & 1 deletion types/src/v30/mining/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct GetMiningInfo {
pub target: String,
/// The network hashes per second.
#[serde(rename = "networkhashps")]
pub network_hash_ps: i64,
pub network_hash_ps: f64,
/// The size of the mempool.
#[serde(rename = "pooledtx")]
pub pooled_tx: i64,
Expand Down
Loading