mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-21 23:48:01 +00:00
Override gas limit for tests (#231)
* Add the ability to override the gas limit and other gas params in test steps * Update the CI to accept resolc URL
This commit is contained in:
@@ -18,10 +18,9 @@ inputs:
|
||||
required: false
|
||||
default: "main"
|
||||
type: string
|
||||
resolc-version:
|
||||
description: "The version of resolc to install and use in tests."
|
||||
required: false
|
||||
default: "0.5.0"
|
||||
resolc-download-url:
|
||||
description: "The URL to use to download the resolc compiler."
|
||||
required: true
|
||||
type: string
|
||||
use-compilation-caches:
|
||||
description: "Controls if the compilation caches will be used for the test run or not."
|
||||
@@ -62,11 +61,8 @@ runs:
|
||||
submodules: recursive
|
||||
- name: Installing the Latest Resolc
|
||||
shell: bash
|
||||
if: ${{ runner.os == 'Linux' && runner.arch == 'X64' }}
|
||||
run: |
|
||||
VERSION="${{ inputs['resolc-version'] }}"
|
||||
ASSET_URL="https://github.com/paritytech/revive/releases/download/v$VERSION/resolc-x86_64-unknown-linux-musl"
|
||||
echo "Downloading resolc v$VERSION from $ASSET_URL"
|
||||
ASSET_URL="${{ inputs['resolc-download-url'] }}"
|
||||
curl -Lsf --show-error -o resolc "$ASSET_URL"
|
||||
chmod +x resolc
|
||||
./resolc --version
|
||||
|
||||
@@ -482,15 +482,16 @@ where
|
||||
.context("Failed to find deployment receipt for constructor call"),
|
||||
Method::Fallback | Method::FunctionName(_) => {
|
||||
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())
|
||||
.await
|
||||
{
|
||||
Ok(tx) => tx,
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
.await?;
|
||||
|
||||
let gas_overrides = step
|
||||
.gas_overrides
|
||||
.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
|
||||
}
|
||||
@@ -911,7 +912,6 @@ where
|
||||
.get(contract_instance)
|
||||
{
|
||||
info!(
|
||||
|
||||
%address,
|
||||
"Contract instance already deployed."
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::{collections::HashMap, fmt::Display, str::FromStr};
|
||||
|
||||
use alloy::hex::ToHexExt;
|
||||
use alloy::network::Network;
|
||||
use alloy::primitives::{FixedBytes, utils::parse_units};
|
||||
use alloy::{
|
||||
eips::BlockNumberOrTag,
|
||||
@@ -11,6 +12,7 @@ use alloy::{
|
||||
};
|
||||
use anyhow::Context as _;
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, stream};
|
||||
use revive_dt_common::types::PlatformIdentifier;
|
||||
use schemars::JsonSchema;
|
||||
use semver::VersionReq;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -152,6 +154,11 @@ pub struct FunctionCallStep {
|
||||
/// during the execution.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
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
|
||||
@@ -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)]
|
||||
mod tests {
|
||||
|
||||
|
||||
+1
-1
Submodule resolc-compiler-tests updated: d5185923e0...9522e30552
Reference in New Issue
Block a user