File tree Expand file tree Collapse file tree 6 files changed +73
-0
lines changed
Expand file tree Collapse file tree 6 files changed +73
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -22,3 +22,6 @@ pub use plaintext::*;
2222
2323pub mod programs;
2424pub use programs:: * ;
25+
26+ pub mod uri;
27+ pub use uri:: * ;
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ use crate::{array, object};
1818
1919use 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+
2129pub const PUZZLE_SPINNER_V002 : & str = r#"import puzzle_arcade_coin_v002.aleo;
2230import puzzle_arcade_ticket_v002.aleo;
2331
Original file line number Diff line number Diff line change 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" ;
You can’t perform that action at this time.
0 commit comments