Skip to content
Merged
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
8 changes: 6 additions & 2 deletions crates/iota-transactional-test-runner/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ pub struct ConsensusCommitPrologueCommand {
pub struct ProgrammableTransactionCommand {
#[arg(long)]
pub sender: Option<String>,
#[arg(long)]
#[clap(long = "sponsor")]
pub sponsor: Option<String>,
#[arg(long = "gas-budget")]
pub gas_budget: Option<u64>,
#[arg(long)]
pub gas_price: Option<u64>,
#[arg(long)]
#[clap(long = "gas-payment", value_parser = parse_fake_id)]
pub gas_payment: Option<FakeID>,
#[arg(long = "dev-inspect")]
pub dev_inspect: bool,
#[arg(
long,
Expand Down
74 changes: 59 additions & 15 deletions crates/iota-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use iota_types::{
Argument, CallArg, Command, ProgrammableTransaction, Transaction, TransactionData,
TransactionDataAPI, TransactionKind, VerifiedTransaction,
},
utils::to_sender_signed_transaction,
utils::{to_sender_signed_transaction, to_sender_signed_transaction_with_multi_signers},
};
use move_binary_format::CompiledModule;
use move_bytecode_utils::module_cache::GetModule;
Expand Down Expand Up @@ -748,8 +748,10 @@ impl MoveTestAdapter<'_> for IotaTestAdapter {
}
IotaSubcommand::ProgrammableTransaction(ProgrammableTransactionCommand {
sender,
sponsor,
gas_budget,
gas_price,
gas_payment,
dev_inspect,
inputs,
}) => {
Expand Down Expand Up @@ -795,15 +797,21 @@ impl MoveTestAdapter<'_> for IotaTestAdapter {
let summary = if !dev_inspect {
let gas_budget = gas_budget.unwrap_or(DEFAULT_GAS_BUDGET);
let gas_price = gas_price.unwrap_or(self.gas_price);
let transaction = self.sign_txn(sender, |sender, gas| {
TransactionData::new_programmable(
sender,
vec![gas],
ProgrammableTransaction { inputs, commands },
gas_budget,
gas_price,
)
});
let transaction = self.sign_sponsor_txn(
sender,
sponsor,
gas_payment,
|sender, sponsor, gas| {
TransactionData::new_programmable_allow_sponsor(
sender,
vec![gas],
ProgrammableTransaction { inputs, commands },
gas_budget,
gas_price,
sponsor,
)
},
);
self.execute_txn(transaction).await?
} else {
assert!(
Expand Down Expand Up @@ -1387,13 +1395,49 @@ impl IotaTestAdapter {
ObjectRef,
) -> TransactionData,
) -> Transaction {
let test_account = self.get_sender(sender);
let gas_payment = self
.get_object(&test_account.gas, None)
self.sign_sponsor_txn(sender, None, None, move |sender, _, gas| {
txn_data(sender, gas)
})
}

fn sign_sponsor_txn(
&self,
sender: Option<String>,
sponsor: Option<String>,
payment: Option<FakeID>,
txn_data: impl FnOnce(
// sender
IotaAddress,
// sponsor
IotaAddress,
// gas
ObjectRef,
) -> TransactionData,
) -> Transaction {
let sender = self.get_sender(sender);
let sponsor = sponsor.map_or(sender, |a| self.get_sender(Some(a)));

let payment = if let Some(payment) = payment {
self.fake_to_real_object_id(payment)
.expect("Could not find specified payment object")
} else {
sponsor.gas
};

let payment_ref = self
.get_object(&payment, None)
.unwrap()
.compute_object_reference();
let data = txn_data(test_account.address, gas_payment);
to_sender_signed_transaction(data, &test_account.key_pair)

let data = txn_data(sender.address, sponsor.address, payment_ref);
if sender.address == sponsor.address {
to_sender_signed_transaction(data, &sender.key_pair)
} else {
to_sender_signed_transaction_with_multi_signers(
data,
vec![&sender.key_pair, &sponsor.key_pair],
)
}
}

fn get_sender(&self, sender: Option<String>) -> &TestAccount {
Expand Down
Loading