WIP removing input files from examples

This commit is contained in:
Pranav Gaddamadugu 2023-09-29 11:13:49 -04:00 committed by Pranav Gaddamadugu
parent e4ddfcda25
commit e8a46b7628
28 changed files with 39 additions and 200 deletions

View File

@ -1,26 +1,26 @@
# Leo Examples
This directory includes the following Leo code examples:
This directory includes the following Leo code including:
1. Hello World -> Basic Sum of two u32
2. Groups -> Basic operations over groups
3. Core -> Core functions over a field type
4. Bubblesort -> Sorting algorithms over a tuple
5. Import point -> Import code from another file
6. Message -> Initialization of a struct
7. Token -> Record example
5. Message -> Initialization of a struct
6. Token -> Record example
along with many more.
## Run Guide
To run each program, run:
```bash
leo run main
leo run main <inputs>
```
This command will look in the input file inputs/*.in where should find a section [main] and use the variables as inputs to the program.
## Execute Guide
To execute each program call, run:
```bash
leo execute main <inputs> --endpoint <endpoint>
```
leo execute main <inputs>
```

View File

@ -36,7 +36,6 @@ The auction is conducted in a series of stages.
## Running the Program
Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in `inputs/`.
### Configuring Accounts
The `.env` file contains a private key.
@ -50,16 +49,9 @@ To generate a new account, navigate to [aleo.tools](https://aleo.tools).
### Providing inputs via the command line.
1. Run
```bash
leo run <function_name> <input_1> <input_2> ...
```
See `./run.sh` for an example.
### Using an input file.
1. Modify `inputs/auction.in` with the desired inputs.
2. Run
```bash
leo run <function_name>
```

View File

@ -37,7 +37,6 @@ Can you find any others?
## Running the Program
Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in `inputs/`.
### Configuring Accounts
The `.env` file contains a private key.
@ -50,22 +49,7 @@ The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides an interfac
To generate a new account, navigate to [aleo.tools](https://aleo.tools).
### Providing inputs via the command line.
1. Run
```bash
leo run <function_name> <input_1> <input_2> ...
```
See `./run.sh` for an example.
### Using an input file.
1. Modify `inputs/auction.in` with the desired inputs.
2. Run
```bash
leo run <function_name>
```
For example,
```bash
leo run issue
leo run deposit
leo run withdraw
```

View File

@ -1,12 +1,3 @@
// The program input for bubblesort_tuple/src/main.leo
[bubble_sort]
arr0: u32 = 13u32;
arr1: u32 = 2u32;
arr2: u32 = 4u32;
arr3: u32 = 3u32;
arr4: u32 = 5u32;
arr5: u32 = 10u32;
arr6: u32 = 7u32;
arr7: u32 = 1u32;
13u32 2u32 4u32 3u32 5u32 10u32 7u32 1u32

View File

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

View File

@ -1,3 +1 @@
// The program input for fibonacci/src/main.leo
[fibonacci]
public n: u8 = 63u8;
63u8

View File

@ -1,4 +1 @@
// The program input for groups/src/main.leo
// Leo will use provided string as the x coordinate and attempt to recover the y coordinate to form a group.
[main]
a: group = 1817767092074430972953743941103352519057913259183777531581123188265134806220group;
1817767092074430972953743941103352519057913259183777531581123188265134806220group

View File

@ -1,3 +1 @@
// The program input for ntzdebruijn/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for ntzgaudet/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for ntzloops/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for ntzmasks/src/main.leo
[main]
public x: u32 = 1073741824u32;
1073741824u32

View File

@ -1,3 +1 @@
// The program input for ntzreisers/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for nztseals/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for ntzsearchtree/src/main.leo
[main]
public z: u32 = 2147483648u32;
2147483648u32

View File

@ -1,3 +1 @@
// The program input for ntzsmallvals/src/main.leo
[main]
public x: u32 = 2147483648u32;
2147483648u32

View File

@ -1,4 +1 @@
// The program input for helloworld/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32; // Input variable `b` is private by default.
1u32 2u32

View File

@ -0,0 +1 @@
80u32 5u32 10u8

View File

@ -1,9 +1 @@
// The program input for interest/src/main.leo
[fixed_iteration_interest]
capital: u32 = 80u32;
rate: u32 = 5u32; // 5%
[bounded_iteration_interest]
capital: u32 = 80u32;
rate: u32 = 5u32; // 5%
iterations: u8 = 10u8;
80u32 5u32

View File

@ -1,7 +1 @@
// The program input for message/src/main.leo
// To pass "m" into the "main" function we
// 1. Define the "Message" type.
// 2. Use brackets `{ }` to enclose the struct members.
// 3. Define each struct member `name : value`.
[main]
m: Message = Message { first: 2field, second: 3field };
"{ first: 2field, second: 3field }"

View File

@ -0,0 +1 @@
aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau 100u64

View File

@ -1,13 +1,5 @@
// The program input for simple_token/src/main.leo
[mint]
owner: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau;
amount: u64 = 100u64;
[transfer]
token: Token = Token {
"{
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
amount: 100u64,
_nonce: 0group,
};
to: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau;
amount: u64 = 50u64;
}" aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau 50u64

View File

@ -27,23 +27,13 @@ An alternative representation would be to use an array, however, these are not y
## Running the Program
Leo provides users with a command line interface for compiling and running Leo programs.
Users may either specify input values via the command line or provide an input file in `inputs/`.
### Providing inputs via the command line.
1. Run
```bash
leo run <function_name> <input_1> <input_2> ...
```
See `./run.sh` for an example.
### Using an input file.
1. Modify `inputs/tictactoe.in` with the desired inputs.
2. Run
```bash
leo run <function_name>
```
## Executing the Program
```bash
leo execute <function_name> <input_1> <input_2> ...

View File

@ -1,18 +1,6 @@
// The `new` function does not take any inputs.
[new]
// Inputs for the `make_move` function.
// - `player` : A u8 representing the player making the move. 1 for player 1, 2 for player 2.
// - `row` : A u8 representing the row to make the move in.
// - `column` : A u8 representing the column to make the move in.
// - `board` : A representation of the board state.
[make_move]
player: u8 = 1u8;
row: u8 = 1u8;
col: u8 = 1u8;
board: Board = Board {
1u8 1u8 1u8 "{
r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
};
}"

View File

@ -1,11 +1 @@
// The program input for twoadicity/src/main.leo
[main]
// Here is a made-up example.
// public a: field = 391995973843653359517682711560178397928211734490775552field;
// (comes from: 2field.pow(41) * 178259130663561045147472537592047227885001field)
// This example is (maxfield - 1).
// The output for this can be seen in the Pratt certificate
// for bls12-377-scalar-field-prime
// as the number of factors of 2 in (bls12-377-scalar-field-prime - 1).
public a: field = 8444461749428370424248824938781546531375899335154063827935233455917409239040field;
8444461749428370424248824938781546531375899335154063827935233455917409239040field

View File

@ -0,0 +1,5 @@
"{
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field,
_nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group
}"

View File

@ -0,0 +1 @@
2264670486490520844857553240576860973319410481267184439818180411609250173817field aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau

View File

@ -1,25 +1,5 @@
// The program input for vote/src/main.leo
[propose]
info: ProposalInfo = ProposalInfo {
"{
title: 2077160157502449938194577302446444field,
content: 1452374294790018907888397545906607852827800436field,
proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2,
};
[new_ticket]
pid: field = 2264670486490520844857553240576860973319410481267184439818180411609250173817field;
voter: address = aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau;
[agree]
ticket: Ticket = Ticket {
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field,
_nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group
};
[disagree]
ticket: Ticket = Ticket {
owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau,
pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field,
_nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group
};
}"

View File

@ -61,45 +61,9 @@ Parser Directory namespaces:
- `ParseExpression` - Test a file line by line to check that each line is a valid Leo expression.
- `ParseStatement` - Test a file consuming multiple lines till a blank line to check that it contains a valid Leo statement.
- `Serialize` - Test a file to check that it can be serialized to JSON.
- `Input` - Test an input file to check that it is a valid Leo input file.
- `Token` - Test a file line by line to check that it contains zero or more valid Leo parser tokens.
Compiler Directory namespaces:
- `Compiler` - Test a file to check that it is a valid Leo program, and it can be compiled without errors.
### expectation
```yaml
- Mandatory: yes
- Namespace: all
- Values: Pass / Fail
```
This setting indicates whether the tested code is supposed to succeed or to fail.
If the test was marked as `Pass` but it actually failed,
you'll know that something went wrong and the test or the compiler/parser needs fixing.
### input_file (Compile)
```yaml
- Mandatory: no
- Namespace: Compile
- Values: <input file path>, ...
```
This setting allows using one or more input files for the Leo program.
The program will be run with every provided input.
See this example:
```yaml
/*
namespace: Compile
expectation: Pass
input_file:
- inputs/a_0.in
- inputs/a_1.in
*/
function main(a: u32) {}
```
- `Execute` - Test a file to check that it is a valid Leo program, and it can be compiled and executed without errors.