Skip to content

Commit

Permalink
clean up dependence on pc-contracts-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
AmbientTea authored and LGLO committed Dec 18, 2024
1 parent bd3a0e1 commit f17f08d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
10 changes: 1 addition & 9 deletions toolkit/partner-chains-cli/src/setup_main_chain_state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::config::config_fields::{CARDANO_PAYMENT_SIGNING_KEY_FILE, POSTGRES_CONNECTION_STRING};
use crate::config::{
config_fields, ChainConfig, ConfigFieldDefinition, CHAIN_CONFIG_FILE_PATH,
PC_CONTRACTS_CLI_PATH,
};
use crate::config::{config_fields, ChainConfig, ConfigFieldDefinition, CHAIN_CONFIG_FILE_PATH};
use crate::io::IOContext;
use crate::pc_contracts_cli_resources::prompt_ogmios_configuration;
use crate::permissioned_candidates::{ParsedPermissionedCandidatesKeys, PermissionedCandidateKeys};
Expand Down Expand Up @@ -98,11 +95,6 @@ impl SetupMainChainStateCmd {
context.print(
"This wizard will set or update D-Parameter and Permissioned Candidates on the main chain. Setting either of these costs ADA!",
);
if !context.file_exists(PC_CONTRACTS_CLI_PATH) {
return Err(anyhow!(
"Partner Chains Smart Contracts executable file ({PC_CONTRACTS_CLI_PATH}) is missing",
));
}
let config_initial_authorities =
initial_permissioned_candidates_from_chain_config(context)?;
if let Some(ariadne_parameters) = get_ariadne_parameters(context, &chain_config)? {
Expand Down
27 changes: 3 additions & 24 deletions toolkit/partner-chains-cli/src/setup_main_chain_state/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::config::config_fields;
use crate::config::config_fields::CARDANO_PAYMENT_SIGNING_KEY_FILE;
use crate::config::{config_fields, PC_CONTRACTS_CLI_PATH};
use crate::config::{CHAIN_CONFIG_FILE_PATH, RESOURCES_CONFIG_FILE_PATH};
use crate::pc_contracts_cli_resources::tests::{
establish_pc_contracts_cli_configuration_io, prompt_ogmios_configuration_io,
};
use crate::pc_contracts_cli_resources::{default_ogmios_service_config, PcContractsCliResources};
use crate::pc_contracts_cli_resources::default_ogmios_service_config;
use crate::pc_contracts_cli_resources::tests::prompt_ogmios_configuration_io;
use crate::prepare_configuration::tests::{
prompt_and_save_to_existing_file, prompt_with_default_and_save_to_existing_file,
};
Expand All @@ -22,7 +20,6 @@ use sp_core::offchain::Timestamp;
#[test]
fn no_ariadne_parameters_on_main_chain_no_updates() {
let mock_context = MockIOContext::new()
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_expected_io(vec![
Expand Down Expand Up @@ -56,7 +53,6 @@ fn no_ariadne_parameters_on_main_chain_do_updates() {
Ok(Some(McTxHash([2; 32]))),
);
let mock_context = MockIOContext::new()
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_json_file("payment.skey", valid_payment_signing_key_content())
Expand All @@ -80,7 +76,6 @@ fn no_ariadne_parameters_on_main_chain_do_updates() {
#[test]
fn ariadne_parameters_are_on_main_chain_no_updates() {
let mock_context = MockIOContext::new()
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_expected_io(vec![
Expand Down Expand Up @@ -114,7 +109,6 @@ fn ariadne_parameters_are_on_main_chain_do_update() {
Ok(Some(McTxHash([2; 32]))),
);
let mock_context = MockIOContext::new()
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_json_file("payment.skey", valid_payment_signing_key_content())
Expand Down Expand Up @@ -146,7 +140,6 @@ fn fails_if_update_permissioned_candidates_fail() {
);
let mock_context = MockIOContext::new()
.with_offchain_mocks(OffchainMocks::new_with_mock("http://localhost:1337", offchain_mock))
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_expected_io(vec![
Expand All @@ -165,7 +158,6 @@ fn fails_if_update_permissioned_candidates_fail() {
#[test]
fn candidates_on_main_chain_are_same_as_in_config_no_updates() {
let mock_context = MockIOContext::new()
.with_file(PC_CONTRACTS_CLI_PATH, "<mock executable>")
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_json_file(RESOURCES_CONFIG_FILE_PATH, test_resources_config_content())
.with_expected_io(vec![
Expand All @@ -182,19 +174,6 @@ fn candidates_on_main_chain_are_same_as_in_config_no_updates() {
result.expect("should succeed");
}

#[test]
fn should_return_error_message_if_pc_cli_missing() {
let mock_context = MockIOContext::new()
.with_json_file(CHAIN_CONFIG_FILE_PATH, test_chain_config_content())
.with_expected_io(vec![read_chain_config_io(), print_info_io()]);
let result = SetupMainChainStateCmd.run(&mock_context);
let err = result.expect_err("should return error");
assert_eq!(
err.to_string(),
"Partner Chains Smart Contracts executable file (./pc-contracts-cli) is missing"
);
}

fn read_chain_config_io() -> MockIO {
MockIO::file_read(CHAIN_CONFIG_FILE_PATH)
}
Expand Down

0 comments on commit f17f08d

Please sign in to comment.