Skip to content

Commit

Permalink
run test
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-schott committed Dec 16, 2023
1 parent 7954539 commit 6922569
Show file tree
Hide file tree
Showing 33 changed files with 324 additions and 2 deletions.
24 changes: 24 additions & 0 deletions leo/cli/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

4 changes: 2 additions & 2 deletions leo/cli/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub(crate) inputs: Vec<String>,

#[clap(flatten)]
pub(crate) compiler_options: BuildOptions,
Expand Down
5 changes: 5 additions & 0 deletions utils/tmp/grandparent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/README.md
Original file line number Diff line number Diff line change
@@ -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
```
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/build/imports/child.aleo
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions utils/tmp/grandparent/build/imports/parent.aleo
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/build/imports/prog_a.aleo
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions utils/tmp/grandparent/build/imports/prog_b.aleo
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions utils/tmp/grandparent/build/main.aleo
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 18 additions & 0 deletions utils/tmp/grandparent/build/program.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
4 changes: 4 additions & 0 deletions utils/tmp/grandparent/inputs/import_example.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// The program input for import_example/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/leo.lock
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 5 additions & 0 deletions utils/tmp/grandparent/parent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/parent/README.md
Original file line number Diff line number Diff line change
@@ -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
```
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/parent/build/imports/a.aleo
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/parent/build/imports/child.aleo
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/parent/build/imports/prog_a.aleo
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions utils/tmp/grandparent/parent/build/main.aleo
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/parent/build/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"program": "prog_b.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT",
"dependencies": [
{
"name": "child.aleo",
"location": "local",
"path": "child"
}
]
}
5 changes: 5 additions & 0 deletions utils/tmp/grandparent/parent/child/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/parent/child/README.md
Original file line number Diff line number Diff line change
@@ -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
```
12 changes: 12 additions & 0 deletions utils/tmp/grandparent/parent/child/build/main.aleo
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions utils/tmp/grandparent/parent/child/build/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"program": "child.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
4 changes: 4 additions & 0 deletions utils/tmp/grandparent/parent/child/inputs/a.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// The program input for a/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;
1 change: 1 addition & 0 deletions utils/tmp/grandparent/parent/child/leo.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package = []
6 changes: 6 additions & 0 deletions utils/tmp/grandparent/parent/child/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"program": "child.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
10 changes: 10 additions & 0 deletions utils/tmp/grandparent/parent/child/src/main.leo
Original file line number Diff line number Diff line change
@@ -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};
}
}
4 changes: 4 additions & 0 deletions utils/tmp/grandparent/parent/inputs/b.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// The program input for b/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;
6 changes: 6 additions & 0 deletions utils/tmp/grandparent/parent/leo.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[package]]
name = "child"
location = "local"
path = "parent/child"
checksum = "6341f6fcccbfa86b71e0eac445b9d0ee558c74ef896183ee82b456b9e7fb2270"
dependencies = []
13 changes: 13 additions & 0 deletions utils/tmp/grandparent/parent/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"program": "parent.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT",
"dependencies": [
{
"name": "child.aleo",
"location": "local",
"path": "child"
}
]
}
7 changes: 7 additions & 0 deletions utils/tmp/grandparent/parent/src/main.leo
Original file line number Diff line number Diff line change
@@ -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);
}
}
18 changes: 18 additions & 0 deletions utils/tmp/grandparent/program.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
8 changes: 8 additions & 0 deletions utils/tmp/grandparent/src/main.leo
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 6922569

Please sign in to comment.