mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-13 10:31:03 +00:00
Handle values from the metadata files
This commit is contained in:
@@ -251,6 +251,12 @@ where
|
|||||||
|
|
||||||
let tx = {
|
let tx = {
|
||||||
let tx = TransactionRequest::default().from(input.caller);
|
let tx = TransactionRequest::default().from(input.caller);
|
||||||
|
let tx = match input.value {
|
||||||
|
Some(ref value) if deploy_with_constructor_arguments => {
|
||||||
|
tx.value(value.into_inner())
|
||||||
|
}
|
||||||
|
_ => tx,
|
||||||
|
};
|
||||||
TransactionBuilder::<Ethereum>::with_deploy_code(tx, code)
|
TransactionBuilder::<Ethereum>::with_deploy_code(tx, code)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,16 @@ use alloy::{
|
|||||||
primitives::{Address, Bytes, U256},
|
primitives::{Address, Bytes, U256},
|
||||||
rpc::types::TransactionRequest,
|
rpc::types::TransactionRequest,
|
||||||
};
|
};
|
||||||
use alloy_primitives::FixedBytes;
|
use alloy_primitives::{FixedBytes, utils::parse_units};
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use revive_dt_node_interaction::EthereumNode;
|
use revive_dt_node_interaction::EthereumNode;
|
||||||
|
|
||||||
use crate::metadata::{AddressReplacementMap, ContractInstance};
|
use crate::{
|
||||||
|
define_wrapper_type,
|
||||||
|
metadata::{AddressReplacementMap, ContractInstance},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
@@ -26,7 +29,7 @@ pub struct Input {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub calldata: Calldata,
|
pub calldata: Calldata,
|
||||||
pub expected: Option<Expected>,
|
pub expected: Option<Expected>,
|
||||||
pub value: Option<String>,
|
pub value: Option<EtherValue>,
|
||||||
pub storage: Option<HashMap<String, Calldata>>,
|
pub storage: Option<HashMap<String, Calldata>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +85,37 @@ pub enum Method {
|
|||||||
FunctionName(String),
|
FunctionName(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define_wrapper_type!(
|
||||||
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
EtherValue(U256);
|
||||||
|
);
|
||||||
|
|
||||||
|
impl Serialize for EtherValue {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
format!("{} wei", self.0).serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'de> Deserialize<'de> for EtherValue {
|
||||||
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let string = String::deserialize(deserializer)?;
|
||||||
|
let mut splitted = string.split(' ');
|
||||||
|
let (Some(value), Some(unit)) = (splitted.next(), splitted.next()) else {
|
||||||
|
return Err(serde::de::Error::custom("Failed to parse the value"));
|
||||||
|
};
|
||||||
|
let parsed = parse_units(value, unit.replace("eth", "ether"))
|
||||||
|
.map_err(|_| serde::de::Error::custom("Failed to parse units"))?
|
||||||
|
.into();
|
||||||
|
Ok(Self(parsed))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ExpectedOutput {
|
impl ExpectedOutput {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
@@ -324,7 +358,11 @@ impl Input {
|
|||||||
chain_state_provider: &impl EthereumNode,
|
chain_state_provider: &impl EthereumNode,
|
||||||
) -> anyhow::Result<TransactionRequest> {
|
) -> anyhow::Result<TransactionRequest> {
|
||||||
let input_data = self.encoded_input(deployed_contracts, chain_state_provider)?;
|
let input_data = self.encoded_input(deployed_contracts, chain_state_provider)?;
|
||||||
let transaction_request = TransactionRequest::default().from(self.caller);
|
let transaction_request = TransactionRequest::default().from(self.caller).value(
|
||||||
|
self.value
|
||||||
|
.map(|value| value.into_inner())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
);
|
||||||
match self.method {
|
match self.method {
|
||||||
Method::Deployer => Ok(transaction_request.with_deploy_code(input_data)),
|
Method::Deployer => Ok(transaction_request.with_deploy_code(input_data)),
|
||||||
_ => Ok(transaction_request
|
_ => Ok(transaction_request
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ impl Instance {
|
|||||||
<EthereumWallet as NetworkWallet<Ethereum>>::signer_addresses(&self.wallet)
|
<EthereumWallet as NetworkWallet<Ethereum>>::signer_addresses(&self.wallet)
|
||||||
{
|
{
|
||||||
genesis.alloc.entry(signer_address).or_insert(
|
genesis.alloc.entry(signer_address).or_insert(
|
||||||
GenesisAccount::default().with_balance(1000000000000000000u128.try_into().unwrap()),
|
GenesisAccount::default()
|
||||||
|
.with_balance(10000000000000000000000u128.try_into().unwrap()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let genesis_path = self.base_directory.join(Self::GENESIS_JSON_FILE);
|
let genesis_path = self.base_directory.join(Self::GENESIS_JSON_FILE);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ impl KitchensinkNode {
|
|||||||
{
|
{
|
||||||
genesis.alloc.entry(signer_address).or_insert(
|
genesis.alloc.entry(signer_address).or_insert(
|
||||||
GenesisAccount::default()
|
GenesisAccount::default()
|
||||||
.with_balance(1000000000000000000u128.try_into().unwrap()),
|
.with_balance(10000000000000000000000u128.try_into().unwrap()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
self.extract_balance_from_genesis_file(&genesis)?
|
self.extract_balance_from_genesis_file(&genesis)?
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
"timestamp": "0x00",
|
"timestamp": "0x00",
|
||||||
"alloc": {
|
"alloc": {
|
||||||
"90F8bf6A479f320ead074411a4B0e7944Ea8c9C1": {
|
"90F8bf6A479f320ead074411a4B0e7944Ea8c9C1": {
|
||||||
"balance": "1000000000000000000"
|
"balance": "10000000000000000000000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user