Skip to content

Commit 17478fc

Browse files
Add programs twice to ensure the edition is updated to one
1 parent 8976c0d commit 17478fc

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

wasm/src/programs/macros.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ macro_rules! authorize {
5454
if !$process.contains_program(program.id()) {
5555
log("Adding program to the process");
5656
$process.add_program(&program).map_err(|e| e.to_string())?;
57+
$process.add_program(&program).map_err(|e| e.to_string())?;
5758
}
5859
}
5960

@@ -138,6 +139,7 @@ macro_rules! execute_program {
138139
if !$process.contains_program(program.id()) {
139140
log("Adding program to the process");
140141
$process.add_program(&program).map_err(|e| e.to_string())?;
142+
$process.add_program(&program).map_err(|e| e.to_string())?;
141143
}
142144
}
143145

wasm/src/programs/manager/execute.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,45 @@ impl ProgramManager {
365365
cost_in_microcredits_v2(&stack, &function_id).map_err(|e| e.to_string())
366366
}
367367
}
368+
369+
#[cfg(test)]
370+
mod tests {
371+
use super::*;
372+
use crate::{
373+
Metadata,
374+
array,
375+
utilities::test::{HELLO_PROGRAM, PROVABLE_API},
376+
};
377+
378+
async fn test_execute_added_program() {
379+
// Generate the private key.
380+
let private_key = PrivateKey::new();
381+
382+
// Download the fee prover.
383+
let fee_prover_uri = Metadata::fee_public().prover;
384+
let fee_proving_key_bytes = reqwest::get(fee_prover_uri).await.unwrap().bytes().await.unwrap().to_vec();
385+
let fee_prover = ProvingKey::from_bytes(&fee_proving_key_bytes).unwrap();
386+
let fee_verifier = VerifyingKey::fee_public_verifier();
387+
388+
// Create the execution.
389+
let transaction = ProgramManager::execute(
390+
&private_key,
391+
HELLO_PROGRAM,
392+
"main",
393+
array!["5u32", "5u32"],
394+
0.0,
395+
None,
396+
Some(PROVABLE_API.to_string()),
397+
None,
398+
None,
399+
None,
400+
Some(fee_prover),
401+
Some(fee_verifier),
402+
None,
403+
)
404+
.await
405+
.unwrap();
406+
407+
assert!(transaction.is_execute());
408+
}
409+
}

wasm/src/programs/manager/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ impl ProgramManager {
118118
// If the process does not already contain the program, add it
119119
if !process.contains_program(import.id()) {
120120
process.add_program(&import).map_err(|err| err.to_string())?;
121+
process.add_program(&import).map_err(|err| err.to_string())?;
121122
}
122123
}
123124
}

wasm/src/utilities/test/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ pub use plaintext::*;
2222

2323
pub mod programs;
2424
pub use programs::*;
25+
26+
pub mod uri;
27+
pub use uri::*;

wasm/src/utilities/test/programs.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ use crate::{array, object};
1818

1919
use js_sys::{Array, Object};
2020

21+
pub const HELLO_PROGRAM: &str = r#"program hello.aleo;
22+
function main:
23+
input r0 as u32.public;
24+
input r1 as u32.private;
25+
add r0 r1 into r2;
26+
output r2 as u32.private;
27+
"#;
28+
2129
pub const PUZZLE_SPINNER_V002: &str = r#"import puzzle_arcade_coin_v002.aleo;
2230
import puzzle_arcade_ticket_v002.aleo;
2331

wasm/src/utilities/test/uri.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2019-2025 Provable Inc.
2+
// This file is part of the Provable SDK library.
3+
4+
// The Provable SDK library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// The Provable SDK library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with the Provable SDK library. If not, see <https://www.gnu.org/licenses/>.
16+
17+
pub const PROVABLE_API: &str = "https://api.explorer.provable.com/v1";

0 commit comments

Comments
 (0)