Repository: MystenLabs/sui
File: crates/sui-transactional-test-runner/src/test_adapter.rs (Rust)

Code before:

                if dev_inspect {
                    assert!(
                        gas_budget.is_none(),
                        "Meaningless to set gas budget with dev-inspect"
                    );
                }

                let (gas_budget, use_address_balance_gas) =
                    if let Some(budget) = gas_budget_from_address_balance {
                        (budget, true)
                    } else {
                        (gas_budget.unwrap_or(DEFAULT_GAS_BUDGET), false)
                    };

                let summary = if !dev_inspect && !dry_run {
                    let gas_price = gas_price.unwrap_or(self.gas_price);
                    let expiration = expiration
                        .map(TransactionExpiration::Epoch)
                        .unwrap_or(TransactionExpiration::None);
                    let transaction = self.sign_sponsor_txn(
                        sender,
                        sponsor,
                        gas_payment.unwrap_or_default(),
                        |sender, sponsor, mut gas| {
                            if use_address_balance_gas {
                                gas.clear();
                            }
                            let mut tx_data = TransactionData::new_programmable_allow_sponsor(
                                sender,
                                gas,
                                ProgrammableTransaction { inputs, commands },
                                gas_budget,
                                gas_price,
                                sponsor,
                            );
                            *tx_data.expiration_mut_for_testing() = expiration;
                            tx_data
                        },
                    );
                    self.execute_txn(transaction).await?
                } else if dry_run {
                    let gas_price = gas_price.unwrap_or(self.gas_price);
                    let expiration = expiration
                        .map(TransactionExpiration::Epoch)
                        .unwrap_or(TransactionExpiration::None);
                    let sender = self.get_sender(sender);
                    let sponsor = sponsor.map_or(sender, |a| self.get_sender(Some(a)));

                    let payments = if use_address_balance_gas {
                        vec![]

Review comment (suggestion):
It would be good to be consistent about how you handle this case (either this way or setting it to `vec![]` is fine), so people can identify the pattern easily.

Code after:

                if dev_inspect {
                    assert!(
                        gas_budget.is_none(),
                        "Meaningless to set gas budget with dev-inspect"
                    );
                }

                let gas_budget = gas_budget_from_address_balance
                    .or(gas_budget)
                    .unwrap_or(DEFAULT_GAS_BUDGET);
                let use_address_balance_gas = gas_budget_from_address_balance.is_some();

                let summary = if !dev_inspect && !dry_run {
                    let gas_price = gas_price.unwrap_or(self.gas_price);
                    let expiration = expiration
                        .map(TransactionExpiration::Epoch)
                        .unwrap_or(TransactionExpiration::None);
                    let transaction = self.sign_sponsor_txn(
                        sender,
                        sponsor,
                        gas_payment.unwrap_or_default(),
                        |sender, sponsor, gas| {
                            let gas = if use_address_balance_gas { vec![] } else { gas };
                            let mut tx_data = TransactionData::new_programmable_allow_sponsor(
                                sender,
                                gas,
                                ProgrammableTransaction { inputs, commands },
                                gas_budget,
                                gas_price,
                                sponsor,
                            );
                            *tx_data.expiration_mut_for_testing() = expiration;
                            tx_data
                        },
                    );
                    self.execute_txn(transaction).await?
                } else if dry_run {
                    let gas_price = gas_price.unwrap_or(self.gas_price);
                    let expiration = expiration
                        .map(TransactionExpiration::Epoch)
                        .unwrap_or(TransactionExpiration::None);
                    let sender = self.get_sender(sender);
                    let sponsor = sponsor.map_or(sender, |a| self.get_sender(Some(a)));

                    let payments = if use_address_balance_gas {
                        vec![]
                    } else {
                        self.get_payments(sponsor, gas_payment.unwrap_or_default())
                    };