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

Code before:
                            format!("{}::{}", fake_id, modules)
                        }
                    }
                }))
            }
            SuiSubcommand::TransferObject(TransferObjectCommand {
                id: fake_id,
                recipient,
                sender,
                gas_budget,
                gas_budget_from_address_balance,
                gas_price,
            }) => {
                let mut builder = ProgrammableTransactionBuilder::new();
                let obj_arg = SuiValue::Object(fake_id, None).into_argument(&mut builder, self)?;
                let recipient = match self.accounts.get(&recipient) {
                    Some(test_account) => test_account.address,
                    None => panic!("Unbound account {}", recipient),
                };
                let gas_price: u64 = gas_price.unwrap_or(self.gas_price);
                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 transaction = self.sign_txn(sender, |sender, gas| {
                    let rec_arg = builder.pure(recipient).unwrap();
                    builder.command(sui_types::transaction::Command::TransferObjects(
                        vec![obj_arg],
                        rec_arg,
                    ));
                    let pt = builder.finish();
                    let gas = if use_address_balance_gas { vec![] } else { gas };
                    TransactionData::new_programmable(sender, gas, pt, gas_budget, gas_price)
                });
                let summary = self.execute_txn(transaction).await?;
                let output = self.object_summary_output(&summary, /* summarize */ false);
                Ok(output)
            }
            SuiSubcommand::ConsensusCommitPrologue(ConsensusCommitPrologueCommand {
                timestamp_ms,
            }) => {
                let transaction = VerifiedTransaction::new_consensus_commit_prologue_v3(
                    0,
                    0,
                    timestamp_ms,
                    ConsensusCommitDigest::default(),
                    ConsensusDeterminedVersionAssignments::empty_for_testing(),
                );
                let summary = self.execute_txn(transaction.into()).await?;

Review comment (suggestion):
nit (optional): separating concerns

```suggestion
                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();
```

Code after:
                            format!("{}::{{{}}}", fake_id, modules)
                        } else {
                            format!("{}::{}", fake_id, modules)
                        }
                    }
                }))
            }
            SuiSubcommand::TransferObject(TransferObjectCommand {
                id: fake_id,
                recipient,
                sender,
                gas_budget,
                gas_budget_from_address_balance,
                gas_price,
            }) => {
                let mut builder = ProgrammableTransactionBuilder::new();
                let obj_arg = SuiValue::Object(fake_id, None).into_argument(&mut builder, self)?;
                let recipient = match self.accounts.get(&recipient) {
                    Some(test_account) => test_account.address,
                    None => panic!("Unbound account {}", recipient),
                };
                let gas_price: u64 = gas_price.unwrap_or(self.gas_price);
                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 transaction = self.sign_txn(sender, |sender, gas| {
                    let rec_arg = builder.pure(recipient).unwrap();
                    builder.command(sui_types::transaction::Command::TransferObjects(
                        vec![obj_arg],
                        rec_arg,
                    ));
                    let pt = builder.finish();
                    let gas = if use_address_balance_gas { vec![] } else { gas };
                    TransactionData::new_programmable(sender, gas, pt, gas_budget, gas_price)
                });
                let summary = self.execute_txn(transaction).await?;
                let output = self.object_summary_output(&summary, /* summarize */ false);
                Ok(output)
            }
            SuiSubcommand::ConsensusCommitPrologue(ConsensusCommitPrologueCommand {
                timestamp_ms,
            }) => {
                let transaction = VerifiedTransaction::new_consensus_commit_prologue_v3(
                    0,
                    0,
                    timestamp_ms,
                    ConsensusCommitDigest::default(),
                    ConsensusDeterminedVersionAssignments::empty_for_testing(),
                );
                let summary = self.execute_txn(transaction.into()).await?;