Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed Jun 17, 2024
1 parent 4e0dcff commit e979974
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions unit_tests/tests/test_get_state_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use common::*;

use starknet_core::types::{BlockId, StarknetError};
use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider};
use std::collections::HashMap;
use std::{collections::HashMap, os::macos::raw};

/// Test for the `get_state_update` Deoxys RPC method
/// # Arguments
Expand Down Expand Up @@ -46,8 +46,9 @@ async fn fail_non_existing_block(clients: HashMap<String, JsonRpcClient<HttpTran
async fn work_existing_block(clients: HashMap<String, JsonRpcClient<HttpTransport>>) {
let deoxys = &clients[DEOXYS];
let pathfinder = &clients[PATHFINDER];
let juno = &clients[JUNO];

let block_number = BlockId::Number(100);
let block_number = BlockId::Number(10000);

let response_deoxys = deoxys
.get_state_update(block_number)
Expand All @@ -57,6 +58,29 @@ async fn work_existing_block(clients: HashMap<String, JsonRpcClient<HttpTranspor
.get_state_update(block_number)
.await
.expect("RPC : Error while getting the state update");
let response_juno = juno
.get_state_update(block_number)
.await
.expect("RPC : Error while getting the state update");

let raw_deoxys = format!("{:?}", response_deoxys);
let raw_pathfinder = format!("{:?}", response_pathfinder);
let raw_juno = format!("{:?}", response_juno);

assert_eq!(response_deoxys, response_pathfinder);
let mut sorted_deoxys: Vec<char> = raw_deoxys.chars().collect();
sorted_deoxys.sort(); // Use sort instead of sort_unstable
let sorted_deoxys: String = sorted_deoxys.into_iter().collect();

let mut sorted_pathfinder: Vec<char> = raw_pathfinder.chars().collect();
sorted_pathfinder.sort(); // Use sort instead of sort_unstable
let sorted_pathfinder: String = sorted_pathfinder.into_iter().collect();

let mut sorted_juno: Vec<char> = raw_juno.chars().collect();
sorted_juno.sort(); // Use sort instead of sort_unstable
let sorted_juno: String = sorted_juno.into_iter().collect();

assert_eq!(sorted_deoxys, sorted_pathfinder, "The sorted responses do not match");
assert_eq!(sorted_deoxys, sorted_juno, "The sorted responses do not match");
assert_eq!(sorted_juno, sorted_pathfinder, "The sorted responses do not match");
}

0 comments on commit e979974

Please sign in to comment.