Skip to content

Commit

Permalink
Add support to specify private key in tests; regen expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
d0cd committed Sep 29, 2023
1 parent 7994e5b commit f3b4533
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
14 changes: 8 additions & 6 deletions compiler/compiler/tests/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
.map(|input| console::program::Value::<Network>::from_str(input.as_str().unwrap()).unwrap())
.collect();
let input_string = format!("[{}]", inputs.iter().map(|input| input.to_string()).join(", "));
let private_key = match case.get(&Value::from("private_key")) {
Some(private_key) => {
PrivateKey::from_str(private_key.as_str().expect("expected string for private key"))
.expect("unable to parse private key")
}
None => dotenv_private_key(package.directory()).unwrap(),
};

// TODO: Add support for custom config like custom private keys.
// Execute the program and get the outputs.
let output_string = match package.run::<Aleo, _>(
&dotenv_private_key(package.directory()).unwrap(),
function_name,
&inputs,
rng,
) {
let output_string = match package.run::<Aleo, _>(&private_key, function_name, &inputs, rng) {
Ok((response, _)) => format!(
"[{}]",
response
Expand Down
8 changes: 4 additions & 4 deletions tests/expectations/execution/counter.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ outputs:
results:
dubble:
- input: "[]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo1ujk4sm9yqm49au0jw36freu2k5pzvfeut4hymuxxxwxqmztndc8qgfyjwy\n ]\n}]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo17z49cl3wfpjdyu5juxaxnuttag24ygz36pg8ln2qmlcsw4w8cs9s3f45uq\n ]\n}]"
- input: "[]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo1ujk4sm9yqm49au0jw36freu2k5pzvfeut4hymuxxxwxqmztndc8qgfyjwy\n ]\n}]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo17z49cl3wfpjdyu5juxaxnuttag24ygz36pg8ln2qmlcsw4w8cs9s3f45uq\n ]\n}]"
- input: "[]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo1ujk4sm9yqm49au0jw36freu2k5pzvfeut4hymuxxxwxqmztndc8qgfyjwy\n ]\n}]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo17z49cl3wfpjdyu5juxaxnuttag24ygz36pg8ln2qmlcsw4w8cs9s3f45uq\n ]\n}]"
- input: "[]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo1ujk4sm9yqm49au0jw36freu2k5pzvfeut4hymuxxxwxqmztndc8qgfyjwy\n ]\n}]"
output: "[{\n program_id: test.aleo,\n function_name: dubble,\n arguments: [\n aleo17z49cl3wfpjdyu5juxaxnuttag24ygz36pg8ln2qmlcsw4w8cs9s3f45uq\n ]\n}]"
4 changes: 4 additions & 0 deletions tests/tests/execution/counter.leo
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ initial_state:
cases:
dubble:
- input: []
private_key: APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE
- input: []
private_key: APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE
- input: []
private_key: APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE
- input: []
private_key: APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE
*/

program test.aleo {
Expand Down

0 comments on commit f3b4533

Please sign in to comment.