22
33import java .math .BigInteger ;
44import java .util .Collections ;
5+ import java .util .Map ;
6+
57import lombok .extern .slf4j .Slf4j ;
68import org .junit .Test ;
79import org .junit .runner .RunWith ;
1618import org .ton .ton4j .tl .liteserver .responses .LibraryEntry ;
1719import org .ton .ton4j .tl .liteserver .responses .LibraryResult ;
1820import org .ton .ton4j .toncenter .TonCenter ;
21+ import org .ton .ton4j .toncenter .TonResponse ;
22+ import org .ton .ton4j .toncenter .model .GetLibrariesResponse ;
1923import org .ton .ton4j .tonlib .types .SmcLibraryEntry ;
2024import org .ton .ton4j .tonlib .types .SmcLibraryResult ;
2125import org .ton .ton4j .utils .Utils ;
2226
27+ import static org .junit .Assert .assertNotNull ;
28+ import static org .junit .Assert .assertTrue ;
29+
2330@ Slf4j
2431@ RunWith (JUnit4 .class )
2532public class TestLibraryDeployer extends CommonTest {
@@ -52,6 +59,8 @@ public void testDeployLibraryDeployer() throws InterruptedException {
5259 10 ,
5360 "Deployment of LibraryDeployer will never happen. Lite-server will return an error, but the library will be deployed" );
5461
62+ log .info ("walletV5Code library hash(b64) in testnet {}" , Utils .bytesToBase64 (walletV5Code .getHash ()));
63+
5564 SmcLibraryResult smcLibraryResult =
5665 tonlib .getLibraries (
5766 Collections .singletonList (
@@ -70,6 +79,8 @@ public void testDeployLibraryDeployer() throws InterruptedException {
7079 @ Test
7180 public void testIfLibraryHasBeenDeployed () {
7281 Cell walletV5Code = CellBuilder .beginCell ().fromBoc (WalletCodes .V5R1 .getValue ()).endCell ();
82+ log .info ("walletV5Code library hash(hex) in testnet {}" , Utils .bytesToHex (walletV5Code .getHash ()));
83+ log .info ("walletV5Code library hash(b64) in testnet {}" , Utils .bytesToBase64 (walletV5Code .getHash ()));
7384 SmcLibraryResult smcLibraryResult =
7485 tonlib .getLibraries (Collections .singletonList (Utils .bytesToBase64 (walletV5Code .getHash ())));
7586 // "IINLe3KxEhR+Gy+0V7hOdNGjDwT3N9T2KmaOlVLSty8="));
@@ -157,10 +168,22 @@ public void testDeployLibraryDeployerTonCenterClient() throws Exception {
157168 10 ,
158169 "Deployment of LibraryDeployer will never happen. Lite-server will return an error, but the library will be deployed" );
159170
160- // Note: TonCenter API doesn't provide a direct getLibraries method like AdnlLiteClient
161- // To verify library deployment, you would need to use other methods or check through
162- // a block explorer or other means
163- log .info ("Library should be deployed at this point. Verify through other means if needed." );
171+ TonResponse <GetLibrariesResponse > smcLibraryResult =
172+ tonCenter .getLibraries (
173+ Collections .singletonList (
174+ Utils .bytesToHex (walletV5Code .getHash ())
175+ ));
176+ log .info ("response {}" , smcLibraryResult .getResult ());
177+
178+ // The response should be successful even if libraries don't exist
179+ assertTrue ("Get libraries should be successful" , smcLibraryResult .isSuccess ());
180+ assertNotNull ("Libraries response should not be null" , smcLibraryResult .getResult ());
181+
182+ for (Map .Entry <String , String > entry : smcLibraryResult .getResult ().getLibraries ().entrySet ()) {
183+
184+ Cell libCell = Cell .fromBoc (entry .getValue ());
185+ log .info ("cell lib {}" , libCell .toHex ());
186+ }
164187 }
165188
166189 @ Test
@@ -181,19 +204,4 @@ public void testIfLibraryHasBeenDeployedAdnlLiteClient() throws Exception {
181204 log .info ("cell lib {}" , libCell .toHex ());
182205 }
183206 }
184-
185- @ Test
186- public void testIfLibraryHasBeenDeployedTonCenterClient () throws Exception {
187- TonCenter tonCenter =
188- TonCenter .builder ()
189- .apiKey (TESTNET_API_KEY )
190- .testnet ()
191- .build ();
192- Cell walletV5Code = CellBuilder .beginCell ().fromBoc (WalletCodes .V5R1 .getValue ()).endCell ();
193-
194- // Note: TonCenter API doesn't provide a direct getLibraries method like AdnlLiteClient
195- // This test is a placeholder to maintain consistency with the AdnlLiteClient version
196- log .info ("Library hash: {}" , Utils .bytesToBase64 (walletV5Code .getHash ()));
197- log .info ("To check if the library has been deployed, use other methods or external tools" );
198- }
199207}
0 commit comments