Skip to content

Commit

Permalink
scenario step default gas limit 5,000,000
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jul 14, 2023
1 parent 59a05b3 commit 8d2a870
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 32 deletions.
2 changes: 0 additions & 2 deletions contracts/examples/adder/interact/src/adder_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl AdderInteract {
.call(self.state.default_adder().init(BigUint::from(0u64)))
.from(&self.wallet_address)
.code(&self.adder_code)
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
|new_address, tr| {
tr.result
Expand Down Expand Up @@ -178,7 +177,6 @@ impl AdderInteract {
ScCallStep::new()
.call(self.state.adder().add(value))
.from(&self.wallet_address)
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
|tr| {
tr.result.unwrap_or_else(|err| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fn adder_mandos_constructed_raw() {
.from("address:owner")
.code(adder_code)
.argument("5")
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
)
.sc_query_step(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ fn adder_scenario_constructed_raw() {
.from(owner_address)
.code(adder_code)
.call(adder_contract.init(5u32))
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
|new_address, _: TypedResponse<()>| {
assert_eq!(new_address, adder_contract.to_address());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn crowdfunding_scenario_rust_test() {
deadline,
EgldOrEsdtTokenIdentifier::esdt(cf_token_id_value),
))
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
);

Expand Down
5 changes: 0 additions & 5 deletions contracts/examples/multisig/tests/multisig_rust_test_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ impl MultisigTestState {
.from(self.owner.clone())
.code(self.world.code_expression(MULTISIG_PATH_EXPR))
.call(self.multisig.init(2u32, board))
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
);

Expand All @@ -158,7 +157,6 @@ impl MultisigTestState {
.from(self.owner.clone())
.code(self.world.code_expression(ADDER_PATH_EXPR))
.call(self.adder.init(0u64))
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
);

Expand All @@ -185,7 +183,6 @@ impl MultisigTestState {
ScCallStep::new()
.from(caller)
.call(self.multisig.perform_action_endpoint(action_id))
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
);
output.into_option()
Expand Down Expand Up @@ -224,7 +221,6 @@ impl MultisigTestState {
CodeMetadata::DEFAULT,
adder_init_args,
))
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
)
}
Expand All @@ -245,7 +241,6 @@ impl MultisigTestState {
adder_call.endpoint_name,
adder_call.arg_buffer.into_multi_value_encoded(),
))
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fn tester_deploy_test() {
.from(owner_address)
.code(code)
.call(adder_contract.init())
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
|address, tr: TypedResponse<String>| {
assert_eq!(address, adder_contract.to_address());
Expand Down
19 changes: 1 addition & 18 deletions framework/scenario/src/scenario/model/step/step_sc_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::multiversx_sc::types::{CodeMetadata, ContractDeploy};

use super::{convert_call_args, TypedScDeploy};

#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub struct ScDeployStep {
pub id: String,
pub tx_id: Option<String>,
Expand All @@ -25,23 +25,6 @@ pub struct ScDeployStep {
pub response: Option<TxResponse>,
}

impl Default for ScDeployStep {
fn default() -> Self {
Self {
id: Default::default(),
tx_id: Default::default(),
explicit_tx_hash: Default::default(),
comment: Default::default(),
tx: Box::new(TxDeploy {
code_metadata: CodeMetadata::all(),
..Default::default()
}),
expect: Default::default(),
response: Default::default(),
}
}
}

impl ScDeployStep {
pub fn new() -> Self {
Self::default()
Expand Down
19 changes: 18 additions & 1 deletion framework/scenario/src/scenario/model/transaction/tx_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::{

use super::{tx_interpret_util::interpret_egld_value, TxESDT};

#[derive(Debug, Default, Clone)]
pub const DEFAULT_GAS_EXPR: &str = "5,000,000";

#[derive(Debug, Clone)]
pub struct TxCall {
pub from: AddressValue,
pub to: AddressValue,
Expand All @@ -22,6 +24,21 @@ pub struct TxCall {
pub gas_price: U64Value,
}

impl Default for TxCall {
fn default() -> Self {
Self {
from: Default::default(),
to: Default::default(),
egld_value: Default::default(),
esdt_value: Default::default(),
function: Default::default(),
arguments: Default::default(),
gas_limit: U64Value::from(DEFAULT_GAS_EXPR),
gas_price: Default::default(),
}
}
}

impl InterpretableFrom<TxCallRaw> for TxCall {
fn interpret_from(from: TxCallRaw, context: &InterpreterContext) -> Self {
TxCall {
Expand Down
18 changes: 16 additions & 2 deletions framework/scenario/src/scenario/model/transaction/tx_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::{
},
};

use super::tx_interpret_util::interpret_egld_value;
use super::{tx_interpret_util::interpret_egld_value, DEFAULT_GAS_EXPR};

#[derive(Debug, Default, Clone)]
#[derive(Debug, Clone)]
pub struct TxDeploy {
pub from: AddressValue,
pub egld_value: BigUintValue,
Expand All @@ -20,6 +20,20 @@ pub struct TxDeploy {
pub gas_price: U64Value,
}

impl Default for TxDeploy {
fn default() -> Self {
Self {
from: Default::default(),
egld_value: Default::default(),
code_metadata: CodeMetadata::all(),
contract_code: Default::default(),
arguments: Default::default(),
gas_limit: U64Value::from(DEFAULT_GAS_EXPR),
gas_price: Default::default(),
}
}
}

impl InterpretableFrom<TxDeployRaw> for TxDeploy {
fn interpret_from(from: TxDeployRaw, context: &InterpreterContext) -> Self {
TxDeploy {
Expand Down

0 comments on commit 8d2a870

Please sign in to comment.