mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-12 14:41:06 +00:00
fixes
This commit is contained in:
@@ -131,7 +131,11 @@ impl GethNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_existing(private_key: &str, rpc_port: u16) -> anyhow::Result<Self> {
|
pub async fn new_existing(private_key: &str, rpc_port: u16) -> anyhow::Result<Self> {
|
||||||
use alloy::{primitives::FixedBytes, signers::local::PrivateKeySigner};
|
use alloy::{
|
||||||
|
primitives::FixedBytes,
|
||||||
|
providers::{Provider, ProviderBuilder},
|
||||||
|
signers::local::PrivateKeySigner,
|
||||||
|
};
|
||||||
|
|
||||||
let key_str = private_key.trim().strip_prefix("0x").unwrap_or(private_key.trim());
|
let key_str = private_key.trim().strip_prefix("0x").unwrap_or(private_key.trim());
|
||||||
let key_bytes = alloy::hex::decode(key_str)
|
let key_bytes = alloy::hex::decode(key_str)
|
||||||
@@ -152,6 +156,13 @@ impl GethNode {
|
|||||||
|
|
||||||
let address = signer.address();
|
let address = signer.address();
|
||||||
let wallet = Arc::new(EthereumWallet::new(signer));
|
let wallet = Arc::new(EthereumWallet::new(signer));
|
||||||
|
let connection_string = format!("http://localhost:{}", rpc_port);
|
||||||
|
|
||||||
|
let chain_id = ProviderBuilder::new()
|
||||||
|
.connect_http(connection_string.parse()?)
|
||||||
|
.get_chain_id()
|
||||||
|
.await
|
||||||
|
.context("Failed to query chain ID from RPC")?;
|
||||||
|
|
||||||
let node = Self {
|
let node = Self {
|
||||||
connection_string: format!("http://localhost:{}", rpc_port),
|
connection_string: format!("http://localhost:{}", rpc_port),
|
||||||
@@ -160,7 +171,7 @@ impl GethNode {
|
|||||||
logs_directory: PathBuf::new(),
|
logs_directory: PathBuf::new(),
|
||||||
geth: PathBuf::new(),
|
geth: PathBuf::new(),
|
||||||
id: 0,
|
id: 0,
|
||||||
chain_id: 1337,
|
chain_id,
|
||||||
handle: None,
|
handle: None,
|
||||||
start_timeout: Duration::from_secs(0),
|
start_timeout: Duration::from_secs(0),
|
||||||
wallet,
|
wallet,
|
||||||
@@ -174,6 +185,8 @@ impl GethNode {
|
|||||||
Ok(node)
|
Ok(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ensure that the given address has at least 1000 ETH, funding it from the node's managed
|
||||||
|
/// account if necessary.
|
||||||
async fn ensure_funded(&self, address: Address) -> anyhow::Result<()> {
|
async fn ensure_funded(&self, address: Address) -> anyhow::Result<()> {
|
||||||
use alloy::{
|
use alloy::{
|
||||||
primitives::utils::{format_ether, parse_ether},
|
primitives::utils::{format_ether, parse_ether},
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ pub struct SubstrateNode {
|
|||||||
wallet: Arc<EthereumWallet>,
|
wallet: Arc<EthereumWallet>,
|
||||||
nonce_manager: CachedNonceManager,
|
nonce_manager: CachedNonceManager,
|
||||||
provider: OnceCell<ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>>,
|
provider: OnceCell<ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>>,
|
||||||
|
chain_id: alloy::primitives::ChainId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SubstrateNode {
|
impl SubstrateNode {
|
||||||
@@ -129,11 +130,16 @@ impl SubstrateNode {
|
|||||||
wallet: wallet.clone(),
|
wallet: wallet.clone(),
|
||||||
nonce_manager: Default::default(),
|
nonce_manager: Default::default(),
|
||||||
provider: Default::default(),
|
provider: Default::default(),
|
||||||
|
chain_id: CHAIN_ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn new_existing(private_key: &str, rpc_port: u16) -> anyhow::Result<Self> {
|
pub async fn new_existing(private_key: &str, rpc_port: u16) -> anyhow::Result<Self> {
|
||||||
use alloy::{primitives::FixedBytes, signers::local::PrivateKeySigner};
|
use alloy::{
|
||||||
|
primitives::FixedBytes,
|
||||||
|
providers::{Provider, ProviderBuilder},
|
||||||
|
signers::local::PrivateKeySigner,
|
||||||
|
};
|
||||||
|
|
||||||
let key_str = private_key.trim().strip_prefix("0x").unwrap_or(private_key.trim());
|
let key_str = private_key.trim().strip_prefix("0x").unwrap_or(private_key.trim());
|
||||||
let key_bytes = alloy::hex::decode(key_str)
|
let key_bytes = alloy::hex::decode(key_str)
|
||||||
@@ -153,13 +159,21 @@ impl SubstrateNode {
|
|||||||
.map_err(|e| anyhow::anyhow!("Failed to create signer from private key: {}", e))?;
|
.map_err(|e| anyhow::anyhow!("Failed to create signer from private key: {}", e))?;
|
||||||
|
|
||||||
let wallet = Arc::new(EthereumWallet::new(signer));
|
let wallet = Arc::new(EthereumWallet::new(signer));
|
||||||
|
let rpc_url = format!("http://localhost:{}", rpc_port);
|
||||||
|
|
||||||
|
// Query the chain ID from the RPC
|
||||||
|
let chain_id = ProviderBuilder::new()
|
||||||
|
.connect_http(rpc_url.parse()?)
|
||||||
|
.get_chain_id()
|
||||||
|
.await
|
||||||
|
.context("Failed to query chain ID from RPC")?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id: 0,
|
id: 0,
|
||||||
node_binary: PathBuf::new(),
|
node_binary: PathBuf::new(),
|
||||||
eth_proxy_binary: PathBuf::new(),
|
eth_proxy_binary: PathBuf::new(),
|
||||||
export_chainspec_command: String::new(),
|
export_chainspec_command: String::new(),
|
||||||
rpc_url: format!("http://localhost:{}", rpc_port),
|
rpc_url,
|
||||||
base_directory: PathBuf::new(),
|
base_directory: PathBuf::new(),
|
||||||
logs_directory: PathBuf::new(),
|
logs_directory: PathBuf::new(),
|
||||||
substrate_process: None,
|
substrate_process: None,
|
||||||
@@ -167,6 +181,7 @@ impl SubstrateNode {
|
|||||||
wallet,
|
wallet,
|
||||||
nonce_manager: Default::default(),
|
nonce_manager: Default::default(),
|
||||||
provider: Default::default(),
|
provider: Default::default(),
|
||||||
|
chain_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +398,7 @@ impl SubstrateNode {
|
|||||||
construct_concurrency_limited_provider::<ReviveNetwork, _>(
|
construct_concurrency_limited_provider::<ReviveNetwork, _>(
|
||||||
self.rpc_url.as_str(),
|
self.rpc_url.as_str(),
|
||||||
FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
|
FallbackGasFiller::new(u64::MAX, 5_000_000_000, 1_000_000_000),
|
||||||
ChainIdFiller::new(Some(CHAIN_ID)),
|
ChainIdFiller::new(Some(self.chain_id)),
|
||||||
NonceFiller::new(self.nonce_manager.clone()),
|
NonceFiller::new(self.nonce_manager.clone()),
|
||||||
self.wallet.clone(),
|
self.wallet.clone(),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user