Skip to content

Commit

Permalink
test(api): close api service for most test
Browse files Browse the repository at this point in the history
  • Loading branch information
halibobo1205 committed Jun 14, 2024
1 parent 0e654f4 commit b2898ae
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.tron.common.application.ApplicationFactory;
import org.tron.common.application.TronApplicationContext;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.PublicMethod;
import org.tron.core.Constant;
import org.tron.core.config.DefaultConfig;
import org.tron.core.config.args.Args;
Expand Down Expand Up @@ -47,18 +46,6 @@ public void init() throws IOException {
},
"config.conf"
);
Args.getInstance().setRpcEnable(false);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(false);
Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setPBFTHttpEnable(false);
Args.getInstance().setPBFTHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setSolidityNodeHttpEnable(false);
Args.getInstance().setSolidityHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);
CommonParameter parameter = Args.getInstance();
parameter.setNodeListenPort(port);
parameter.getSeedNode().getAddressList().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ public static void init() throws IOException {
Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF);
String OWNER_ADDRESS = Wallet.getAddressPreFixString()
+ "548794500882809695a8a687866e76d4271a1abc";
getInstance().setRpcEnable(true);
getInstance().setRpcPort(PublicMethod.chooseRandomPort());
getInstance().setRpcSolidityEnable(true);
getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort());
getInstance().setRpcPBFTEnable(true);
getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort());
String fullNode = String.format("%s:%d", getInstance().getNodeLanIp(),
getInstance().getRpcPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import io.grpc.ManagedChannelBuilder;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.junit.*;
import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.tron.api.GrpcAPI.EmptyMessage;
import org.tron.api.WalletGrpc;
Expand Down Expand Up @@ -32,14 +36,6 @@ public static void init() throws IOException {
"--p2p-disable", "true"}, Constant.TEST_CONF);
Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcEnable(true);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(false);
Args.getInstance().setPBFTHttpEnable(false);
Args.getInstance().setSolidityNodeHttpEnable(false);
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);
context = new TronApplicationContext(DefaultConfig.class);
appT = ApplicationFactory.create(context);
appT.startup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ public class HttpApiAccessFilterTest extends BaseTest {
static {
Args.setParam(new String[]{"-d", dbPath()}, Constant.TEST_CONF);
Args.getInstance().setFullNodeAllowShieldedTransactionArgs(false);
Args.getInstance().setRpcEnable(false);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(true);
Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setPBFTHttpEnable(true);
Args.getInstance().setPBFTHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setSolidityNodeHttpEnable(true);
Args.getInstance().setSolidityHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ public class LiteFnQueryGrpcInterceptorTest {
@BeforeClass
public static void init() throws IOException {
Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF);
Args.getInstance().setRpcEnable(true);
Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcSolidityEnable(true);
Args.getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcPBFTEnable(true);
Args.getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort());
String fullnode = String.format("%s:%d", Args.getInstance().getNodeLanIp(),
Args.getInstance().getRpcPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ public class RpcApiAccessInterceptorTest {
@BeforeClass
public static void init() throws IOException {
Args.setParam(new String[] {"-d", temporaryFolder.newFolder().toString()}, Constant.TEST_CONF);
Args.getInstance().setRpcEnable(true);
Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcSolidityEnable(true);
Args.getInstance().setRpcOnSolidityPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcPBFTEnable(true);
Args.getInstance().setRpcOnPBFTPort(PublicMethod.chooseRandomPort());
String fullNode = String.format("%s:%d", Args.getInstance().getNodeLanIp(),
Args.getInstance().getRpcPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,8 @@ public static void init() throws Exception {
Args.setParam(
new String[]{"--output-directory", dbPath(), "--debug", "--witness"}, Constant.TEST_CONF);
Args.getInstance().needSyncCheck = false;
Args.getInstance().setRpcEnable(false);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(true);
Args.getInstance().setFullNodeHttpPort(PublicMethod.chooseRandomPort());
Args.getInstance().setPBFTHttpEnable(false);
Args.getInstance().setSolidityNodeHttpEnable(false);
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);
httpNode = String.format("%s:%d", "127.0.0.1",
Args.getInstance().getFullNodeHttpPort());
}
Expand Down
14 changes: 12 additions & 2 deletions framework/src/test/resources/config-localtest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,21 @@ node {
]

http {
fullNodePort = 8090
solidityPort = 8091
fullNodeEnable = false
solidityEnable = false
PBFTEnable = false
}

jsonrpc {
httpFullNodeEnable = false
httpSolidityEnable = false
httpPBFTEnable = false
}

rpc {
enable = false
solidityEnable = false
PBFTEnable = false
port = 50051
# default value is 50061
# solidityPort = 50061
Expand Down
16 changes: 15 additions & 1 deletion framework/src/test/resources/config-test-index.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,23 @@ node {
version = 43 # 43: testnet; 101: debug
}

http {
fullNodeEnable = false
solidityEnable = false
PBFTEnable = false
}

jsonrpc {
httpFullNodeEnable = false
httpSolidityEnable = false
httpPBFTEnable = false
}

rpc {
port = 50051

enable = false
solidityEnable = false
PBFTEnable = false
# Number of gRPC thread, default availableProcessors / 2
# thread = 16

Expand Down
18 changes: 18 additions & 0 deletions framework/src/test/resources/config-test-mainnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ node {
version = 43 # 43: testnet; 101: debug
}

http {
fullNodeEnable = false
solidityEnable = false
PBFTEnable = false
}

jsonrpc {
httpFullNodeEnable = false
httpSolidityEnable = false
httpPBFTEnable = false
}

rpc {
enable = false
solidityEnable = false
PBFTEnable = false
}

}

sync {
Expand Down
16 changes: 12 additions & 4 deletions framework/src/test/resources/config-test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ node {
}

http {
fullNodeEnable = true
fullNodePort = 8090
solidityEnable = true
solidityPort = 8091
fullNodeEnable = false
solidityEnable = false
PBFTEnable = false
}

jsonrpc {
httpFullNodeEnable = false
httpSolidityEnable = false
httpPBFTEnable = false
}

# use your ipv6 address for node discovery and tcp connection, default false
Expand Down Expand Up @@ -171,6 +176,9 @@ node {
}

rpc {
enable = false
solidityEnable = false
PBFTEnable = false
port = 50051

PBFTPort = 50072
Expand Down
8 changes: 0 additions & 8 deletions plugins/src/test/java/org/tron/plugins/DbLiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ public void init() throws IOException {
Args.getInstance().setAllowAccountStateRoot(1);
Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort());
Args.getInstance().setRpcEnable(true);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(false);
Args.getInstance().setPBFTHttpEnable(false);
Args.getInstance().setSolidityNodeHttpEnable(false);
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);
databaseDir = Args.getInstance().getStorage().getDbDirectory();
// init dbBackupConfig to avoid NPE
Args.getInstance().dbBackupConfig = DbBackupConfig.getInstance();
Expand Down

0 comments on commit b2898ae

Please sign in to comment.