This commit is contained in:
evan-schott 2023-12-15 20:47:11 -08:00
parent 7954539458
commit 6922569eff
33 changed files with 324 additions and 2 deletions

View File

@ -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(())
}

View File

@ -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,

5
utils/tmp/grandparent/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/

View File

@ -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
```

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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"
}
]
}

View File

@ -0,0 +1,4 @@
// The program input for import_example/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;

View File

@ -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"]

View File

@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/

View File

@ -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
```

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,13 @@
{
"program": "prog_b.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT",
"dependencies": [
{
"name": "child.aleo",
"location": "local",
"path": "child"
}
]
}

View File

@ -0,0 +1,5 @@
.env
*.avm
*.prover
*.verifier
outputs/

View File

@ -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
```

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"program": "child.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -0,0 +1,4 @@
// The program input for a/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;

View File

@ -0,0 +1 @@
package = []

View File

@ -0,0 +1,6 @@
{
"program": "child.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -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};
}
}

View File

@ -0,0 +1,4 @@
// The program input for b/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;

View File

@ -0,0 +1,6 @@
[[package]]
name = "child"
location = "local"
path = "parent/child"
checksum = "6341f6fcccbfa86b71e0eac445b9d0ee558c74ef896183ee82b456b9e7fb2270"
dependencies = []

View File

@ -0,0 +1,13 @@
{
"program": "parent.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT",
"dependencies": [
{
"name": "child.aleo",
"location": "local",
"path": "child"
}
]
}

View File

@ -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);
}
}

View File

@ -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"
}
]
}

View File

@ -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);
}
}