Validate eth1 chain id (#1877)

## Issue Addressed

Resolves #1815 

## Proposed Changes

Adds extra validation for eth1 chain id apart from the existing check for eth1 network id.
This commit is contained in:
Pawan Dhananjay
2020-11-16 23:10:42 +00:00
parent 4d732a1f1d
commit 280334b1b0
5 changed files with 71 additions and 29 deletions

View File

@@ -15,6 +15,7 @@ use web3::{
const GANACHE_STARTUP_TIMEOUT_MILLIS: u64 = 10_000;
const NETWORK_ID: u64 = 42;
const CHAIN_ID: u64 = 42;
/// Provides a dedicated `ganachi-cli` instance with a connected `Web3` instance.
///
@@ -46,6 +47,8 @@ impl GanacheInstance {
.arg("\"vast thought differ pull jewel broom cook wrist tribe word before omit\"")
.arg("--networkId")
.arg(format!("{}", NETWORK_ID))
.arg("--chainId")
.arg(format!("{}", CHAIN_ID))
.spawn()
.map_err(|e| {
format!(
@@ -106,6 +109,11 @@ impl GanacheInstance {
NETWORK_ID
}
/// Returns the chain id of the ganache instance
pub fn chain_id(&self) -> u64 {
CHAIN_ID
}
/// Increase the timestamp on future blocks by `increase_by` seconds.
pub async fn increase_time(&self, increase_by: u64) -> Result<(), String> {
self.web3