-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c2a4a5
commit 6e2db30
Showing
8 changed files
with
185 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
mod config; | ||
pub mod docker; | ||
pub mod task; | ||
|
||
pub use config::BOOTSTRAP_CONTRACT_NAMES; | ||
use std::process::exit; | ||
|
||
pub const EXCHANGER_ADDRESS: &str = "KT1F3MuqvT9Yz57TgCS3EkDcKNZe9HpiavUJ"; | ||
pub const JSTZ_ROLLUP_ADDRESS: &str = "sr1PuFMgaRUN12rKQ3J2ae5psNtwCxPNmGNK"; | ||
pub const JSTZ_NATIVE_BRIDGE_ADDRESS: &str = "KT1GFiPkkTjd14oHe6MrBPiRh5djzRkVWcni"; | ||
|
||
/// The `main` function for running jstzd | ||
pub async fn main() -> anyhow::Result<()> { | ||
println!("Hello, world!"); | ||
Ok(()) | ||
pub async fn main(config_path: &Option<String>) { | ||
match config::build_config(config_path).await { | ||
Ok((_port, _config)) => { | ||
// TODO: run JstzdServer here | ||
println!("ready"); | ||
} | ||
Err(e) => { | ||
match config_path { | ||
Some(p) => eprintln!("failed to build config from {}: {:?}", p, e), | ||
None => eprintln!("failed to build default config: {:?}", e), | ||
}; | ||
exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
use clap::{Parser, Subcommand}; | ||
|
||
#[derive(Parser, Debug)] | ||
struct Cli { | ||
#[command(subcommand)] | ||
command: Commands, | ||
} | ||
|
||
#[derive(Subcommand, Debug)] | ||
enum Commands { | ||
/// Run the sandbox | ||
Run { config_path: Option<String> }, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
if let Err(e) = jstzd::main().await { | ||
eprintln!("Error: {:?}", e); | ||
std::process::exit(1); | ||
let cli = Cli::parse(); | ||
match &cli.command { | ||
Commands::Run { config_path } => jstzd::main(config_path).await, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt}; | ||
use predicates::prelude::predicate; | ||
use std::{io::Write, process::Command}; | ||
use tempfile::NamedTempFile; | ||
|
||
#[test] | ||
fn unknown_command() { | ||
let mut cmd = Command::cargo_bin("jstzd").unwrap(); | ||
|
||
cmd.arg("test") | ||
.assert() | ||
.failure() | ||
.stderr(predicate::str::contains("unrecognized subcommand \'test\'")); | ||
} | ||
|
||
#[test] | ||
fn default_config() { | ||
let mut cmd = Command::cargo_bin("jstzd").unwrap(); | ||
|
||
cmd.arg("run") | ||
.assert() | ||
.success() | ||
.stdout(predicate::str::contains("ready")); | ||
} | ||
|
||
#[test] | ||
fn valid_config_file() { | ||
let mut cmd = Command::cargo_bin("jstzd").unwrap(); | ||
let mut tmp_file = NamedTempFile::new().unwrap(); | ||
tmp_file.write_all(r#"{"protocol":{"bootstrap_accounts":[["edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2","6000000000"]]}}"#.as_bytes()).unwrap(); | ||
|
||
cmd.args(["run", &tmp_file.path().to_string_lossy()]) | ||
.assert() | ||
.success() | ||
.stdout(predicate::str::contains("ready")); | ||
} | ||
|
||
#[test] | ||
fn bad_config_file() { | ||
let mut cmd = Command::cargo_bin("jstzd").unwrap(); | ||
let mut tmp_file = NamedTempFile::new().unwrap(); | ||
tmp_file.write_all("{}".as_bytes()).unwrap(); | ||
|
||
cmd.args(["run", &tmp_file.path().to_string_lossy()]) | ||
.assert() | ||
.failure() | ||
.stderr(predicate::str::contains( | ||
"should have at least one bootstrap account with at least 6000 tez", | ||
)); | ||
} |