File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
main/java/com/openelements/hedera/microprofile
test/java/com/openelements/hedera/microprofile/test Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 1818import jakarta .enterprise .context .ApplicationScoped ;
1919import jakarta .enterprise .inject .Produces ;
2020import jakarta .inject .Inject ;
21- import java .util .HashMap ;
2221import java .util .List ;
2322import java .util .Map ;
2423import java .util .Objects ;
24+ import java .util .stream .Collectors ;
2525import org .eclipse .microprofile .config .inject .ConfigProperties ;
2626import org .jspecify .annotations .NonNull ;
2727
@@ -82,9 +82,8 @@ private Client createClient() {
8282 final PrivateKey privateKey = getPrivateKey ();
8383 final HederaNetwork hederaNetwork = getHederaNetwork ();
8484 if (Objects .equals (HederaNetwork .CUSTOM , hederaNetwork )) {
85- final Map <String , AccountId > nodes = new HashMap <>();
86- networkConfiguration .getNodes ()
87- .forEach (node -> nodes .put (node .ip () + ":" + node .port (), AccountId .fromString (node .account ())));
85+ final Map <String , AccountId > nodes = networkConfiguration .getNodes ()
86+ .stream ().collect (Collectors .toMap (n -> n .getAddress (), n -> n .getAccountId ()));
8887 Client client = Client .forNetwork (nodes );
8988 networkConfiguration .getMirrornode ()
9089 .map (mirrorNode -> List .of (mirrorNode ))
Original file line number Diff line number Diff line change 11package com .openelements .hedera .microprofile ;
22
3+ import com .hedera .hashgraph .sdk .AccountId ;
34import jakarta .enterprise .context .Dependent ;
45import jakarta .inject .Inject ;
56import java .util .Optional ;
1415public class HieroNetworkConfiguration {
1516
1617 public record Node (String ip , String port , String account ) {
18+
19+ String getAddress () {
20+ return ip + ":" + port ;
21+ }
22+
23+ AccountId getAccountId () {
24+ return AccountId .fromString (account );
25+ }
1726 }
1827
1928 private Optional <String > name ;
Original file line number Diff line number Diff line change 33import io .github .cdimascio .dotenv .Dotenv ;
44import java .util .HashMap ;
55import java .util .Map ;
6+ import java .util .Objects ;
67import java .util .Set ;
78import org .eclipse .microprofile .config .spi .ConfigSource ;
89import org .slf4j .Logger ;
@@ -36,14 +37,16 @@ public TestConfigSource() {
3637 final String hederaNetwork = System .getenv ("HEDERA_NETWORK" );
3738 if (hederaNetwork != null ) {
3839 properties .put ("hiero.network.name" , hederaNetwork );
39- //TODO: Hardcoded for Solo tests,should be fixed later
40- if (hederaNetwork == "solo" ) {
41- properties .put ("hiero.network.nodes" , "127.0.0.1:50211:0.0.3" );
42- properties .put ("hiero.network.mirrornode" , "http://localhost:8080" );
43- }
4440 } else {
4541 properties .put ("hiero.network.name" , Dotenv .load ().get ("hedera.network.name" ));
4642 }
43+
44+ //TODO: Hardcoded for Solo tests,should be fixed later
45+ if (Objects .equals (properties .get ("hiero.network.name" ), "solo" )) {
46+ properties .put ("hiero.network.nodes" , "127.0.0.1:50211:0.0.3" );
47+ properties .put ("hiero.network.mirrornode" , "http://localhost:8080" );
48+ }
49+
4750 properties .forEach ((k , v ) -> log .info ("CONFIG: '" + k + "'->'" + v + "'" ));
4851 }
4952
You can’t perform that action at this time.
0 commit comments