mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 05:45:30 +03:00
Commit leo example tests (#2524)
* commit leo example tests * improve leo example readme's and ci * commit leo token example script
This commit is contained in:
parent
a601ccd5cc
commit
12570e4602
@ -3,8 +3,8 @@ $LEO new foo || exit
|
||||
ls -la
|
||||
cd foo && ls -la
|
||||
|
||||
# Run `leo build`.
|
||||
$LEO build || exit
|
||||
# Run `leo run`.
|
||||
$LEO run || exit
|
||||
|
||||
# Assert that the 'build' folder exists.
|
||||
if [ "$(ls -A build)" ]; then
|
||||
|
32
.circleci/leo-example.sh
Normal file
32
.circleci/leo-example.sh
Normal file
@ -0,0 +1,32 @@
|
||||
(
|
||||
# Create a new Leo lottery example program.
|
||||
$LEO example lottery || exit
|
||||
ls -la
|
||||
cd lottery && ls -la
|
||||
|
||||
# Run the play function.
|
||||
$LEO run play || exit
|
||||
)
|
||||
|
||||
(
|
||||
# Create a new Leo tictactoe example program.
|
||||
$LEO example tictactoe || exit
|
||||
ls -la
|
||||
cd tictactoe && ls -la
|
||||
|
||||
# Create a new game.
|
||||
$LEO run new || exit
|
||||
|
||||
# Create a make a move.
|
||||
$LEO run make_move || exit
|
||||
)
|
||||
|
||||
(
|
||||
#Create a new Leo token example program.
|
||||
$LEO example token || exit
|
||||
ls -la
|
||||
cd token && ls -la
|
||||
|
||||
# Run the mint_public function.
|
||||
$LEO run mint_public || exit
|
||||
)
|
@ -48,3 +48,35 @@ leo run <function_name>
|
||||
```bash
|
||||
leo execute <function_name> <input_1> <input_2> ...
|
||||
```
|
||||
|
||||
## Playing the Game
|
||||
|
||||
### 1. Create a new game board
|
||||
```bash
|
||||
leo run new
|
||||
```
|
||||
| | | |
|
||||
|---|---|---|
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 0 | 0 |
|
||||
|
||||
### 2. Player 1 makes a move
|
||||
```bash
|
||||
leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
|
||||
```
|
||||
| | | |
|
||||
|---|---|---|
|
||||
| 1 | 0 | 0 |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 0 | 0 |
|
||||
|
||||
### 3. Player 2 makes a move
|
||||
```bash
|
||||
leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }"
|
||||
```
|
||||
| | | |
|
||||
|---|---|---|
|
||||
| 1 | 0 | 0 |
|
||||
| 0 | 2 | 0 |
|
||||
| 0 | 0 | 0 |
|
||||
|
@ -11,8 +11,8 @@ player: u8 = 1u8;
|
||||
row: u8 = 1u8;
|
||||
col: u8 = 1u8;
|
||||
board: Board = Board {
|
||||
r1: Row { c1: 0u8, c2: 1u8, c3: 1u8 },
|
||||
r2: Row { c1: 2u8, c2: 2u8, c3: 0u8 },
|
||||
r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
|
||||
r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
|
||||
r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 },
|
||||
};
|
||||
|
||||
|
@ -8,12 +8,5 @@ A transparent & shielded custom token in Leo.
|
||||
|
||||
To run this program, run:
|
||||
```bash
|
||||
leo run main
|
||||
```
|
||||
|
||||
## Execute Guide
|
||||
|
||||
To execute this program, run:
|
||||
```bash
|
||||
leo execute main
|
||||
```
|
||||
./run.sh
|
||||
```
|
@ -49,7 +49,7 @@ impl Command for Example {
|
||||
fs::write(main_file_path, self.main_file_string()).map_err(CliError::failed_to_write_file)?;
|
||||
|
||||
// Write the input file.
|
||||
let input_file_path = package_dir.join("inputs").join("input.in");
|
||||
let input_file_path = package_dir.join("inputs").join(format!("{}.in", self.name()));
|
||||
fs::write(input_file_path, self.input_file_string()).map_err(CliError::failed_to_write_file)?;
|
||||
|
||||
// Write the README file.
|
||||
@ -98,9 +98,7 @@ impl Example {
|
||||
Self::TicTacToe => {
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/tictactoe/inputs/tictactoe.in")).to_string()
|
||||
}
|
||||
Self::Token => {
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/inputs/token.in")).to_string()
|
||||
}
|
||||
Self::Token => include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/examples/token/run.sh")).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user