Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Aug 29, 2024
1 parent bc9a092 commit 3274789
Showing 1 changed file with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ where

#[cfg(test)]
mod test {
use super::*;
use crate::config::PlatformConfig;
use crate::test::helpers::setup::TestPlatformBuilder;
use dashcore_rpc::json::MasternodeListDiff;
use std::env;
use std::fs::File;
use std::io::BufReader;
use dashcore_rpc::json::MasternodeListDiff;
use crate::config::PlatformConfig;
use crate::test::helpers::setup::TestPlatformBuilder;
use super::*;
use std::path::PathBuf;

#[test]
Expand All @@ -92,7 +92,7 @@ mod test {
let platform_state = platform.state.load();

let mut init_chain_platform_state = platform_state.as_ref().clone();

let genesis_core_block_height = 2128896;
let first_block_core_block_height = 2129440;
let genesis_time = 1;
Expand All @@ -116,49 +116,81 @@ mod test {
let current_dir = env::current_dir().expect("expected to get current directory");
// Check if the current directory ends with "platform"
let adjusted_path = if current_dir.ends_with("platform") {
current_dir.join("packages/rs-drive-abci").join(relative_path)
current_dir
.join("packages/rs-drive-abci")
.join(relative_path)
} else {
current_dir.join(relative_path)
};

adjusted_path
}

platform
.core_rpc
.expect_get_protx_diff_with_masternodes()
.returning(move |base_block, block| {
if block == 2128896 {
let file_path = adjust_path_based_on_current_dir("tests/supporting_files/mainnet_protx_list_diffs/1-2128896.json");
println!("Current directory: {:?}, using {:?}", std::env::current_dir(), &file_path);
let file_path = adjust_path_based_on_current_dir(
"tests/supporting_files/mainnet_protx_list_diffs/1-2128896.json",
);
println!(
"Current directory: {:?}, using {:?}",
std::env::current_dir(),
&file_path
);
// Deserialize the first JSON file
let file = File::open(file_path).expect("expected to open file");
let reader = BufReader::new(file);
let init_chain_masternode_list_diff: MasternodeListDiff = serde_json::from_reader(reader).expect("expected to deserialize into a masternode list diff");
let init_chain_masternode_list_diff: MasternodeListDiff =
serde_json::from_reader(reader)
.expect("expected to deserialize into a masternode list diff");


Ok(init_chain_masternode_list_diff)
} else {

// Deserialize the second JSON file
let file = File::open(adjust_path_based_on_current_dir("tests/supporting_files/mainnet_protx_list_diffs/2128896-2129440.json")).expect("expected to open file");
let file = File::open(adjust_path_based_on_current_dir(
"tests/supporting_files/mainnet_protx_list_diffs/2128896-2129440.json",
))
.expect("expected to open file");
let reader = BufReader::new(file);
let block_1_masternode_list_diff: MasternodeListDiff = serde_json::from_reader(reader).expect("expected to deserialize into a masternode list diff");
let block_1_masternode_list_diff: MasternodeListDiff =
serde_json::from_reader(reader)
.expect("expected to deserialize into a masternode list diff");


Ok(block_1_masternode_list_diff)
}
});

let transaction = platform.drive.grove.start_transaction();

platform.update_masternode_list(None,&mut init_chain_platform_state,genesis_core_block_height, true, &genesis_block_info, &transaction, platform_version).expect("expected to update masternode list");

platform
.update_masternode_list(
None,
&mut init_chain_platform_state,
genesis_core_block_height,
true,
&genesis_block_info,
&transaction,
platform_version,
)
.expect("expected to update masternode list");

let platform_state = init_chain_platform_state.clone();

let mut block_platform_state = platform_state.clone();

platform.update_masternode_list(Some(&platform_state),&mut block_platform_state,first_block_core_block_height, false, &first_block_info, &transaction, platform_version).expect("expected to update masternode list");

platform
.update_masternode_list(
Some(&platform_state),
&mut block_platform_state,
first_block_core_block_height,
false,
&first_block_info,
&transaction,
platform_version,
)
.expect("expected to update masternode list");
platform
.drive
.grove
Expand Down

0 comments on commit 3274789

Please sign in to comment.