Repository: MystenLabs/sui
File: crates/sui/tests/cli_tests.rs (Rust)

Code before:

    // Provide path to well formed package sources
    let mut package_path = PathBuf::from(TEST_DATA_DIR);
    package_path.push("clever_errors");
    let build_config = BuildConfig::new_for_testing().config;
    let resp = SuiClientCommands::TestPublish(TestPublishArgs {
        publish_args: PublishArgs {
            package_path: package_path.clone(),
            build_config,
            skip_dependency_verification: false,
            verify_deps: true,
            with_unpublished_dependencies: false,
            payment: PaymentArgs {
                gas: vec![gas_obj_id],
            },
            gas_data: GasDataArgs {
                gas_budget: Some(rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
                ..Default::default()
            },
            processing: TxProcessingArgs::default(),
        },
        ephemeral: EphemeralArgs {
            build_env: Some("testnet".to_string()),
            pubfile_path: Some(tempdir()?.path().join("localnet.toml")),
        },
        ..Default::default()
    })
    .execute(context)
    .await?;

    // Print it out to CLI/logs
    resp.print(true);

    let SuiClientCommandResult::TransactionBlock(response) = resp else {
        unreachable!("Invalid response");
    };

    let SuiTransactionBlockEffects::V1(effects) = response.effects.unwrap();

    assert!(effects.status.is_ok());
    assert_eq!(effects.gas_object().object_id(), gas_obj_id);
    let package = effects
        .created()
        .iter()
        .find(|refe| matches!(refe.owner, Owner::Immutable))
        .unwrap();

    let elide_transaction_digest = |s: String| -> String {
        let mut x = s.splitn(5, '\'').collect::<Vec<_>>();
        x[1] = "ELIDED_TRANSACTION_DIGEST";
        let tmp = format!("ELIDED_ADDRESS{}", &x[3][66..]);

Review comment (suggestion):
```suggestion
        ..TestPublishArgs::default()
```

Code after:

    // Provide path to well formed package sources
    let mut package_path = PathBuf::from(TEST_DATA_DIR);
    package_path.push("clever_errors");
    let build_config = BuildConfig::new_for_testing().config;
    let resp = SuiClientCommands::TestPublish(TestPublishArgs {
        publish_args: PublishArgs {
            package_path: package_path.clone(),
            build_config,
            skip_dependency_verification: false,
            verify_deps: true,
            with_unpublished_dependencies: false,
            payment: PaymentArgs {
                gas: vec![gas_obj_id],
            },
            gas_data: GasDataArgs {
                gas_budget: Some(rgp * TEST_ONLY_GAS_UNIT_FOR_PUBLISH),
                ..Default::default()
            },
            processing: TxProcessingArgs::default(),
        },
        ephemeral: EphemeralArgs {
            build_env: Some("testnet".to_string()),
            pubfile_path: Some(tempdir()?.path().join("localnet.toml")),
        },
    })
    .execute(context)
    .await?;

    // Print it out to CLI/logs
    resp.print(true);

    let SuiClientCommandResult::TransactionBlock(response) = resp else {
        unreachable!("Invalid response");
    };

    let SuiTransactionBlockEffects::V1(effects) = response.effects.unwrap();

    assert!(effects.status.is_ok());
    assert_eq!(effects.gas_object().object_id(), gas_obj_id);
    let package = effects
        .created()
        .iter()
        .find(|refe| matches!(refe.owner, Owner::Immutable))
        .unwrap();

    let elide_transaction_digest = |s: String| -> String {
        let mut x = s.splitn(5, '\'').collect::<Vec<_>>();
        x[1] = "ELIDED_TRANSACTION_DIGEST";
        let tmp = format!("ELIDED_ADDRESS{}", &x[3][66..]);
        x[3] = &tmp;