Skip to content

Commit

Permalink
allow gas and sponsor in dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjennings-mysten committed Jan 29, 2025
1 parent a47fc15 commit 2840e64
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ created: object(1,0)
mutated: object(0,1)
gas summary: computation_cost: 1000000, storage_cost: 3465600, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, lines 16-17:
task 2, lines 16-18:
//# programmable --sender A --inputs 0 --dev-inspect
//> 0: test::m::return_ref(Input(0));
mutated: object(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module test::m {
}

//# programmable --sender A --inputs 0 --dev-inspect

//> 0: test::m::return_ref(Input(0));
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ created: object(1,0)
mutated: object(0,1)
gas summary: computation_cost: 1000000, storage_cost: 3465600, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, lines 16-17:
task 2, lines 16-18:
//# programmable --sender A --inputs 0 --dry-run
//> 0: test::m::return_ref(Input(0));
Error: Transaction Effects Status: InvalidPublicFunctionReturnType { idx: 0 } in command 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module test::m {
}

//# programmable --sender A --inputs 0 --dry-run

//> 0: test::m::return_ref(Input(0));
36 changes: 22 additions & 14 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,14 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter {
} else if dry_run {
let gas_budget = gas_budget.unwrap_or(DEFAULT_GAS_BUDGET);
let gas_price = gas_price.unwrap_or(self.gas_price);
let sender_address = self.get_sender(sender).address;
let sender = self.get_sender(sender);
let sponsor = sponsor.map_or(sender, |a| self.get_sender(Some(a)));

let payment = self.get_payment(sponsor, gas_payment);

let transaction = TransactionData::new_programmable(
sender_address,
vec![],
sender.address,
vec![payment],
ProgrammableTransaction { inputs, commands },
gas_budget,
gas_price,
Expand Down Expand Up @@ -1401,6 +1405,7 @@ impl<'a> SuiTestAdapter {
gas_budget: Option<u64>,
policy: u8,
gas_price: u64,
// dry_run: bool,
) -> anyhow::Result<Option<String>> {
let modules_bytes = modules
.iter()
Expand Down Expand Up @@ -1494,6 +1499,19 @@ impl<'a> SuiTestAdapter {
})
}

fn get_payment(&self, sponsor: &TestAccount, payment: Option<FakeID>) -> ObjectRef {
let payment = if let Some(payment) = payment {
self.fake_to_real_object_id(payment)
.expect("Could not find specified payment object")
} else {
sponsor.gas
};

self.get_object(&payment, None)
.unwrap()
.compute_object_reference()
}

fn sign_sponsor_txn(
&self,
sender: Option<String>,
Expand All @@ -1508,17 +1526,7 @@ impl<'a> SuiTestAdapter {
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 payment_ref = self.get_payment(sender, payment);

let data = txn_data(sender.address, sponsor.address, payment_ref);
if sender.address == sponsor.address {
Expand Down

0 comments on commit 2840e64

Please sign in to comment.