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
6 changes: 3 additions & 3 deletions framework/src/main/java/org/tron/core/capsule/utils/RLP.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static long decodeLong(byte[] data, int index) {
return value;
}

private static String decodeStringItem(byte[] data, int index) {
public static String decodeStringItem(byte[] data, int index) {

final byte[] valueBytes = decodeItemBytes(data, index);

Expand All @@ -229,12 +229,12 @@ public static BigInteger decodeBigInteger(byte[] data, int index) {
}
}

private static byte[] decodeByteArray(byte[] data, int index) {
public static byte[] decodeByteArray(byte[] data, int index) {

return decodeItemBytes(data, index);
}

private static int nextItemLength(byte[] data, int index) {
public static int nextItemLength(byte[] data, int index) {

if (index >= data.length) {
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class BandWidthRuntimeOutOfTimeTest extends BaseTest {
private static final String TriggerOwnerAddress = "TCSgeWapPJhCqgWRxXCKb6jJ5AgNWSGjPA";

static {
dbPath = "output_BandWidthRuntimeOutOfTimeTest_test";
dbPath = "output_bandwidth_runtime_out_of_time_test";
Args.setParam(
new String[]{
"--output-directory", dbPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class BandWidthRuntimeOutOfTimeWithCheckTest extends BaseTest {
private static final String TriggerOwnerAddress = "TCSgeWapPJhCqgWRxXCKb6jJ5AgNWSGjPA";

static {
dbPath = "output_BandWidthRuntimeOutOfTimeTest_test";
dbPath = "output_bandwidth_runtime_out_of_time_with_check_test";
Args.setParam(
new String[]{
"--output-directory", dbPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.protobuf.ByteString;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.runtime.RuntimeImpl;
Expand Down Expand Up @@ -56,8 +57,9 @@ public class BandWidthRuntimeTest extends BaseTest {
private static final String TriggerOwnerTwoAddress = "TPMBUANrTwwQAPwShn7ZZjTJz1f3F8jknj";
private static boolean init;

static {
dbPath = "output_BandWidthRuntimeTest_test";
@BeforeClass
public static void init() {
dbPath = "output_bandwidth_runtime_test";
Args.setParam(
new String[]{
"--output-directory", dbPath,
Expand All @@ -73,7 +75,7 @@ public class BandWidthRuntimeTest extends BaseTest {
* Init data.
*/
@Before
public void init() {
public void before() {
if (init) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class BandWidthRuntimeWithCheckTest extends BaseTest {
private static boolean init;

static {
dbPath = "output_BandWidthRuntimeTest_test";
dbPath = "output_bandwidth_runtime_with_check_test";
Args.setParam(
new String[]{
"--output-directory", dbPath,
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion framework/src/test/java/org/tron/core/tire/TrieTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void testOrder() {
trie2.put(RLP.encodeInt(i), String.valueOf(i).getBytes());
}
byte[] rootHash2 = trie2.getRootHash();
Assert.assertTrue(java.util.Arrays.equals(rootHash1, rootHash2));
Assert.assertArrayEquals(rootHash1, rootHash2);
}

private void assertTrue(byte[] key, TrieImpl trieCopy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.tron.api.WalletGrpc;
import org.tron.common.application.Application;
import org.tron.common.application.ApplicationFactory;
Expand All @@ -35,9 +33,6 @@ public class LiteFullNodeToolTest {
private Application appTest;
private String databaseDir;

@Rule
public ExpectedException thrown = ExpectedException.none();

private static final String DB_PATH = "output_lite_fn";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SolidityNodeTest {
private static TronApplicationContext context;

private static RpcApiService rpcApiService;
private static String dbPath = "output_witness_test";
private static String dbPath = "output_sn_test";

static {
Args.setParam(new String[]{"-d", dbPath}, Constant.TEST_CONF);
Expand Down
137 changes: 137 additions & 0 deletions framework/src/test/java/org/tron/program/SupplementTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package org.tron.program;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.math.BigInteger;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.tron.common.config.DbBackupConfig;
import org.tron.common.entity.PeerInfo;
import org.tron.common.utils.CompactEncoder;
import org.tron.common.utils.JsonUtil;
import org.tron.common.utils.Value;
import org.tron.core.Constant;
import org.tron.core.capsule.StorageRowCapsule;
import org.tron.core.capsule.utils.RLP;
import org.tron.core.config.DefaultConfig;
import org.tron.core.config.args.Args;
import org.tron.core.services.http.HttpSelfFormatFieldName;
import org.tron.core.store.StorageRowStore;
import org.tron.keystore.WalletUtils;

@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
@ContextConfiguration(classes = {DefaultConfig.class})
public class SupplementTest {

private static final String dbPath = "output_coverage_test";

@Resource
private StorageRowStore storageRowStore;

@Rule
public ExpectedException thrown = ExpectedException.none();

@BeforeClass
public static void init() {
Args.setParam(new String[]{"--output-directory", dbPath, "--debug"}, Constant.TEST_CONF);
}

@Test
public void testGet() throws Exception {
StorageRowCapsule storageRowCapsule = storageRowStore.get(new byte[]{});
assertNotNull(storageRowCapsule);

DbBackupConfig dbBackupConfig = new DbBackupConfig();
dbBackupConfig.initArgs(true, "propPath", "bak1path/", "bak2path/", 1);

WalletUtils.generateFullNewWalletFile("123456", new File(dbPath));
WalletUtils.generateLightNewWalletFile("123456", new File(dbPath));
WalletUtils.getDefaultKeyDirectory();
WalletUtils.getTestnetKeyDirectory();
WalletUtils.getMainnetKeyDirectory();

Value value = new Value(new byte[]{1});
value.asBytes();
value = new Value(1);
value.asInt();
value = new Value(100L);
value.asLong();
value = new Value(new BigInteger("1000"));
value.asBigInt();
value = new Value("1000");
value.asString();
value.isEmpty();
value = new Value(new byte[]{1, 2, 3});
value.isList();
value.isReadableString();
value.isHexString();
value.isHashCode();
value.isNull();
value.length();
assertNotNull(value.toString());
value.countBranchNodes();

PeerInfo peerInfo = new PeerInfo();
peerInfo.setAvgLatency(peerInfo.getAvgLatency());
peerInfo.setBlockInPorcSize(peerInfo.getBlockInPorcSize());
peerInfo.setConnectTime(peerInfo.getConnectTime());
peerInfo.setDisconnectTimes(peerInfo.getDisconnectTimes());
peerInfo.setHeadBlockTimeWeBothHave(peerInfo.getHeadBlockTimeWeBothHave());
peerInfo.setHeadBlockWeBothHave(peerInfo.getHeadBlockWeBothHave());
peerInfo.setHost(peerInfo.getHost());
peerInfo.setInFlow(peerInfo.getInFlow());
peerInfo.setLastBlockUpdateTime(peerInfo.getLastBlockUpdateTime());
peerInfo.setLastSyncBlock(peerInfo.getLastSyncBlock());
peerInfo.setLocalDisconnectReason(peerInfo.getLocalDisconnectReason());
peerInfo.setNodeCount(peerInfo.getNodeCount());
peerInfo.setNodeId(peerInfo.getNodeId());
peerInfo.setRemainNum(peerInfo.getRemainNum());
peerInfo.setRemoteDisconnectReason(peerInfo.getRemoteDisconnectReason());
peerInfo.setScore(peerInfo.getScore());
peerInfo.setPort(peerInfo.getPort());
peerInfo.setSyncFlag(peerInfo.isSyncFlag());
peerInfo.setNeedSyncFromPeer(peerInfo.isNeedSyncFromPeer());
peerInfo.setNeedSyncFromUs(peerInfo.isNeedSyncFromUs());
peerInfo.setSyncToFetchSize(peerInfo.getSyncToFetchSize());
peerInfo.setSyncToFetchSizePeekNum(peerInfo.getSyncToFetchSizePeekNum());
peerInfo.setSyncBlockRequestedSize(peerInfo.getSyncBlockRequestedSize());
peerInfo.setUnFetchSynNum(peerInfo.getUnFetchSynNum());
peerInfo.setActive(peerInfo.isActive());

assertNotNull(JsonUtil.json2Obj("{}", PeerInfo.class));
assertNotNull(JsonUtil.obj2Json(peerInfo));

assertTrue(HttpSelfFormatFieldName.isAddressFormat(
"protocol.DelegatedResourceMessage.fromAddress"));
assertTrue(HttpSelfFormatFieldName.isNameStringFormat(
"protocol.MarketPriceList.buy_token_id"));

CompactEncoder.packNibbles(new byte[] {1,2,3,4,5,6,7});
assertFalse(CompactEncoder.hasTerminator(new byte[] {1,2,3,4,5,6,7}));
CompactEncoder.unpackToNibbles(new byte[] {1,2,3,4,5,6,7});
CompactEncoder.binToNibblesNoTerminator(new byte[] {1,2,3,4,5,6,7});

assertNotNull(RLP.decodeIP4Bytes(new byte[] {1,2,3,4,5,6,7}, 0));
RLP.decodeByteArray(new byte[] {1,2,3,4,5,6,7}, 0);
RLP.nextItemLength(new byte[] {1,2,3,4,5,6,7}, 0);
RLP.decodeStringItem(new byte[] {1,2,3,4,5,6,7}, 0);
RLP.decodeInt(new byte[] {1,2,3,4,5,6,7}, 0);
RLP.decode2OneItem(new byte[] {1,2,3,4,5,6,7}, 0);
RLP.decode2(new byte[] {1,2,3,4,5,6,7}, 1);
RLP.decode2(new byte[] {1,2,3,4,5,6,7});
thrown.expect(ClassCastException.class);
RLP.unwrapList(new byte[] {1,2,3,4,5,6,7});
}

}