Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrp committed May 5, 2018
1 parent 05119cc commit ba8200f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ src/main/resources/META-INF/

/output_manager/
/output_witness/

output*
nodeId.properties
7 changes: 3 additions & 4 deletions src/test/java/org/tron/core/net/node/BroadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
@Slf4j
public class BroadTest {

private static String dbPath = "output-nodeImplTest/broad";
private static AnnotationConfigApplicationContext context;
private NodeImpl node;
RpcApiService rpcApiService;
Expand Down Expand Up @@ -167,7 +166,7 @@ public void init() {
@Override
public void run() {
logger.info("Full node running.");
Args.setParam(new String[]{"--output-directory", dbPath}, "config.conf");
Args.setParam(new String[]{"-d", "output-BroadTest-test"}, "config.conf");
Args cfgArgs = Args.getInstance();
cfgArgs.setNodeListenPort(17889);
cfgArgs.setNodeDiscoveryEnable(false);
Expand Down Expand Up @@ -220,8 +219,8 @@ public void run() {
@AfterClass
public static void destroy() {
Args.clearParam();
FileUtil.deleteDir(new File(dbPath));
context.destroy();
FileUtil.deleteDir(new File("output-BroadTest-test"));
// context.destroy();
}

private void prepare() {
Expand Down
16 changes: 14 additions & 2 deletions src/test/java/org/tron/core/net/node/HandleSyncBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.netty.util.internal.ConcurrentSet;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -18,6 +19,7 @@
import org.tron.common.overlay.server.ChannelManager;
import org.tron.common.overlay.server.SyncPool;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.FileUtil;
import org.tron.common.utils.ReflectUtils;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.capsule.BlockCapsule;
Expand All @@ -32,6 +34,7 @@
import org.tron.core.services.WitnessService;
import org.tron.protos.Protocol;

import java.io.File;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -40,6 +43,7 @@

@Slf4j
public class HandleSyncBlockTest {
private static AnnotationConfigApplicationContext context;
private NodeImpl node;
RpcApiService rpcApiService;
PeerClient peerClient;
Expand Down Expand Up @@ -147,15 +151,15 @@ public void init() {
@Override
public void run() {
logger.info("Full node running.");
Args.setParam(new String[]{"-d","output-nodeImplTest/handleSyncBlock"}, "config.conf");
Args.setParam(new String[]{"-d","output-handleSyncBlock-test"}, "config.conf");
Args cfgArgs = Args.getInstance();
cfgArgs.setNodeListenPort(17889);
cfgArgs.setNodeDiscoveryEnable(false);
cfgArgs.getSeedNode().getIpList().clear();
cfgArgs.setNeedSyncCheck(false);
cfgArgs.setNodeExternalIp("127.0.0.1");

ApplicationContext context = new AnnotationConfigApplicationContext(DefaultConfig.class);
context = new AnnotationConfigApplicationContext(DefaultConfig.class);

if (cfgArgs.isHelp()) {
logger.info("Here is the help message.");
Expand Down Expand Up @@ -196,6 +200,14 @@ public void run() {
}
}

@AfterClass
public static void destroy() {
Args.clearParam();
FileUtil.deleteDir(new File("output-handleSyncBlock-test"));
// context.destroy();
}


private void prepare() {
try {
ExecutorService advertiseLoopThread = ReflectUtils.getFieldValue(node, "broadPool");
Expand Down
16 changes: 14 additions & 2 deletions src/test/java/org/tron/core/net/node/StartFetchSyncBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -14,6 +15,7 @@
import org.tron.common.overlay.server.Channel;
import org.tron.common.overlay.server.ChannelManager;
import org.tron.common.overlay.server.SyncPool;
import org.tron.common.utils.FileUtil;
import org.tron.common.utils.ReflectUtils;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.capsule.BlockCapsule;
Expand All @@ -27,6 +29,7 @@
import org.tron.core.services.WitnessService;
import org.tron.protos.Protocol;

import java.io.File;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -35,6 +38,7 @@

@Slf4j
public class StartFetchSyncBlockTest {
private static AnnotationConfigApplicationContext context;
private NodeImpl node;
RpcApiService rpcApiService;
PeerClient peerClient;
Expand Down Expand Up @@ -111,15 +115,15 @@ public void init() {
@Override
public void run() {
logger.info("Full node running.");
Args.setParam(new String[]{"-d","output-nodeImplTest/startFetchSyncBlock"}, "config.conf");
Args.setParam(new String[]{"-d","output-startFetchSyncBlock-test"}, "config.conf");
Args cfgArgs = Args.getInstance();
cfgArgs.setNodeListenPort(17889);
cfgArgs.setNodeDiscoveryEnable(false);
cfgArgs.getSeedNode().getIpList().clear();
cfgArgs.setNeedSyncCheck(false);
cfgArgs.setNodeExternalIp("127.0.0.1");

ApplicationContext context = new AnnotationConfigApplicationContext(DefaultConfig.class);
context = new AnnotationConfigApplicationContext(DefaultConfig.class);

if (cfgArgs.isHelp()) {
logger.info("Here is the help message.");
Expand Down Expand Up @@ -166,6 +170,14 @@ public void run() {
}
}

@AfterClass
public static void destroy() {
Args.clearParam();
FileUtil.deleteDir(new File("output-startFetchSyncBlock-test"));
// context.destroy();

}

private void prepare() {
try {
ExecutorService advertiseLoopThread = ReflectUtils.getFieldValue(node, "broadPool");
Expand Down

0 comments on commit ba8200f

Please sign in to comment.