Skip to content
Open
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
4 changes: 2 additions & 2 deletions docs/implement-a-customized-actuator-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public class SumActuatorTest {
@BeforeClass
public static void init() throws IOException {
Args.setParam(new String[]{"--output-directory",
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
temporaryFolder.newFolder().toString()}, "config-test.conf");
context = new TronApplicationContext(DefaultConfig.class);
appTest = ApplicationFactory.create(context);
appTest.startup();
Expand All @@ -255,7 +255,7 @@ public class SumActuatorTest {

@Test
public void sumActuatorTest() {
// this key is defined in config-localtest.conf as accountName=Sun
// this key is defined in config-test.conf as accountName=Sun
String key = "<your_private_key>";
byte[] address = PublicMethed.getFinalAddress(key);
ECKey ecKey = null;
Expand Down
4 changes: 2 additions & 2 deletions docs/implement-a-customized-actuator-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class SumActuatorTest {
@BeforeClass
public static void init() throws IOException {
Args.setParam(new String[]{"--output-directory",
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
temporaryFolder.newFolder().toString()}, "config-test.conf");
context = new TronApplicationContext(DefaultConfig.class);
appTest = ApplicationFactory.create(context);
appTest.startup();
Expand All @@ -257,7 +257,7 @@ public class SumActuatorTest {

@Test
public void sumActuatorTest() {
// this key is defined in config-localtest.conf as accountName=Sun
// this key is defined in config-test.conf as accountName=Sun
String key = "<your_private_key>";
byte[] address = PublicMethed.getFinalAddress(key);
ECKey ecKey = null;
Expand Down
6 changes: 1 addition & 5 deletions framework/src/test/java/org/tron/common/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
public class TestConstants {

public static final String TEST_CONF = "config-test.conf";
public static final String NET_CONF = "config.conf";
public static final String MAINNET_CONF = "config-test-mainnet.conf";
public static final String LOCAL_CONF = "config-localtest.conf";
public static final String STORAGE_CONF = "config-test-storagetest.conf";
public static final String INDEX_CONF = "config-test-index.conf";
public static final String SHIELD_CONF = "config-shield.conf";

/**
* Skips the current test on ARM64 where LevelDB JNI is unavailable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.runtime.RuntimeImpl;
import org.tron.common.runtime.TvmTestUtils;
import org.tron.common.utils.Commons;
Expand Down Expand Up @@ -75,7 +76,7 @@ public class BandWidthRuntimeOutOfTimeTest extends BaseTest {
"--storage-index-directory", indexDirectory,
"--debug"
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.runtime.RuntimeImpl;
import org.tron.common.runtime.TvmTestUtils;
import org.tron.common.utils.Commons;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class BandWidthRuntimeOutOfTimeWithCheckTest extends BaseTest {
"--storage-index-directory", indexDirectory,
"--debug"
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.runtime.RuntimeImpl;
import org.tron.common.runtime.TvmTestUtils;
Expand Down Expand Up @@ -70,8 +71,9 @@ public static void init() {
"--output-directory", dbPath(),
"--storage-db-directory", dbDirectory,
"--storage-index-directory", indexDirectory,
"--debug",
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.runtime.RuntimeImpl;
import org.tron.common.runtime.TvmTestUtils;
import org.tron.common.utils.Commons;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class BandWidthRuntimeWithCheckTest extends BaseTest {
"--storage-db-directory", dbDirectory,
"--storage-index-directory", indexDirectory,
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.junit.Test;
import org.tron.api.GrpcAPI.ShieldedTRC20Parameters;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
import org.tron.common.utils.FileUtil;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class PrecompiledContractsVerifyProofTest extends BaseTest {

@BeforeClass
public static void init() {
Args.setParam(new String[]{"--output-directory", dbPath()}, "config-test.conf");
Args.setParam(new String[]{"--output-directory", dbPath()}, TestConstants.TEST_CONF);
DEFAULT_OVK = ByteArray
.fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d");
SHIELDED_CONTRACT_ADDRESS = WalletClient.decodeFromBase58Check(SHIELDED_CONTRACT_ADDRESS_STR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ public class Sha256Sm3Hash implements Serializable, Comparable<Sha256Sm3Hash> {
private final byte[] bytes;
private static boolean isEckey = true;

/* static {
Config config = Configuration.getByPath("config.conf"); // it is needs set to be a constant
Config config = "crypto.engine";
if (config.hasPath("crypto.engine")) {
isEckey = config.getString("crypto.engine").equalsIgnoreCase("eckey");
System.out.println("Sha256Sm3Hash getConfig isEckey: " + isEckey);
}
}*/

public Sha256Sm3Hash(long num, byte[] hash) {
byte[] rawHashBytes = this.generateBlockId(num, hash);
Preconditions.checkArgument(rawHashBytes.length == LENGTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.tron.api.GrpcAPI.ShieldedTRC20TriggerContractParameters;
import org.tron.api.GrpcAPI.SpendAuthSigParameters;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
import org.tron.common.utils.PublicMethod;
Expand Down Expand Up @@ -63,7 +64,7 @@ public class ShieldedTRC20BuilderTest extends BaseTest {
private static final byte[] PUBLIC_TO_ADDRESS;

static {
Args.setParam(new String[]{"--output-directory", dbPath()}, "config-test-mainnet.conf");
Args.setParam(new String[]{"--output-directory", dbPath()}, TestConstants.TEST_CONF);
SHIELDED_CONTRACT_ADDRESS = WalletClient.decodeFromBase58Check(SHIELDED_CONTRACT_ADDRESS_STR);
DEFAULT_OVK = ByteArray
.fromHexString("030c8c2bc59fb3eb8afb047a8ea4b028743d23e7d38c6fa30908358431e2314d");
Expand Down
11 changes: 2 additions & 9 deletions framework/src/test/java/org/tron/core/config/args/ArgsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public class ArgsTest {

@Test
public void get() {
Args.setParam(new String[] {"-c", TestConstants.TEST_CONF, "--keystore-factory"},
TestConstants.NET_CONF);
Args.setParam(new String[] {"--keystore-factory"}, TestConstants.TEST_CONF);

CommonParameter parameter = Args.getInstance();

Expand All @@ -73,7 +72,7 @@ public void get() {

Assert.assertEquals("database", parameter.getStorage().getDbDirectory());

Assert.assertEquals(11, parameter.getSeedNode().getAddressList().size());
Assert.assertEquals(0, parameter.getSeedNode().getAddressList().size());

GenesisBlock genesisBlock = parameter.getGenesisBlock();

Expand Down Expand Up @@ -147,12 +146,6 @@ public void testIpFromLibP2p()
Assert.assertNotEquals(configuredExternalIp, parameter.getNodeExternalIp());
}

@Test
public void testOldRewardOpt() {
thrown.expect(IllegalArgumentException.class);
Args.setParam(new String[] {"-c", "args-test.conf"}, TestConstants.NET_CONF);
}

@Test
public void testInitService() {
Map<String,String> storage = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ public void testConstructor() {
public void testLocalWitnessConfig() throws IOException {
Args.setParam(
new String[]{"--output-directory", temporaryFolder.newFolder().toString(), "-w", "--debug"},
"config-localtest.conf");
TestConstants.SHIELD_CONF);
LocalWitnesses witness = Args.getLocalWitnesses();
Assert.assertNotNull(witness.getPrivateKey());
Assert.assertNotNull(witness.getWitnessAccountAddress());
Args.clearParam();
}

@Test
Expand All @@ -191,5 +192,6 @@ public void testNullLocalWitnessConfig() throws IOException {
LocalWitnesses witness = Args.getLocalWitnesses();
Assert.assertNull(witness.getPrivateKey());
Assert.assertNull(witness.getWitnessAccountAddress());
Args.clearParam();
}
}
33 changes: 31 additions & 2 deletions framework/src/test/java/org/tron/core/config/args/StorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,51 @@

package org.tron.core.config.args;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import java.io.File;
import org.iq80.leveldb.CompressionType;
import org.iq80.leveldb.Options;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.tron.common.TestConstants;
import org.tron.common.utils.FileUtil;
import org.tron.common.utils.StorageUtils;

public class StorageTest {

private static Storage storage;
private static final Storage storage;

static {
Args.setParam(new String[]{}, "config-test-storagetest.conf");
Args.setParam(new String[]{}, TestConstants.TEST_CONF);
storage = Args.getInstance().getStorage();
setupStorage();
}

private static void setupStorage() {
Config cfg = ConfigFactory.parseString(
"storage.default.maxOpenFiles = 50\n"
+ "storage.defaultM.maxOpenFiles = 500\n"
+ "storage.defaultL.maxOpenFiles = 1000\n"
+ "storage.properties = [\n"
+ " { name = account, path = storage_directory_test,\n"
+ " createIfMissing = true, paranoidChecks = true, verifyChecksums = true,\n"
+ " compressionType = 1, blockSize = 4096,\n"
+ " writeBufferSize = 10485760, cacheSize = 10485760, maxOpenFiles = 100 },\n"
+ " { name = \"account-index\", path = storage_directory_test,\n"
+ " createIfMissing = true, paranoidChecks = true, verifyChecksums = true,\n"
+ " compressionType = 1, blockSize = 4096,\n"
+ " writeBufferSize = 10485760, cacheSize = 10485760, maxOpenFiles = 100 },\n"
+ " { name = test_name, path = test_path,\n"
+ " createIfMissing = false, paranoidChecks = false, verifyChecksums = false,\n"
+ " compressionType = 1, blockSize = 2,\n"
+ " writeBufferSize = 3, cacheSize = 4, maxOpenFiles = 5 }\n"
+ "]"
).withFallback(ConfigFactory.load(TestConstants.TEST_CONF));
StorageConfig sc = StorageConfig.fromConfig(cfg);
storage.setDefaultDbOptions(sc);
storage.setPropertyMapFromBean(sc.getProperties());
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.runtime.RuntimeImpl;
import org.tron.common.runtime.TvmTestUtils;
import org.tron.common.utils.ByteArray;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class TransactionTraceTest extends BaseTest {
"--storage-index-directory", indexDirectory,
"--debug"
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.capsule.AccountCapsule;
Expand All @@ -27,7 +28,7 @@ public class AssetUpdateHelperTest extends BaseTest {
private static boolean init;

static {
Args.setParam(new String[]{"-d", dbPath()}, "config-test-index.conf");
Args.setParam(new String[]{"-d", dbPath()}, TestConstants.TEST_CONF);
Args.getInstance().setSolidityNode(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.config.args.Args;
Expand All @@ -21,7 +22,7 @@ public class ApiUtilTest {

@BeforeClass
public static void init() {
Args.setParam(new String[]{}, "config-localtest.conf");
Args.setParam(new String[]{}, TestConstants.TEST_CONF);
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
import org.tron.common.zksnark.IncrementalMerkleTreeContainer;
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void init() {
"--storage-index-directory", indexDirectory,
"--debug"
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
Args.getInstance().setAllowShieldedTransactionApi(true);
ZksnarkInitService.librustzcashInitZksnarkParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
import org.tron.common.zksnark.IncrementalMerkleTreeContainer;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class MerkleTreeTest extends BaseTest {
"--storage-index-directory", indexDirectory,
"--debug"
},
"config-test-mainnet.conf"
TestConstants.TEST_CONF
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.Test;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.utils.ByteArray;
import org.tron.core.Wallet;
import org.tron.core.capsule.AssetIssueCapsule;
Expand Down Expand Up @@ -39,7 +40,7 @@ public class NoteEncDecryTest extends BaseTest {
private Wallet wallet;

static {
Args.setParam(new String[]{"--output-directory", dbPath()}, "config-localtest.conf");
Args.setParam(new String[]{"--output-directory", dbPath()}, TestConstants.SHIELD_CONF);
FROM_ADDRESS = Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.Test;
import org.tron.api.GrpcAPI;
import org.tron.common.BaseTest;
import org.tron.common.TestConstants;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
Expand Down Expand Up @@ -111,7 +112,7 @@ public class SendCoinShieldTest extends BaseTest {
private static boolean init;

static {
Args.setParam(new String[]{"--output-directory", dbPath()}, "config-test-mainnet.conf");
Args.setParam(new String[]{"--output-directory", dbPath()}, TestConstants.TEST_CONF);
Args.getInstance().setZenTokenId(String.valueOf(tokenId));
PUBLIC_ADDRESS_ONE =
Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0";
Expand Down
Loading
Loading