pub fn spawn(self) -> GanacheInstance {
        let mut cmd = Command::new("ganache-cli");
        cmd.stdout(std::process::Stdio::piped());
        let port = if let Some(port) = self.port {
            port
        } else {
            unused_port()
        };
        cmd.arg("-p").arg(port.to_string());

        if let Some(mnemonic) = self.mnemonic {
            cmd.arg("-m").arg(mnemonic);
        }

        if let Some(block_time) = self.block_time {
            cmd.arg("-b").arg(block_time.to_string());
        }

        let mut child = cmd.spawn().expect("couldnt start ganache-cli");

        let stdout = child
            .stdout
            .expect("Unable to get stdout for ganache child process");

        let start = Instant::now();
        let mut reader = BufReader::new(stdout);

        let mut private_keys = Vec::new();
        let mut is_private_key = false;
        loop {
            if start + Duration::from_millis(GANACHE_STARTUP_TIMEOUT_MILLIS) <= Instant::now() {
                panic!("Timed out waiting for ganache to start. Is ganache-cli installed?")
            }

            let mut line = String::new();
            reader
                .read_line(&mut line)
                .expect("Failed to read line from ganache process");
            if line.starts_with("Listening on") {
                break;
            }

            if line.starts_with("Private Keys") {
                is_private_key = true;
            }

            if is_private_key && line.starts_with('(') {
                let key_str = &line[6..line.len() - 1];
                let key: PrivateKey = key_str.parse().expect("did not get private key");
                private_keys.push(key);
            }
        }

        child.stdout = Some(reader.into_inner());

        GanacheInstance {
            pid: child,
            private_keys,
            port,
        }
    }
/// Consumes the builder and spawns `ganache-cli` with stdout redirected
/// to /dev/null. This takes ~2 seconds to execute as it blocks while
/// waiting for `ganache-cli` to launch.
Consumes the builder and spawns `ganache-cli` with stdout redirected
to /dev/null. This takes ~2 seconds to execute as it blocks while
waiting for `ganache-cli` to launch.
Consumes the builder and spawns ` ganache - cli ` with stdout redirected to / dev / null . This takes ~2 seconds to execute as it blocks while waiting for ` ganache - cli ` to launch .
pub fn spawn(self) -> GanacheInstance {
        let mut cmd = Command::new("ganache-cli");
        cmd.stdout(std::process::Stdio::piped());
        let port = if let Some(port) = self.port {
            port
        } else {
            unused_port()
        };
        cmd.arg("-p").arg(port.to_string());
        if let Some(mnemonic) = self.mnemonic {
            cmd.arg("-m").arg(mnemonic);
        }
        if let Some(block_time) = self.block_time {
            cmd.arg("-b").arg(block_time.to_string());
        }
        let mut child = cmd.spawn().expect("couldnt start ganache-cli");
        let stdout = child
            .stdout
            .expect("Unable to get stdout for ganache child process");
        let start = Instant::now();
        let mut reader = BufReader::new(stdout);
        let mut private_keys = Vec::new();
        let mut is_private_key = false;
        loop {
            if start + Duration::from_millis(GANACHE_STARTUP_TIMEOUT_MILLIS) <= Instant::now() {
                panic!("Timed out waiting for ganache to start. Is ganache-cli installed?")
            }
            let mut line = String::new();
            reader
                .read_line(&mut line)
                .expect("Failed to read line from ganache process");
            if line.starts_with("Listening on") {
                break;
            }
            if line.starts_with("Private Keys") {
                is_private_key = true;
            }
            if is_private_key && line.starts_with('(') {
                let key_str = &line[6..line.len() - 1];
                let key: PrivateKey = key_str.parse().expect("did not get private key");
                private_keys.push(key);
            }
        }
        child.stdout = Some(reader.into_inner());
        GanacheInstance {
            pid: child,
            private_keys,
            port,
        }
    }
pub fn spawn ( self ) -> GanacheInstance { let mut cmd = Command :: new ( " " ) ; cmd . stdout ( std :: process :: Stdio :: piped ( ) ) ; let port = if let Some ( port ) = self . port { port } else { unused_port ( ) } ; cmd . arg ( " " ) . arg ( port . to_string ( ) ) ; if let Some ( mnemonic ) = self . mnemonic { cmd . arg ( " " ) . arg ( mnemonic ) ; } if let Some ( block_time ) = self . block_time { cmd . arg ( " " ) . arg ( block_time . to_string ( ) ) ; } let mut child = cmd . spawn ( ) . expect ( " " ) ; let stdout = child . stdout . expect ( " " ) ; let start = Instant :: now ( ) ; let mut reader = BufReader :: new ( stdout ) ; let mut private_keys = Vec :: new ( ) ; let mut is_private_key = false ; loop { if start + Duration :: from_millis ( GANACHE_STARTUP_TIMEOUT_MILLIS ) <= Instant :: now ( ) { panic ! ( " " ) } let mut line = String :: new ( ) ; reader . read_line ( & mut line ) . expect ( " " ) ; if line . starts_with ( " " ) { break ; } if line . starts_with ( " " ) { is_private_key = true ; } if is_private_key && line . starts_with ( '(' ) { let key_str = & line [ 6 .. line . len ( ) - 1 ] ; let key : PrivateKey = key_str . parse ( ) . expect ( " " ) ; private_keys . push ( key ) ; } } child . stdout = Some ( reader . into_inner ( ) ) ; GanacheInstance { pid : child , private_keys , port , } }
Consumes the builder and spawns `ganache-cli` with stdout redirected
to /dev/null.
Consumes the builder and spawns ` ganache - cli ` with stdout redirected to / dev / null .
self
self