mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 15:15:47 +03:00
run test
This commit is contained in:
parent
7954539458
commit
6922569eff
@ -180,3 +180,27 @@ pub fn mixed_local_network_build_test() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ use snarkvm::cli::Run as SnarkVMRun;
|
|||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
pub struct Run {
|
pub struct Run {
|
||||||
#[clap(name = "NAME", help = "The name of the program to run.", default_value = "main")]
|
#[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.")]
|
#[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)]
|
#[clap(flatten)]
|
||||||
pub(crate) compiler_options: BuildOptions,
|
pub(crate) compiler_options: BuildOptions,
|
||||||
|
5
utils/tmp/grandparent/.gitignore
vendored
Normal file
5
utils/tmp/grandparent/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.env
|
||||||
|
*.avm
|
||||||
|
*.prover
|
||||||
|
*.verifier
|
||||||
|
outputs/
|
13
utils/tmp/grandparent/README.md
Normal file
13
utils/tmp/grandparent/README.md
Normal 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
|
||||||
|
```
|
12
utils/tmp/grandparent/build/imports/child.aleo
Normal file
12
utils/tmp/grandparent/build/imports/child.aleo
Normal 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;
|
10
utils/tmp/grandparent/build/imports/parent.aleo
Normal file
10
utils/tmp/grandparent/build/imports/parent.aleo
Normal 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;
|
12
utils/tmp/grandparent/build/imports/prog_a.aleo
Normal file
12
utils/tmp/grandparent/build/imports/prog_a.aleo
Normal 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;
|
10
utils/tmp/grandparent/build/imports/prog_b.aleo
Normal file
10
utils/tmp/grandparent/build/imports/prog_b.aleo
Normal 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;
|
11
utils/tmp/grandparent/build/main.aleo
Normal file
11
utils/tmp/grandparent/build/main.aleo
Normal 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;
|
18
utils/tmp/grandparent/build/program.json
Normal file
18
utils/tmp/grandparent/build/program.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
4
utils/tmp/grandparent/inputs/import_example.in
Normal file
4
utils/tmp/grandparent/inputs/import_example.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// The program input for import_example/src/main.leo
|
||||||
|
[main]
|
||||||
|
public a: u32 = 1u32;
|
||||||
|
b: u32 = 2u32;
|
13
utils/tmp/grandparent/leo.lock
Normal file
13
utils/tmp/grandparent/leo.lock
Normal 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"]
|
5
utils/tmp/grandparent/parent/.gitignore
vendored
Normal file
5
utils/tmp/grandparent/parent/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.env
|
||||||
|
*.avm
|
||||||
|
*.prover
|
||||||
|
*.verifier
|
||||||
|
outputs/
|
13
utils/tmp/grandparent/parent/README.md
Normal file
13
utils/tmp/grandparent/parent/README.md
Normal 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
|
||||||
|
```
|
12
utils/tmp/grandparent/parent/build/imports/a.aleo
Normal file
12
utils/tmp/grandparent/parent/build/imports/a.aleo
Normal 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;
|
12
utils/tmp/grandparent/parent/build/imports/child.aleo
Normal file
12
utils/tmp/grandparent/parent/build/imports/child.aleo
Normal 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;
|
12
utils/tmp/grandparent/parent/build/imports/prog_a.aleo
Normal file
12
utils/tmp/grandparent/parent/build/imports/prog_a.aleo
Normal 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;
|
10
utils/tmp/grandparent/parent/build/main.aleo
Normal file
10
utils/tmp/grandparent/parent/build/main.aleo
Normal 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;
|
13
utils/tmp/grandparent/parent/build/program.json
Normal file
13
utils/tmp/grandparent/parent/build/program.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"program": "prog_b.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": [
|
||||||
|
{
|
||||||
|
"name": "child.aleo",
|
||||||
|
"location": "local",
|
||||||
|
"path": "child"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
5
utils/tmp/grandparent/parent/child/.gitignore
vendored
Normal file
5
utils/tmp/grandparent/parent/child/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.env
|
||||||
|
*.avm
|
||||||
|
*.prover
|
||||||
|
*.verifier
|
||||||
|
outputs/
|
13
utils/tmp/grandparent/parent/child/README.md
Normal file
13
utils/tmp/grandparent/parent/child/README.md
Normal 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
|
||||||
|
```
|
12
utils/tmp/grandparent/parent/child/build/main.aleo
Normal file
12
utils/tmp/grandparent/parent/child/build/main.aleo
Normal 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;
|
6
utils/tmp/grandparent/parent/child/build/program.json
Normal file
6
utils/tmp/grandparent/parent/child/build/program.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"program": "child.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
4
utils/tmp/grandparent/parent/child/inputs/a.in
Normal file
4
utils/tmp/grandparent/parent/child/inputs/a.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// The program input for a/src/main.leo
|
||||||
|
[main]
|
||||||
|
public a: u32 = 1u32;
|
||||||
|
b: u32 = 2u32;
|
1
utils/tmp/grandparent/parent/child/leo.lock
Normal file
1
utils/tmp/grandparent/parent/child/leo.lock
Normal file
@ -0,0 +1 @@
|
|||||||
|
package = []
|
6
utils/tmp/grandparent/parent/child/program.json
Normal file
6
utils/tmp/grandparent/parent/child/program.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"program": "child.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
10
utils/tmp/grandparent/parent/child/src/main.leo
Normal file
10
utils/tmp/grandparent/parent/child/src/main.leo
Normal 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};
|
||||||
|
}
|
||||||
|
}
|
4
utils/tmp/grandparent/parent/inputs/b.in
Normal file
4
utils/tmp/grandparent/parent/inputs/b.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// The program input for b/src/main.leo
|
||||||
|
[main]
|
||||||
|
public a: u32 = 1u32;
|
||||||
|
b: u32 = 2u32;
|
6
utils/tmp/grandparent/parent/leo.lock
Normal file
6
utils/tmp/grandparent/parent/leo.lock
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[[package]]
|
||||||
|
name = "child"
|
||||||
|
location = "local"
|
||||||
|
path = "parent/child"
|
||||||
|
checksum = "6341f6fcccbfa86b71e0eac445b9d0ee558c74ef896183ee82b456b9e7fb2270"
|
||||||
|
dependencies = []
|
13
utils/tmp/grandparent/parent/program.json
Normal file
13
utils/tmp/grandparent/parent/program.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"program": "parent.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": [
|
||||||
|
{
|
||||||
|
"name": "child.aleo",
|
||||||
|
"location": "local",
|
||||||
|
"path": "child"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
7
utils/tmp/grandparent/parent/src/main.leo
Normal file
7
utils/tmp/grandparent/parent/src/main.leo
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
18
utils/tmp/grandparent/program.json
Normal file
18
utils/tmp/grandparent/program.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
8
utils/tmp/grandparent/src/main.leo
Normal file
8
utils/tmp/grandparent/src/main.leo
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user