mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-18 11:41:09 +00:00
Add the ability to override the gas limit and other gas params in test steps
This commit is contained in:
@@ -482,15 +482,16 @@ where
|
|||||||
.context("Failed to find deployment receipt for constructor call"),
|
.context("Failed to find deployment receipt for constructor call"),
|
||||||
Method::Fallback | Method::FunctionName(_) => {
|
Method::Fallback | Method::FunctionName(_) => {
|
||||||
let resolver = self.platform_information.node.resolver().await?;
|
let resolver = self.platform_information.node.resolver().await?;
|
||||||
let tx = match step
|
let mut tx = step
|
||||||
.as_transaction(resolver.as_ref(), self.default_resolution_context())
|
.as_transaction(resolver.as_ref(), self.default_resolution_context())
|
||||||
.await
|
.await?;
|
||||||
{
|
|
||||||
Ok(tx) => tx,
|
let gas_overrides = step
|
||||||
Err(err) => {
|
.gas_overrides
|
||||||
return Err(err);
|
.get(&self.platform_information.platform.platform_identifier())
|
||||||
}
|
.copied()
|
||||||
};
|
.unwrap_or_default();
|
||||||
|
gas_overrides.apply_to::<Ethereum>(&mut tx);
|
||||||
|
|
||||||
self.platform_information.node.execute_transaction(tx).await
|
self.platform_information.node.execute_transaction(tx).await
|
||||||
}
|
}
|
||||||
@@ -911,7 +912,6 @@ where
|
|||||||
.get(contract_instance)
|
.get(contract_instance)
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
|
|
||||||
%address,
|
%address,
|
||||||
"Contract instance already deployed."
|
"Contract instance already deployed."
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::{collections::HashMap, fmt::Display, str::FromStr};
|
use std::{collections::HashMap, fmt::Display, str::FromStr};
|
||||||
|
|
||||||
use alloy::hex::ToHexExt;
|
use alloy::hex::ToHexExt;
|
||||||
|
use alloy::network::Network;
|
||||||
use alloy::primitives::{FixedBytes, utils::parse_units};
|
use alloy::primitives::{FixedBytes, utils::parse_units};
|
||||||
use alloy::{
|
use alloy::{
|
||||||
eips::BlockNumberOrTag,
|
eips::BlockNumberOrTag,
|
||||||
@@ -11,6 +12,7 @@ use alloy::{
|
|||||||
};
|
};
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, stream};
|
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, stream};
|
||||||
|
use revive_dt_common::types::PlatformIdentifier;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -152,6 +154,11 @@ pub struct FunctionCallStep {
|
|||||||
/// during the execution.
|
/// during the execution.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub variable_assignments: Option<VariableAssignments>,
|
pub variable_assignments: Option<VariableAssignments>,
|
||||||
|
|
||||||
|
/// Allows for the test to set a specific value for the various gas parameter for each one of
|
||||||
|
/// the platforms we support. This is ignored for steps that perform contract deployments.
|
||||||
|
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||||
|
pub gas_overrides: HashMap<PlatformIdentifier, GasOverrides>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This represents a balance assertion step where the framework needs to query the balance of some
|
/// This represents a balance assertion step where the framework needs to query the balance of some
|
||||||
@@ -965,6 +972,62 @@ impl<'de> Deserialize<'de> for EtherValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Eq, PartialEq, JsonSchema)]
|
||||||
|
pub struct GasOverrides {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub gas_limit: Option<u64>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub gas_price: Option<u128>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub max_fee_per_gas: Option<u128>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub max_priority_fee_per_gas: Option<u128>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GasOverrides {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_gas_limit(mut self, value: impl Into<Option<u64>>) -> Self {
|
||||||
|
self.gas_limit = value.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_gas_price(mut self, value: impl Into<Option<u128>>) -> Self {
|
||||||
|
self.gas_price = value.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_max_fee_per_gas(mut self, value: impl Into<Option<u128>>) -> Self {
|
||||||
|
self.max_fee_per_gas = value.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_max_priority_fee_per_gas(mut self, value: impl Into<Option<u128>>) -> Self {
|
||||||
|
self.max_priority_fee_per_gas = value.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apply_to<N: Network>(&self, transaction_request: &mut N::TransactionRequest) {
|
||||||
|
if let Some(gas_limit) = self.gas_limit {
|
||||||
|
transaction_request.set_gas_limit(gas_limit);
|
||||||
|
}
|
||||||
|
if let Some(gas_price) = self.gas_price {
|
||||||
|
transaction_request.set_gas_price(gas_price);
|
||||||
|
}
|
||||||
|
if let Some(max_fee_per_gas) = self.max_fee_per_gas {
|
||||||
|
transaction_request.set_max_fee_per_gas(max_fee_per_gas);
|
||||||
|
}
|
||||||
|
if let Some(max_priority_fee_per_gas) = self.max_priority_fee_per_gas {
|
||||||
|
transaction_request.set_max_priority_fee_per_gas(max_priority_fee_per_gas)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule resolc-compiler-tests updated: d5185923e0...9522e30552
Reference in New Issue
Block a user