Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add block_explorer field to ShowConfigResponse #2750

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion crates/sncast/src/helpers/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct CastConfig {
pub wait_params: ValidatedWaitParams,

#[serde(
default,
default = "default_block_explorer",
rename(serialize = "block-explorer", deserialize = "block-explorer")
)]
/// A block explorer service, used to display links to transaction details
Expand All @@ -48,6 +48,10 @@ pub struct CastConfig {
pub show_explorer_links: bool,
}

fn default_block_explorer() -> Option<block_explorer::Service> {
Some(block_explorer::Service::default())
}

impl Default for CastConfig {
fn default() -> Self {
Self {
Expand Down
37 changes: 37 additions & 0 deletions crates/sncast/tests/e2e/show_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,40 @@ async fn test_show_config_no_url() {
wait_timeout: 500
"});
}

#[tokio::test]
async fn test_show_config_default_block_explorer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be added in the test_show_config_from_snfoundry_toml instead of creating a separate test

let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap();
let args = vec!["show-config"];
let snapbox = runner(&args).current_dir(tempdir.path());
snapbox.assert().success().stdout_eq(formatdoc! {r"
command: show-config
account: user1
accounts_file_path: ../account-file
chain_id: alpha-sepolia
rpc_url: {}
block_explorer: StarkScan
show_explorer_links: true
wait_retry_interval: 5
wait_timeout: 300
", URL});
}

#[tokio::test]
async fn test_show_config_custom_block_explorer() {
let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap();
let args = vec!["--profile", "profile5", "show-config"];
let snapbox = runner(&args).current_dir(tempdir.path());
snapbox.assert().success().stdout_eq(formatdoc! {r"
command: show-config
account: user3
accounts_file_path: ../account-file
chain_id: alpha-sepolia
profile: profile5
rpc_url: {}
block_explorer: blockscout
Copy link
Contributor

Choose a reason for hiding this comment

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

This blok explorer is not supported, please add the custom check for Voyager

show_explorer_links: true
wait_retry_interval: 5
wait_timeout: 300
", URL});
}