-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] #4116: Add test for plain == scale encoded verification for…
… status request (#4284) * [feature] add test for json == scale verification Signed-off-by: VAmuzing <[email protected]>
- Loading branch information
Showing
5 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::str::FromStr as _; | ||
|
||
use eyre::Result; | ||
use iroha_client::{data_model::prelude::*, samples::get_status_json}; | ||
use iroha_telemetry::metrics::Status; | ||
use test_network::*; | ||
|
||
fn status_eq_excluding_uptime_and_queue(lhs: &Status, rhs: &Status) -> bool { | ||
lhs.peers == rhs.peers | ||
&& lhs.blocks == rhs.blocks | ||
&& lhs.txs_accepted == rhs.txs_accepted | ||
&& lhs.txs_rejected == rhs.txs_rejected | ||
&& lhs.view_changes == rhs.view_changes | ||
} | ||
|
||
#[test] | ||
fn json_and_scale_statuses_equality() -> Result<()> { | ||
let (_rt, network, client) = Network::start_test_with_runtime(2, Some(11_200)); | ||
wait_for_genesis_committed(&network.clients(), 0); | ||
|
||
let json_status_zero = get_status_json(&client).unwrap(); | ||
|
||
let scale_status_zero_decoded = client.get_status().unwrap(); | ||
|
||
assert!( | ||
status_eq_excluding_uptime_and_queue(&json_status_zero, &scale_status_zero_decoded), | ||
"get_status() result is not equal to decoded get_status_scale_encoded()" | ||
); | ||
|
||
let coins = ["xor", "btc", "eth", "doge"]; | ||
|
||
let domain_id: DomainId = "test_domain".parse().expect("Should be valid"); | ||
let account_id = AccountId::new(domain_id, "test_account".parse().expect("Should be valid")); | ||
|
||
for coin in coins { | ||
let asset_definition_id = AssetDefinitionId::from_str(&format!("{coin}#wonderland"))?; | ||
let create_asset = | ||
Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone())); | ||
let mint_asset = Mint::asset_numeric( | ||
1234u32, | ||
AssetId::new(asset_definition_id, account_id.clone()), | ||
); | ||
let instructions: [InstructionBox; 2] = [create_asset.into(), mint_asset.into()]; | ||
client.submit_all(instructions)?; | ||
} | ||
|
||
let json_status_coins = get_status_json(&client).unwrap(); | ||
|
||
let scale_status_coins_decoded = client.get_status().unwrap(); | ||
|
||
assert!( | ||
status_eq_excluding_uptime_and_queue(&json_status_coins, &scale_status_coins_decoded), | ||
"get_status() result is not equal to decoded get_status_scale_encoded()" | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters