Skip to content

Commit

Permalink
lite-client wrapper adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Oct 26, 2024
1 parent c6ae3d8 commit b0ab601
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public LiteClient build() {
if (StringUtils.isEmpty(super.pathToLiteClientBinary)) {
log.info("checking if lite-client is installed...");
String errorMsg =
"Make sure you have fift installed. See https://github.com/ton-blockchain/packages for instructions.\nYou can also specify full path via SmartContractCompiler.fiftExecutablePath().";
"Make sure you have lite-client installed. See https://github.com/ton-blockchain/packages for instructions.\nYou can also specify full path via LiteClientBuilder.pathToLiteClientBinary().";
try {
ProcessBuilder pb = new ProcessBuilder("lite-client", "-h").redirectErrorStream(true);
Process p = pb.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
package org.ton.java.liteclient;

import static org.assertj.core.api.Assertions.assertThat;

import com.anarsoft.vmlens.concurrent.junit.ConcurrentTestRunner;
import com.anarsoft.vmlens.concurrent.junit.ThreadCount;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ton.java.liteclient.api.ResultLastBlock;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import static org.assertj.core.api.Assertions.assertThat;

@Slf4j
@RunWith(ConcurrentTestRunner.class)
public class LiteClientThreadsTest {

private LiteClient liteClient;

@Before
public void executedBeforeEach() throws IOException {
InputStream liteClientStream = LiteClient.class.getClassLoader().getResourceAsStream("lite-client.exe");
File f = new File("lite-client.exe");
FileUtils.copyInputStreamToFile(liteClientStream, f);
String pathToLiteClient = f.getAbsolutePath();
liteClientStream.close();

liteClient = LiteClient.builder()
.pathToLiteClientBinary(pathToLiteClient)
.testnet(true)
.build();
}

@Test
@ThreadCount(6)
public void testLiteClientLastThreads() throws Exception {
String resultLast = liteClient.executeLast();
assertThat(resultLast).isNotEmpty();
ResultLastBlock resultLastBlock = LiteClientParser.parseLast(resultLast);
log.info("testLiteClientLastThreads tonBlockId {}", resultLastBlock);
assertThat(resultLastBlock).isNotNull();
String resultShards = liteClient.executeAllshards(resultLastBlock);
log.info("testLiteClientLastThreads resultShards {}", resultShards);
assertThat(resultShards).isNotEmpty();
String resultBlock = liteClient.executeDumpblock(resultLastBlock);
assertThat(resultBlock).isNotEmpty();
}
}
private LiteClient liteClient;

@Before
public void executedBeforeEach() {
liteClient = LiteClient.builder().testnet(true).build();
}

@Test
@ThreadCount(6)
public void testLiteClientLastThreads() throws Exception {
String resultLast = liteClient.executeLast();
assertThat(resultLast).isNotEmpty();
ResultLastBlock resultLastBlock = LiteClientParser.parseLast(resultLast);
log.info("testLiteClientLastThreads tonBlockId {}", resultLastBlock);
assertThat(resultLastBlock).isNotNull();
String resultShards = liteClient.executeAllshards(resultLastBlock);
log.info("testLiteClientLastThreads resultShards {}", resultShards);
assertThat(resultShards).isNotEmpty();
String resultBlock = liteClient.executeDumpblock(resultLastBlock);
assertThat(resultBlock).isNotEmpty();
}
}

0 comments on commit b0ab601

Please sign in to comment.