File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " Iroha_2_examples"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ [dependencies ]
7
+ iroha_data_model = { "git" = " https://github.com/hyperledger/iroha.git" , branch = " iroha2-dev" }
8
+ iroha_client = { "git" = " https://github.com/hyperledger/iroha.git" , branch = " iroha2-dev" }
9
+ iroha_config = { "git" = " https://github.com/hyperledger/iroha.git" , branch = " iroha2-dev" }
10
+
11
+ eyre = " 0.6.8"
12
+
13
+ serde = { version = " 1.0.151" , default-features = false }
14
+ serde_json = { version = " 1.0.91" , default-features = false }
Original file line number Diff line number Diff line change
1
+ use std:: fs:: File ;
2
+ use eyre:: { Error , WrapErr } ;
3
+ use iroha_config:: client:: Configuration ;
4
+ use iroha_data_model:: TryToValue ;
5
+
6
+ fn main ( ) {
7
+ // #region rust_config_load
8
+ let config_loc = "../configs/client/config.json" ;
9
+ let file = File :: open ( config_loc)
10
+ . wrap_err ( "Unable to load the configuration file at `.....`" )
11
+ . expect ( "Config file is loading normally." ) ;
12
+ let config: Configuration = serde_json:: from_reader ( file)
13
+ . wrap_err ( "Failed to parse `../configs/client/config.json`" )
14
+ . expect ( "Verified in tests" ) ;
15
+ // #endregion rust_config_load
16
+
17
+ json_config_client_test ( & config)
18
+ . expect ( "JSON config client example is expected to work correctly" ) ;
19
+
20
+ println ! ( "JSON client configuration test passed successfully!" ) ;
21
+ }
22
+
23
+ fn json_config_client_test ( config : & Configuration ) -> Result < ( ) , Error > {
24
+ use iroha_client:: client:: Client ;
25
+
26
+ // Initialise a client with a provided config
27
+ let _current_client: Client = Client :: new ( & config) ?;
28
+
29
+ Ok ( ( ) )
30
+ }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! ( "Hello, world!" ) ;
3
+ }
You can’t perform that action at this time.
0 commit comments