From 6922569eff5ab3a1c76a65e82230b72d7d4d8304 Mon Sep 17 00:00:00 2001 From: evan-schott <53463459+evan-schott@users.noreply.github.com> Date: Fri, 15 Dec 2023 20:47:11 -0800 Subject: [PATCH] run test --- leo/cli/cli.rs | 24 +++++++++++++++++++ leo/cli/commands/run.rs | 4 ++-- utils/tmp/grandparent/.gitignore | 5 ++++ utils/tmp/grandparent/README.md | 13 ++++++++++ .../tmp/grandparent/build/imports/child.aleo | 12 ++++++++++ .../tmp/grandparent/build/imports/parent.aleo | 10 ++++++++ .../tmp/grandparent/build/imports/prog_a.aleo | 12 ++++++++++ .../tmp/grandparent/build/imports/prog_b.aleo | 10 ++++++++ utils/tmp/grandparent/build/main.aleo | 11 +++++++++ utils/tmp/grandparent/build/program.json | 18 ++++++++++++++ .../tmp/grandparent/inputs/import_example.in | 4 ++++ utils/tmp/grandparent/leo.lock | 13 ++++++++++ utils/tmp/grandparent/parent/.gitignore | 5 ++++ utils/tmp/grandparent/parent/README.md | 13 ++++++++++ .../grandparent/parent/build/imports/a.aleo | 12 ++++++++++ .../parent/build/imports/child.aleo | 12 ++++++++++ .../parent/build/imports/prog_a.aleo | 12 ++++++++++ utils/tmp/grandparent/parent/build/main.aleo | 10 ++++++++ .../tmp/grandparent/parent/build/program.json | 13 ++++++++++ utils/tmp/grandparent/parent/child/.gitignore | 5 ++++ utils/tmp/grandparent/parent/child/README.md | 13 ++++++++++ .../grandparent/parent/child/build/main.aleo | 12 ++++++++++ .../parent/child/build/program.json | 6 +++++ .../tmp/grandparent/parent/child/inputs/a.in | 4 ++++ utils/tmp/grandparent/parent/child/leo.lock | 1 + .../tmp/grandparent/parent/child/program.json | 6 +++++ .../tmp/grandparent/parent/child/src/main.leo | 10 ++++++++ utils/tmp/grandparent/parent/inputs/b.in | 4 ++++ utils/tmp/grandparent/parent/leo.lock | 6 +++++ utils/tmp/grandparent/parent/program.json | 13 ++++++++++ utils/tmp/grandparent/parent/src/main.leo | 7 ++++++ utils/tmp/grandparent/program.json | 18 ++++++++++++++ utils/tmp/grandparent/src/main.leo | 8 +++++++ 33 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 utils/tmp/grandparent/.gitignore create mode 100644 utils/tmp/grandparent/README.md create mode 100644 utils/tmp/grandparent/build/imports/child.aleo create mode 100644 utils/tmp/grandparent/build/imports/parent.aleo create mode 100644 utils/tmp/grandparent/build/imports/prog_a.aleo create mode 100644 utils/tmp/grandparent/build/imports/prog_b.aleo create mode 100644 utils/tmp/grandparent/build/main.aleo create mode 100644 utils/tmp/grandparent/build/program.json create mode 100644 utils/tmp/grandparent/inputs/import_example.in create mode 100644 utils/tmp/grandparent/leo.lock create mode 100644 utils/tmp/grandparent/parent/.gitignore create mode 100644 utils/tmp/grandparent/parent/README.md create mode 100644 utils/tmp/grandparent/parent/build/imports/a.aleo create mode 100644 utils/tmp/grandparent/parent/build/imports/child.aleo create mode 100644 utils/tmp/grandparent/parent/build/imports/prog_a.aleo create mode 100644 utils/tmp/grandparent/parent/build/main.aleo create mode 100644 utils/tmp/grandparent/parent/build/program.json create mode 100644 utils/tmp/grandparent/parent/child/.gitignore create mode 100644 utils/tmp/grandparent/parent/child/README.md create mode 100644 utils/tmp/grandparent/parent/child/build/main.aleo create mode 100644 utils/tmp/grandparent/parent/child/build/program.json create mode 100644 utils/tmp/grandparent/parent/child/inputs/a.in create mode 100644 utils/tmp/grandparent/parent/child/leo.lock create mode 100644 utils/tmp/grandparent/parent/child/program.json create mode 100644 utils/tmp/grandparent/parent/child/src/main.leo create mode 100644 utils/tmp/grandparent/parent/inputs/b.in create mode 100644 utils/tmp/grandparent/parent/leo.lock create mode 100644 utils/tmp/grandparent/parent/program.json create mode 100644 utils/tmp/grandparent/parent/src/main.leo create mode 100644 utils/tmp/grandparent/program.json create mode 100644 utils/tmp/grandparent/src/main.leo diff --git a/leo/cli/cli.rs b/leo/cli/cli.rs index dbcdf0d655..6d2c5a9102 100644 --- a/leo/cli/cli.rs +++ b/leo/cli/cli.rs @@ -180,3 +180,27 @@ pub fn mixed_local_network_build_test() -> Result<()> { Ok(()) } + +#[test] +pub fn double_nested_program_run_test() -> Result<()> { + use leo_span::symbol::create_session_if_not_set_then; + use crate::cli::commands::Run; + + let build_dir: PathBuf = PathBuf::from("utils").join("tmp").join("grandparent"); + let home_dir: PathBuf = PathBuf::from("utils").join("tmp").join(".aleo"); + + let cli = CLI { + debug: false, + quiet: false, + command: Commands::Run {command: Run { name: "double_wrapper_mint".to_string(), inputs: vec!["aleo1q30lfyggefvzzxqaaclzrn3wd94q4u8zzy8jhhfrcqrf306ayvqsdvj7s4".to_string(), "1u32".to_string()], compiler_options: Default::default() } }, + path: Some(build_dir), + home: Some(home_dir), + }; + + create_session_if_not_set_then(|_| { + run_with_args(cli).expect("Failed to run build command"); + }); + + Ok(()) +} + diff --git a/leo/cli/commands/run.rs b/leo/cli/commands/run.rs index ec27f4d812..ab8d243625 100644 --- a/leo/cli/commands/run.rs +++ b/leo/cli/commands/run.rs @@ -22,10 +22,10 @@ use snarkvm::cli::Run as SnarkVMRun; #[derive(Parser, Debug)] pub struct Run { #[clap(name = "NAME", help = "The name of the program to run.", default_value = "main")] - name: String, + pub(crate) name: String, #[clap(name = "INPUTS", help = "The inputs to the program. If none are provided, the input file is used.")] - inputs: Vec, + pub(crate) inputs: Vec, #[clap(flatten)] pub(crate) compiler_options: BuildOptions, diff --git a/utils/tmp/grandparent/.gitignore b/utils/tmp/grandparent/.gitignore new file mode 100644 index 0000000000..f721f7f6f4 --- /dev/null +++ b/utils/tmp/grandparent/.gitignore @@ -0,0 +1,5 @@ +.env +*.avm +*.prover +*.verifier +outputs/ diff --git a/utils/tmp/grandparent/README.md b/utils/tmp/grandparent/README.md new file mode 100644 index 0000000000..66ab9d73cc --- /dev/null +++ b/utils/tmp/grandparent/README.md @@ -0,0 +1,13 @@ +# import_example.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/utils/tmp/grandparent/build/imports/child.aleo b/utils/tmp/grandparent/build/imports/child.aleo new file mode 100644 index 0000000000..0f225259e6 --- /dev/null +++ b/utils/tmp/grandparent/build/imports/child.aleo @@ -0,0 +1,12 @@ +program child.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/build/imports/parent.aleo b/utils/tmp/grandparent/build/imports/parent.aleo new file mode 100644 index 0000000000..af6caa8688 --- /dev/null +++ b/utils/tmp/grandparent/build/imports/parent.aleo @@ -0,0 +1,10 @@ +import child.aleo; +program parent.aleo; + + + +function wrapper_mint: + input r0 as address.private; + input r1 as u32.private; + call child.aleo/mint aleo1q30lfyggefvzzxqaaclzrn3wd94q4u8zzy8jhhfrcqrf306ayvqsdvj7s4 1u32 into r2; + output r2 as child.aleo/A.record; diff --git a/utils/tmp/grandparent/build/imports/prog_a.aleo b/utils/tmp/grandparent/build/imports/prog_a.aleo new file mode 100644 index 0000000000..89f6ef9a46 --- /dev/null +++ b/utils/tmp/grandparent/build/imports/prog_a.aleo @@ -0,0 +1,12 @@ +program prog_a.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/build/imports/prog_b.aleo b/utils/tmp/grandparent/build/imports/prog_b.aleo new file mode 100644 index 0000000000..03f4c705fc --- /dev/null +++ b/utils/tmp/grandparent/build/imports/prog_b.aleo @@ -0,0 +1,10 @@ +import prog_a.aleo; +program prog_b.aleo; + + + +function wrapper_mint: + input r0 as address.private; + input r1 as u32.private; + call prog_a.aleo/mint aleo1q30lfyggefvzzxqaaclzrn3wd94q4u8zzy8jhhfrcqrf306ayvqsdvj7s4 1u32 into r2; + output r2 as prog_a.aleo/A.record; diff --git a/utils/tmp/grandparent/build/main.aleo b/utils/tmp/grandparent/build/main.aleo new file mode 100644 index 0000000000..4be6b74cb0 --- /dev/null +++ b/utils/tmp/grandparent/build/main.aleo @@ -0,0 +1,11 @@ +import child.aleo; +import parent.aleo; +program grandparent.aleo; + + + +function double_wrapper_mint: + input r0 as address.private; + input r1 as u32.private; + call parent.aleo/wrapper_mint r0 r1 into r2; + output r2 as child.aleo/A.record; diff --git a/utils/tmp/grandparent/build/program.json b/utils/tmp/grandparent/build/program.json new file mode 100644 index 0000000000..16a0e03c19 --- /dev/null +++ b/utils/tmp/grandparent/build/program.json @@ -0,0 +1,18 @@ +{ + "program": "grandparent.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT", + "dependencies": [ + { + "name": "child.aleo", + "location": "local", + "path": "parent/child" + }, + { + "name": "parent.aleo", + "location": "local", + "path": "parent" + } + ] +} diff --git a/utils/tmp/grandparent/inputs/import_example.in b/utils/tmp/grandparent/inputs/import_example.in new file mode 100644 index 0000000000..410e26eb54 --- /dev/null +++ b/utils/tmp/grandparent/inputs/import_example.in @@ -0,0 +1,4 @@ +// The program input for import_example/src/main.leo +[main] +public a: u32 = 1u32; +b: u32 = 2u32; diff --git a/utils/tmp/grandparent/leo.lock b/utils/tmp/grandparent/leo.lock new file mode 100644 index 0000000000..ac5676eed6 --- /dev/null +++ b/utils/tmp/grandparent/leo.lock @@ -0,0 +1,13 @@ +[[package]] +name = "child" +location = "local" +path = "parent/child" +checksum = "6341f6fcccbfa86b71e0eac445b9d0ee558c74ef896183ee82b456b9e7fb2270" +dependencies = [] + +[[package]] +name = "parent" +location = "local" +path = "parent" +checksum = "abf40f1784b1e58b97f55322cff031bb36d276d9986bdd8149c2d0cf3829a61e" +dependencies = ["child.aleo"] diff --git a/utils/tmp/grandparent/parent/.gitignore b/utils/tmp/grandparent/parent/.gitignore new file mode 100644 index 0000000000..f721f7f6f4 --- /dev/null +++ b/utils/tmp/grandparent/parent/.gitignore @@ -0,0 +1,5 @@ +.env +*.avm +*.prover +*.verifier +outputs/ diff --git a/utils/tmp/grandparent/parent/README.md b/utils/tmp/grandparent/parent/README.md new file mode 100644 index 0000000000..2972a57632 --- /dev/null +++ b/utils/tmp/grandparent/parent/README.md @@ -0,0 +1,13 @@ +# b.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/utils/tmp/grandparent/parent/build/imports/a.aleo b/utils/tmp/grandparent/parent/build/imports/a.aleo new file mode 100644 index 0000000000..0c6f006cc5 --- /dev/null +++ b/utils/tmp/grandparent/parent/build/imports/a.aleo @@ -0,0 +1,12 @@ +program a.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/parent/build/imports/child.aleo b/utils/tmp/grandparent/parent/build/imports/child.aleo new file mode 100644 index 0000000000..0f225259e6 --- /dev/null +++ b/utils/tmp/grandparent/parent/build/imports/child.aleo @@ -0,0 +1,12 @@ +program child.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/parent/build/imports/prog_a.aleo b/utils/tmp/grandparent/parent/build/imports/prog_a.aleo new file mode 100644 index 0000000000..89f6ef9a46 --- /dev/null +++ b/utils/tmp/grandparent/parent/build/imports/prog_a.aleo @@ -0,0 +1,12 @@ +program prog_a.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/parent/build/main.aleo b/utils/tmp/grandparent/parent/build/main.aleo new file mode 100644 index 0000000000..af6caa8688 --- /dev/null +++ b/utils/tmp/grandparent/parent/build/main.aleo @@ -0,0 +1,10 @@ +import child.aleo; +program parent.aleo; + + + +function wrapper_mint: + input r0 as address.private; + input r1 as u32.private; + call child.aleo/mint aleo1q30lfyggefvzzxqaaclzrn3wd94q4u8zzy8jhhfrcqrf306ayvqsdvj7s4 1u32 into r2; + output r2 as child.aleo/A.record; diff --git a/utils/tmp/grandparent/parent/build/program.json b/utils/tmp/grandparent/parent/build/program.json new file mode 100644 index 0000000000..e167242978 --- /dev/null +++ b/utils/tmp/grandparent/parent/build/program.json @@ -0,0 +1,13 @@ +{ + "program": "prog_b.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT", + "dependencies": [ + { + "name": "child.aleo", + "location": "local", + "path": "child" + } + ] +} diff --git a/utils/tmp/grandparent/parent/child/.gitignore b/utils/tmp/grandparent/parent/child/.gitignore new file mode 100644 index 0000000000..f721f7f6f4 --- /dev/null +++ b/utils/tmp/grandparent/parent/child/.gitignore @@ -0,0 +1,5 @@ +.env +*.avm +*.prover +*.verifier +outputs/ diff --git a/utils/tmp/grandparent/parent/child/README.md b/utils/tmp/grandparent/parent/child/README.md new file mode 100644 index 0000000000..1d165faf5d --- /dev/null +++ b/utils/tmp/grandparent/parent/child/README.md @@ -0,0 +1,13 @@ +# a.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/utils/tmp/grandparent/parent/child/build/main.aleo b/utils/tmp/grandparent/parent/child/build/main.aleo new file mode 100644 index 0000000000..0f225259e6 --- /dev/null +++ b/utils/tmp/grandparent/parent/child/build/main.aleo @@ -0,0 +1,12 @@ +program child.aleo; + +record A: + owner as address.private; + val as u32.private; + + +function mint: + input r0 as address.private; + input r1 as u32.private; + cast r0 r1 into r2 as A.record; + output r2 as A.record; diff --git a/utils/tmp/grandparent/parent/child/build/program.json b/utils/tmp/grandparent/parent/child/build/program.json new file mode 100644 index 0000000000..e38ad182bf --- /dev/null +++ b/utils/tmp/grandparent/parent/child/build/program.json @@ -0,0 +1,6 @@ +{ + "program": "child.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT" +} diff --git a/utils/tmp/grandparent/parent/child/inputs/a.in b/utils/tmp/grandparent/parent/child/inputs/a.in new file mode 100644 index 0000000000..edc7be126e --- /dev/null +++ b/utils/tmp/grandparent/parent/child/inputs/a.in @@ -0,0 +1,4 @@ +// The program input for a/src/main.leo +[main] +public a: u32 = 1u32; +b: u32 = 2u32; diff --git a/utils/tmp/grandparent/parent/child/leo.lock b/utils/tmp/grandparent/parent/child/leo.lock new file mode 100644 index 0000000000..c4293b3b9f --- /dev/null +++ b/utils/tmp/grandparent/parent/child/leo.lock @@ -0,0 +1 @@ +package = [] diff --git a/utils/tmp/grandparent/parent/child/program.json b/utils/tmp/grandparent/parent/child/program.json new file mode 100644 index 0000000000..e38ad182bf --- /dev/null +++ b/utils/tmp/grandparent/parent/child/program.json @@ -0,0 +1,6 @@ +{ + "program": "child.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT" +} diff --git a/utils/tmp/grandparent/parent/child/src/main.leo b/utils/tmp/grandparent/parent/child/src/main.leo new file mode 100644 index 0000000000..444a769ab8 --- /dev/null +++ b/utils/tmp/grandparent/parent/child/src/main.leo @@ -0,0 +1,10 @@ +// The 'a' program. +program child.aleo { + record A { + owner: address, + val: u32, + } + transition mint(owner: address, val: u32) -> A { + return A {owner: owner, val: val}; + } +} diff --git a/utils/tmp/grandparent/parent/inputs/b.in b/utils/tmp/grandparent/parent/inputs/b.in new file mode 100644 index 0000000000..64b61b9994 --- /dev/null +++ b/utils/tmp/grandparent/parent/inputs/b.in @@ -0,0 +1,4 @@ +// The program input for b/src/main.leo +[main] +public a: u32 = 1u32; +b: u32 = 2u32; diff --git a/utils/tmp/grandparent/parent/leo.lock b/utils/tmp/grandparent/parent/leo.lock new file mode 100644 index 0000000000..736e4355a7 --- /dev/null +++ b/utils/tmp/grandparent/parent/leo.lock @@ -0,0 +1,6 @@ +[[package]] +name = "child" +location = "local" +path = "parent/child" +checksum = "6341f6fcccbfa86b71e0eac445b9d0ee558c74ef896183ee82b456b9e7fb2270" +dependencies = [] diff --git a/utils/tmp/grandparent/parent/program.json b/utils/tmp/grandparent/parent/program.json new file mode 100644 index 0000000000..0131497fc8 --- /dev/null +++ b/utils/tmp/grandparent/parent/program.json @@ -0,0 +1,13 @@ +{ + "program": "parent.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT", + "dependencies": [ + { + "name": "child.aleo", + "location": "local", + "path": "child" + } + ] +} diff --git a/utils/tmp/grandparent/parent/src/main.leo b/utils/tmp/grandparent/parent/src/main.leo new file mode 100644 index 0000000000..872de90655 --- /dev/null +++ b/utils/tmp/grandparent/parent/src/main.leo @@ -0,0 +1,7 @@ +// The 'b' program. +import child.aleo; +program parent.aleo { + transition wrapper_mint(owner: address, val: u32) -> child.aleo/A { + return child.aleo/mint(aleo1q30lfyggefvzzxqaaclzrn3wd94q4u8zzy8jhhfrcqrf306ayvqsdvj7s4, 1u32); + } +} diff --git a/utils/tmp/grandparent/program.json b/utils/tmp/grandparent/program.json new file mode 100644 index 0000000000..16a0e03c19 --- /dev/null +++ b/utils/tmp/grandparent/program.json @@ -0,0 +1,18 @@ +{ + "program": "grandparent.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT", + "dependencies": [ + { + "name": "child.aleo", + "location": "local", + "path": "parent/child" + }, + { + "name": "parent.aleo", + "location": "local", + "path": "parent" + } + ] +} diff --git a/utils/tmp/grandparent/src/main.leo b/utils/tmp/grandparent/src/main.leo new file mode 100644 index 0000000000..655d7cfb69 --- /dev/null +++ b/utils/tmp/grandparent/src/main.leo @@ -0,0 +1,8 @@ +// The 'import_example' program. +import child.aleo; +import parent.aleo; +program grandparent.aleo { + transition double_wrapper_mint(owner: address, val: u32) -> child.aleo/A { + return parent.aleo/wrapper_mint(owner,val); + } +}