feat: rename to aiken and add e2e tests for uplc

This commit is contained in:
rvcas
2022-06-11 23:22:24 -04:00
parent 1ef116fcda
commit 984c253f31
17 changed files with 9915 additions and 330 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "neptune"
version = "0.0.0"
name = "aiken"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -12,8 +12,16 @@ pub enum Cli {
#[derive(Subcommand)]
pub enum UplcCommand {
Flat { input: PathBuf },
Unflat { input: PathBuf },
Flat {
input: PathBuf,
#[clap(short, long)]
print: bool,
},
Unflat {
input: PathBuf,
#[clap(short, long)]
print: bool,
},
}
impl Default for Cli {

View File

@@ -3,14 +3,14 @@ use uplc::{
parser,
};
use neptune::{Cli, UplcCommand};
use aiken::{Cli, UplcCommand};
fn main() -> anyhow::Result<()> {
let args = Cli::default();
match args {
Cli::Uplc(uplc) => match uplc {
UplcCommand::Flat { input } => {
UplcCommand::Flat { input, print } => {
let code = std::fs::read_to_string(&input)?;
let program = parser::program(&code)?;
@@ -19,26 +19,28 @@ fn main() -> anyhow::Result<()> {
let bytes = program.to_flat()?;
for (i, byte) in bytes.iter().enumerate() {
print!("{:08b}", byte);
if print {
for (i, byte) in bytes.iter().enumerate() {
print!("{:08b}", byte);
if (i + 1) % 4 == 0 {
println!();
} else {
print!(" ");
if (i + 1) % 4 == 0 {
println!();
} else {
print!(" ");
}
}
}
println!();
println!();
}
}
UplcCommand::Unflat { input } => {
UplcCommand::Unflat { input, print } => {
let bytes = std::fs::read(&input)?;
let program = Program::<FakeNamedDeBruijn>::from_flat(&bytes)?;
let encoded_flat = program.to_flat()?;
println!("{}", encoded_flat.len());
assert!(bytes == encoded_flat)
if print {
println!("{:#?}", program);
}
}
},
}