Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,65 +96,6 @@ public WalletClient(final ECKey ecKey) {
this.ecKey = ecKey;
}

/**
* constructor.
*/

public static boolean init(int itype) {
Config config = Configuration.getByPath("testng.conf");
dbPath = config.getString("CityDb.DbPath");
txtPath = System.getProperty("user.dir") + '/' + config.getString("CityDb.TxtPath");

String fullNodepathname = "";

if (1000 == itype) {
fullNodepathname = "checkfullnode.ip.list";
} else {
fullNodepathname = "fullnode.ip.list";
}
String fullNode = "";
String solidityNode = "";
if (config.hasPath("soliditynode.ip.list")) {
solidityNode = config.getStringList("soliditynode.ip.list").get(0);
}
if (config.hasPath(fullNodepathname)) {
fullNode = config.getStringList(fullNodepathname).get(itype);
}
if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) {
WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
} else {
WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET);
}
rpcCli = new GrpcClient(fullNode, solidityNode);
return true;
}

/**
* constructor.
*/

public static GrpcClient init() {
//Config config = org.tron.core.config.Configuration.getByPath("config.conf");
Config config = Configuration.getByPath("testng.conf");
dbPath = config.getString("CityDb.DbPath");
txtPath = System.getProperty("user.dir") + "/" + config.getString("CityDb.TxtPath");

String fullNode = "";
String solidityNode = "";
if (config.hasPath("soliditynode.ip.list")) {
solidityNode = config.getStringList("soliditynode.ip.list").get(0);
}
if (config.hasPath("fullnode.ip.list")) {
fullNode = config.getStringList("fullnode.ip.list").get(0);
}
if (config.hasPath("net.type") && "mainnet".equalsIgnoreCase(config.getString("net.type"))) {
WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_MAINNET);
} else {
WalletClient.setAddressPreFixByte(CommonConstant.ADD_PRE_FIX_BYTE_TESTNET);
}
return new GrpcClient(fullNode, solidityNode);
}

public static byte getAddressPreFixByte() {
return addressPreFixByte;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public class HttpMethed {
static HttpClient httpClient;
static HttpPost httppost;
static HttpResponse response;
static Integer connectionTimeout =
Configuration.getByPath("testng.conf").getInt("defaultParameter.httpConnectionTimeout");
static Integer soTimeout =
Configuration.getByPath("testng.conf").getInt("defaultParameter.httpSoTimeout");
static Integer connectionTimeout = 19000;
static Integer soTimeout = 18000;
static String transactionString;
static String transactionSignString;
static JSONObject responseContent;
Expand All @@ -48,8 +46,7 @@ public class HttpMethed {
public static volatile Integer witnessNum;

/** constructor. */
private static volatile String httpnode =
Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(1);
private static volatile String httpnode = "127.0.0.1:50052";

/** constructor. */
public static Integer getWitnessNum() {
Expand Down Expand Up @@ -1171,7 +1168,7 @@ public static String gettransactionsign(
String httpNode, String transactionString, String privateKey) {
try {
transactionSignString = TransactionUtils.getTransactionSign(transactionString, privateKey,
false);
false);
} catch (Exception e) {
e.printStackTrace();
httppost.releaseConnection();
Expand Down Expand Up @@ -3446,7 +3443,7 @@ public static Boolean getSpendResult(
String jsonString = responseContent.toJSONString();
if (jsonString.contains("result")
&& (responseContent.getString("result").equals("true")
&& responseContent.getString("message").equals("Input note has been spent"))) {
&& responseContent.getString("message").equals("Input note has been spent"))) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
Expand Down Expand Up @@ -3501,7 +3498,7 @@ public static Boolean getSpendResultFromSolidity(
String jsonString = responseContent.toJSONString();
if (jsonString.contains("result")
&& (responseContent.getString("result").equals("true")
&& responseContent.getString("message").equals("Input note has been spent"))) {
&& responseContent.getString("message").equals("Input note has been spent"))) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
Expand Down Expand Up @@ -3552,7 +3549,7 @@ public static Boolean getSpendResultFromPbft(
String jsonString = responseContent.toJSONString();
if (jsonString.contains("result")
&& (responseContent.getString("result").equals("true")
&& responseContent.getString("message").equals("Input note has been spent"))) {
&& responseContent.getString("message").equals("Input note has been spent"))) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@

import com.alibaba.fastjson.JSON;
import com.google.protobuf.ByteString;
import io.grpc.ManagedChannelBuilder;
import java.net.InetSocketAddress;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.mockito.Mockito;
import org.tron.api.GrpcAPI.EmptyMessage;
import org.tron.api.WalletGrpc;
import org.tron.api.WalletGrpc.WalletBlockingStub;
import org.tron.common.application.TronApplicationContext;
import org.tron.common.entity.NodeInfo;
import org.tron.common.utils.Sha256Hash;
import org.tron.common.utils.client.Configuration;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.net.P2pEventHandlerImpl;
import org.tron.core.net.peer.PeerManager;
import org.tron.p2p.connection.Channel;
import org.tron.program.Version;

Expand All @@ -29,8 +23,6 @@ public class NodeInfoServiceTest {
private NodeInfoService nodeInfoService;
private WitnessProductBlockService witnessProductBlockService;
private P2pEventHandlerImpl p2pEventHandler;
private String fullnode = Configuration.getByPath("testng.conf").getStringList("fullnode.ip.list")
.get(0);

public NodeInfoServiceTest(TronApplicationContext context) {
nodeInfoService = context.getBean("nodeInfoService", NodeInfoService.class);
Expand Down Expand Up @@ -60,12 +52,4 @@ public void test() {
logger.info("{}", JSON.toJSONString(nodeInfo));
}

public void testGrpc() {
WalletBlockingStub walletStub = WalletGrpc
.newBlockingStub(ManagedChannelBuilder.forTarget(fullnode)
.usePlaintext()
.build());
logger.info("getNodeInfo: {}", walletStub.getNodeInfo(EmptyMessage.getDefaultInstance()));
}

}
4 changes: 2 additions & 2 deletions framework/src/test/resources/config-localtest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ genesis.block = {

witnesses = [
{
address: TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz
address: TEDapYSVvAZ3aYH7w8N9tMEEFKaNKUD5Bp
url = "http://Test.org",
voteCount = 106
},
Expand Down Expand Up @@ -262,7 +262,7 @@ genesis.block = {
//localWitnessAccountAddress = TN3zfjYUmMFK3ZsHSsrdJoNRtGkQmZLBLz

localwitness = [
f4df789d3210ac881cb900464dd30409453044d2777060a0c391cbdf4c6a4f57
1234567890123456789012345678901234567890123456789012345678901234
]


Expand Down
Loading