Skip to content

Commit

Permalink
fix: debugging stdin for local account initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
andygolay committed Aug 20, 2024
1 parent db4bb2e commit e61e5b5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
61 changes: 39 additions & 22 deletions protocol-units/bridge/chains/movement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use bridge_shared::{
};
use rand::prelude::*;
use serde::Serialize;
use std::{env, process::{Command, Stdio}};
use std::{env, io::{Write, Read}, process::{Command, Stdio}};
use std::str::FromStr;
use std::{
sync::{mpsc, Arc, Mutex, RwLock},
Expand Down Expand Up @@ -113,7 +113,7 @@ impl MovementClient {
config: Config,
) -> Result<(Self, tokio::process::Child), anyhow::Error> {
let (setup_complete_tx, mut setup_complete_rx) = oneshot::channel();
let mut child = TokioCommand::new("aptos")
let mut child = TokioCommand::new("movement")
.args(&["node", "run-local-testnet"])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
Expand Down Expand Up @@ -197,29 +197,46 @@ impl MovementClient {

pub fn publish_for_test(&self) -> Result<()> {
println!("Current directory: {:?}", env::current_dir());
let output1 = Command::new("aptos")
.args(&[
"init",
"--assume-yes"
])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()
.expect("Failed to execute command");

if !output1.stdout.is_empty() {
println!("stdout: {}", String::from_utf8_lossy(&output1.stdout));
}

if !output1.stderr.is_empty() {
eprintln!("stderr: {}", String::from_utf8_lossy(&output1.stderr));
}

let output = Command::new("aptos")
let mut process = Command::new("movement")
.args(&["init"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.expect("Failed to execute command");

// Write "local" to the first prompt
println!("Spawned");
let stdin = process.stdin.as_mut().expect("Failed to open stdin");
stdin.write_all(b"local\n").expect("Failed to write to stdin");

// Press enter for the second prompt
stdin.write_all(b"\n").expect("Failed to write to stdin");

// Close stdin to indicate that no more input will be provided
drop(stdin);

let output = process
.wait_with_output()
.expect("Failed to read command output");

if !output.stdout.is_empty() {
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
}

if !output.stderr.is_empty() {
eprintln!("stderr: {}", String::from_utf8_lossy(&output.stderr));
}

let output = Command::new("movement")
.args(&[
"move",
"publish",
"create-resource-account-and-publish-package",
"--assume-yes",
"--address-name",
"moveth",
"--seed",
"1234",
"--package-dir",
"../move-modules"
])
Expand Down
8 changes: 4 additions & 4 deletions protocol-units/bridge/move-modules/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "1.0.0"
authors = []

[addresses]
atomic_bridge = "0x31a9bcd02c593c1e311e3edce7084f67397ea5b011aaefe650a2b700c0a5ea77"
moveth = "0x31a9bcd02c593c1e311e3edce7084f67397ea5b011aaefe650a2b700c0a5ea77"
master_minter = "0x31a9bcd02c593c1e311e3edce7084f67397ea5b011aaefe650a2b700c0a5ea77"
atomic_bridge = "0x0003f6590872b68c47f1c84eff6766eebebdae21d49a6f795a563eb76ad9f65c"
moveth = "0x0003f6590872b68c47f1c84eff6766eebebdae21d49a6f795a563eb76ad9f65c"
master_minter = "0x0003f6590872b68c47f1c84eff6766eebebdae21d49a6f795a563eb76ad9f65c"
minter = "0x31a9bcd02c593c1e311e3edce7084f67397ea5b011aaefe650a2b700c0a5ea77"
admin = "0x31a9bcd02c593c1e311e3edce7084f67397ea5b011aaefe650a2b700c0a5ea77"
admin = "0x0003f6590872b68c47f1c84eff6766eebebdae21d49a6f795a563eb76ad9f65c"
pauser = "0xdafe"
denylister = "0xcade"

Expand Down

0 comments on commit e61e5b5

Please sign in to comment.