From ffb3019739d876e1e2d6d2b48a8d1d8666616781 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Tue, 19 May 2026 16:30:21 +0800 Subject: [PATCH 1/6] delete four config test files --- .../java/org/tron/common/TestConstants.java | 6 +- .../vm/BandWidthRuntimeOutOfTimeTest.java | 3 +- ...andWidthRuntimeOutOfTimeWithCheckTest.java | 3 +- .../runtime/vm/BandWidthRuntimeTest.java | 4 +- .../vm/BandWidthRuntimeWithCheckTest.java | 3 +- .../tron/core/ShieldedTRC20BuilderTest.java | 3 +- .../org/tron/core/config/args/ArgsTest.java | 9 +- .../core/config/args/LocalWitnessTest.java | 2 +- .../tron/core/config/args/StorageTest.java | 107 ++++++- .../tron/core/db/TransactionTraceTest.java | 3 +- .../core/db/api/AssetUpdateHelperTest.java | 2 +- .../org/tron/core/jsonrpc/ApiUtilTest.java | 2 +- .../tron/core/zksnark/LibrustzcashTest.java | 3 +- .../org/tron/core/zksnark/MerkleTreeTest.java | 3 +- .../tron/core/zksnark/NoteEncDecryTest.java | 2 +- .../tron/core/zksnark/SendCoinShieldTest.java | 3 +- .../core/zksnark/ShieldedReceiveTest.java | 6 +- framework/src/test/resources/args-test.conf | 223 -------------- ...nfig-localtest.conf => config-shield.conf} | 11 - .../src/test/resources/config-test-index.conf | 174 ----------- .../test/resources/config-test-mainnet.conf | 242 --------------- .../resources/config-test-storagetest.conf | 287 ------------------ framework/src/test/resources/config-test.conf | 18 -- .../java/org/tron/plugins/DbLiteTest.java | 2 +- 24 files changed, 133 insertions(+), 988 deletions(-) delete mode 100644 framework/src/test/resources/args-test.conf rename framework/src/test/resources/{config-localtest.conf => config-shield.conf} (96%) delete mode 100644 framework/src/test/resources/config-test-index.conf delete mode 100644 framework/src/test/resources/config-test-mainnet.conf delete mode 100644 framework/src/test/resources/config-test-storagetest.conf diff --git a/framework/src/test/java/org/tron/common/TestConstants.java b/framework/src/test/java/org/tron/common/TestConstants.java index 88f28688936..a6bf88434ed 100644 --- a/framework/src/test/java/org/tron/common/TestConstants.java +++ b/framework/src/test/java/org/tron/common/TestConstants.java @@ -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. diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java index 582f5157b27..fd744146268 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeTest.java @@ -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; @@ -75,7 +76,7 @@ public class BandWidthRuntimeOutOfTimeTest extends BaseTest { "--storage-index-directory", indexDirectory, "--debug" }, - "config-test-mainnet.conf" + TestConstants.TEST_CONF ); } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java index 7e75f2b31d1..fb19a53467b 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeOutOfTimeWithCheckTest.java @@ -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; @@ -76,7 +77,7 @@ public class BandWidthRuntimeOutOfTimeWithCheckTest extends BaseTest { "--storage-index-directory", indexDirectory, "--debug" }, - "config-test-mainnet.conf" + TestConstants.TEST_CONF ); } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java index 8e38c08c4d8..c415ab44af7 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeTest.java @@ -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; @@ -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 ); } diff --git a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java index aae8cb5702d..4d9490c4173 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/BandWidthRuntimeWithCheckTest.java @@ -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; @@ -77,7 +78,7 @@ public class BandWidthRuntimeWithCheckTest extends BaseTest { "--storage-db-directory", dbDirectory, "--storage-index-directory", indexDirectory, }, - "config-test-mainnet.conf" + TestConstants.TEST_CONF ); } diff --git a/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java b/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java index 0a8fbac009c..00be867fd59 100644 --- a/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java +++ b/framework/src/test/java/org/tron/core/ShieldedTRC20BuilderTest.java @@ -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; @@ -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"); diff --git a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java index 3ae5677fbda..2fb563cf9af 100644 --- a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java @@ -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[] {"-c", TestConstants.TEST_CONF, "--keystore-factory"}, ""); CommonParameter parameter = Args.getInstance(); @@ -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 storage = new HashMap<>(); diff --git a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java index 83a65926446..26b136a3648 100644 --- a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java +++ b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java @@ -177,7 +177,7 @@ public void testConstructor() { public void testLocalWitnessConfig() throws IOException { Args.setParam( new String[]{"--output-directory", temporaryFolder.newFolder().toString(), "-w", "--debug"}, - "config-localtest.conf"); + "config-shield.conf"); LocalWitnesses witness = Args.getLocalWitnesses(); Assert.assertNotNull(witness.getPrivateKey()); Assert.assertNotNull(witness.getWitnessAccountAddress()); diff --git a/framework/src/test/java/org/tron/core/config/args/StorageTest.java b/framework/src/test/java/org/tron/core/config/args/StorageTest.java index eb349a2d146..750e9c072f6 100644 --- a/framework/src/test/java/org/tron/core/config/args/StorageTest.java +++ b/framework/src/test/java/org/tron/core/config/args/StorageTest.java @@ -16,21 +16,124 @@ package org.tron.core.config.args; import java.io.File; +import java.lang.reflect.Field; +import java.util.Arrays; 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(); + } + + /** + * set it as following: + * + * properties = [ + * { + * name = "account", + * path = "storage_directory_test", + * createIfMissing = true, + * paranoidChecks = true, + * verifyChecksums = true, + * compressionType = 1, // compressed with snappy + * blockSize = 4096, // 4 KB = 4 * 1024 B + * writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + * cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + * maxOpenFiles = 100 + * }, + * { + * name = "account-index", + * path = "storage_directory_test", + * createIfMissing = true, + * paranoidChecks = true, + * verifyChecksums = true, + * compressionType = 1, // compressed with snappy + * blockSize = 4096, // 4 KB = 4 * 1024 B + * writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + * cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B + * maxOpenFiles = 100 + * }, + * { # only for unit test + * name = "test_name", + * path = "test_path", + * createIfMissing = false, + * paranoidChecks = false, + * verifyChecksums = false, + * compressionType = 1, + * blockSize = 2, + * writeBufferSize = 3, + * cacheSize = 4, + * maxOpenFiles = 5 + * }, + * ] + */ + private static void setupStorage() { + StorageConfig sc = new StorageConfig(); + try { + setPrivateField(sc, "defaultDbOption", makeOverride(50)); + setPrivateField(sc, "defaultMDbOption", makeOverride(500)); + setPrivateField(sc, "defaultLDbOption", makeOverride(1000)); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + storage.setDefaultDbOptions(sc); + + StorageConfig.PropertyConfig account = new StorageConfig.PropertyConfig(); + account.setName("account"); + account.setPath("storage_directory_test"); + account.setCompressionType(1); + account.setBlockSize(4096); + account.setWriteBufferSize(10485760); + account.setCacheSize(10485760); + account.setMaxOpenFiles(100); + + StorageConfig.PropertyConfig accountIndex = new StorageConfig.PropertyConfig(); + accountIndex.setName("account-index"); + accountIndex.setPath("storage_directory_test"); + accountIndex.setCompressionType(1); + accountIndex.setBlockSize(4096); + accountIndex.setWriteBufferSize(10485760); + accountIndex.setCacheSize(10485760); + accountIndex.setMaxOpenFiles(100); + + StorageConfig.PropertyConfig testName = new StorageConfig.PropertyConfig(); + testName.setName("test_name"); + testName.setPath("test_path"); + testName.setCreateIfMissing(false); + testName.setParanoidChecks(false); + testName.setVerifyChecksums(false); + testName.setCompressionType(1); + testName.setBlockSize(2); + testName.setWriteBufferSize(3); + testName.setCacheSize(4); + testName.setMaxOpenFiles(5); + + storage.setPropertyMapFromBean(Arrays.asList(account, accountIndex, testName)); + } + + private static StorageConfig.DbOptionOverride makeOverride(int maxOpenFiles) { + StorageConfig.DbOptionOverride o = new StorageConfig.DbOptionOverride(); + o.setMaxOpenFiles(maxOpenFiles); + return o; + } + + private static void setPrivateField(Object obj, String name, Object value) + throws ReflectiveOperationException { + Field f = StorageConfig.class.getDeclaredField(name); + f.setAccessible(true); + f.set(obj, value); } @AfterClass diff --git a/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java b/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java index 08848fc9da1..d158a738883 100644 --- a/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java +++ b/framework/src/test/java/org/tron/core/db/TransactionTraceTest.java @@ -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; @@ -67,7 +68,7 @@ public class TransactionTraceTest extends BaseTest { "--storage-index-directory", indexDirectory, "--debug" }, - "config-test-mainnet.conf" + TestConstants.TEST_CONF ); } diff --git a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java index d1edd92c109..d6fcd41f4f8 100644 --- a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java +++ b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java @@ -27,7 +27,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()}, "config-test.conf"); Args.getInstance().setSolidityNode(true); } diff --git a/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java index f62d47d5367..dda4879ba34 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java @@ -21,7 +21,7 @@ public class ApiUtilTest { @BeforeClass public static void init() { - Args.setParam(new String[]{}, "config-localtest.conf"); + Args.setParam(new String[]{}, "config-shield.conf"); } @AfterClass diff --git a/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java b/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java index 5d403b54f90..0a45cc5106c 100644 --- a/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/LibrustzcashTest.java @@ -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; @@ -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(); diff --git a/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java b/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java index e21ba8010b5..d7a9d3040e0 100644 --- a/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/MerkleTreeTest.java @@ -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; @@ -38,7 +39,7 @@ public class MerkleTreeTest extends BaseTest { "--storage-index-directory", indexDirectory, "--debug" }, - "config-test-mainnet.conf" + TestConstants.TEST_CONF ); } diff --git a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java index 3c3fb14b2b1..bb0d91e8e69 100644 --- a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java @@ -39,7 +39,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()}, "config-shield.conf"); FROM_ADDRESS = Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0"; } diff --git a/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java b/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java index 8693bf0716d..08de83ca8bf 100644 --- a/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/SendCoinShieldTest.java @@ -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; @@ -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"; diff --git a/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java b/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java index 7143cef43e2..0d14d6fbc26 100755 --- a/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/ShieldedReceiveTest.java @@ -1,6 +1,6 @@ package org.tron.core.zksnark; -import static org.tron.common.TestConstants.LOCAL_CONF; +import static org.tron.common.TestConstants.SHIELD_CONF; import static org.tron.common.utils.PublicMethod.getHexAddressByPrivateKey; import static org.tron.common.utils.PublicMethod.getRandomPrivateKey; @@ -34,7 +34,6 @@ import org.tron.common.crypto.ECKey; import org.tron.common.parameter.CommonParameter; import org.tron.common.utils.ByteArray; -import org.tron.common.utils.PublicMethod; import org.tron.common.utils.Sha256Hash; import org.tron.common.utils.client.utils.TransactionUtils; import org.tron.common.zksnark.IncrementalMerkleTreeContainer; @@ -148,8 +147,7 @@ public class ShieldedReceiveTest extends BaseTest { private static boolean init; static { - Args.setParam(new String[]{"--output-directory", dbPath(), "-w"}, - LOCAL_CONF); + Args.setParam(new String[]{"--output-directory", dbPath(), "-w"}, SHIELD_CONF); ADDRESS_ONE_PRIVATE_KEY = getRandomPrivateKey(); FROM_ADDRESS = getHexAddressByPrivateKey(ADDRESS_ONE_PRIVATE_KEY); } diff --git a/framework/src/test/resources/args-test.conf b/framework/src/test/resources/args-test.conf deleted file mode 100644 index db889483270..00000000000 --- a/framework/src/test/resources/args-test.conf +++ /dev/null @@ -1,223 +0,0 @@ -net { - # type is deprecated and has no effect. - # type = mainnet -} - - -storage { - # Directory for storing persistent data - - db.engine = "LEVELDB" - db.directory = "database", - index.directory = "index", - - # You can custom these 14 databases' configs: - - # account, account-index, asset-issue, block, block-index, - # block_KDB, peers, properties, recent-block, trans, - # utxo, votes, witness, witness_schedule. - - # Otherwise, db configs will remain defualt and data will be stored in - # the path of "output-directory" or which is set by "-d" ("--output-directory"). - - # Attention: name is a required field that must be set !!! - default = { - maxOpenFiles = 50 - } - defaultM = { - maxOpenFiles = 500 - } - defaultL = { - maxOpenFiles = 1000 - } - properties = [ - { - name = "account", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - { - name = "account-index", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - { # only for unit test - name = "test_name", - path = "test_path", - createIfMissing = false, - paranoidChecks = false, - verifyChecksums = false, - compressionType = 1, - blockSize = 2, - writeBufferSize = 3, - cacheSize = 4, - maxOpenFiles = 5 - }, - ] - - needToUpdateAsset = false - -} - -node.discovery = { - enable = true - persist = true - external.ip = "46.168.1.1" -} - -node { - - trustNode = "127.0.0.1:50051" - - listen.port = 18888 - - active = [] - - maxConnections = 30 - minConnections = 8 - minActiveConnections = 3 - inactiveThreshold = 600 //seconds - - p2p { - version = 43 # 43: testnet; 101: debug - } - - rpc { - port = 50051 - } - -} - -sync { - node.count = 30 -} - -seed.node = { - ip.list = [ - ] -} - -genesis.block = { - # Reserve balance - assets = [ - { - accountName = "Devaccount" - accountType = "AssetIssue" - address = "27d3byPxZXKQWfXX7sJvemJJuv5M65F3vjS" - balance = "10000000000000000" - }, - { - accountName = "Zion" - accountType = "AssetIssue" - address = "27fXgQ46DcjEsZ444tjZPKULcxiUfDrDjqj" - balance = "15000000000000000" - }, - { - accountName = "Sun" - accountType = "AssetIssue" - address = "27SWXcHuQgFf9uv49FknBBBYBaH3DUk4JPx" - balance = "10000000000000000" - }, - { - accountName = "Blackhole" - accountType = "AssetIssue" - address = "27WtBq2KoSy5v8VnVZBZHHJcDuWNiSgjbE3" - balance = "-9223372036854775808" - } - ] - - witnesses = [ - { - address: 27Ssb1WE8FArwJVRRb8Dwy3ssVGuLY8L3S1 - url = "http://Mercury.org", - voteCount = 105 - }, - { - address: 27anh4TDZJGYpsn4BjXzb7uEArNALxwiZZW - url = "http://Venus.org", - voteCount = 104 - }, - { - address: 27Wkfa5iEJtsKAKdDzSmF1b2gDm5s49kvdZ - url = "http://Earth.org", - voteCount = 103 - }, - { - address: 27bqKYX9Bgv7dgTY7xBw5SUHZ8EGaPSikjx - url = "http://Mars.org", - voteCount = 102 - }, - { - address: 27fASUY6qKtsaAEPz6QxhZac2KYVz2ZRTXW - url = "http://Jupiter.org", - voteCount = 101 - }, - { - address: 27Q3RSbiqm59VXcF8shQWHKbyztfso5FwvP - url = "http://Saturn.org", - voteCount = 100 - }, - { - address: 27YkUVSuvCK3K84DbnFnxYUxozpi793PTqZ - url = "http://Uranus.org", - voteCount = 99 - }, - { - address: 27kdTBTDJ16hK3Xqr8PpCuQJmje1b94CDJU - url = "http://Neptune.org", - voteCount = 98 - }, - { - address: 27mw9UpRy7inTMQ5kUzsdTc2QZ6KvtCX4uB - url = "http://Pluto.org", - voteCount = 97 - }, - { - address: 27QzC4PeQZJ2kFMUXiCo4S8dx3VWN5U9xcg - url = "http://Altair.org", - voteCount = 96 - }, - { - address: 27VZHn9PFZwNh7o2EporxmLkpe157iWZVkh - url = "http://AlphaLyrae.org", - voteCount = 95 - } - ] - - timestamp = "0" #2017-8-26 12:00:00 - - parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000" -} - - -localwitness = [ - -] - -block = { - needSyncCheck = true # first node : false, other : true -} - -vm = { - supportConstant = true - minTimeRatio = 0.0 - maxTimeRatio = 5.0 -} -committee = { - allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 - allowOldRewardOpt = 1 -} diff --git a/framework/src/test/resources/config-localtest.conf b/framework/src/test/resources/config-shield.conf similarity index 96% rename from framework/src/test/resources/config-localtest.conf rename to framework/src/test/resources/config-shield.conf index 4c6910e3d7a..f488799d9d8 100644 --- a/framework/src/test/resources/config-localtest.conf +++ b/framework/src/test/resources/config-shield.conf @@ -169,18 +169,7 @@ node { seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] ip.list = [ - "127.0.0.1:6666", - // "127.0.0.1:7777", - // "127.0.0.1:8888", - // "127.0.0.1:9999", ] } diff --git a/framework/src/test/resources/config-test-index.conf b/framework/src/test/resources/config-test-index.conf deleted file mode 100644 index 583064a37f5..00000000000 --- a/framework/src/test/resources/config-test-index.conf +++ /dev/null @@ -1,174 +0,0 @@ -net { - # type is deprecated and has no effect. - # type = mainnet -} - - -storage { - # Directory for storing persistent data - - db.directory = "database", - index.directory = "index", - - # You can custom these 14 databases' configs: - - # account, account-index, asset-issue, block, block-index, - # block_KDB, peers, properties, recent-block, trans, - # utxo, votes, witness, witness_schedule. - - # Otherwise, db configs will remain defualt and data will be stored in - # the path of "output-directory" or which is set by "-d" ("--output-directory"). - - # Attention: name is a required field that must be set !!! - properties = [ - { - name = "account", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - { - name = "account-index", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - ] - - needToUpdateAsset = false - -} - -node.discovery = { - enable = true - persist = true - external.ip = "" -} - -node { - listen.port = 18888 - - active = [ - # Sample entries: - # { url = "enode://@hostname.com:30303" } - # { - # ip = hostname.com - # port = 30303 - # nodeId = e437a4836b77ad9d9ffe73ee782ef2614e6d8370fcf62191a6e488276e23717147073a7ce0b444d485fff5a0c34c4577251a7a990cf80d8542e21b95aa8c5e6c - # } - ] - - p2p { - version = 43 # 43: testnet; 101: debug - } - - http { - fullNodeEnable = false - solidityEnable = false - PBFTEnable = false - } - - jsonrpc { - httpFullNodeEnable = false - httpSolidityEnable = false - httpPBFTEnable = false - # maxBlockRange = 5000 - # maxSubTopics = 1000 - # maxBlockFilterNum = 30000 - } - - rpc { - port = 50051 - enable = false - solidityEnable = false - PBFTEnable = false - # Number of gRPC thread, default availableProcessors / 2 - # thread = 16 - - # The maximum number of concurrent calls permitted for each incoming connection - # maxConcurrentCallsPerConnection = - - # The HTTP/2 flow control window, default 1MB - # flowControlWindow = - - # Connection being idle for longer than which will be gracefully terminated - maxConnectionIdleInMillis = 60000 - - # Connection lasting longer than which will be gracefully terminated - # maxConnectionAgeInMillis = - - # The maximum message size allowed to be received on the server, default 4MB - # maxMessageSize = - - # The maximum size of header list allowed to be received, default 8192 - # maxHeaderListSize = - } - -} - -sync { - node.count = 30 -} - -seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] - ip.list = [ - "47.254.16.55:18888", - "47.254.18.49:18888", - "18.188.111.53:18888", - "54.219.41.56:18888", - "35.169.113.187:18888", - "34.214.241.188:18888", - "47.254.146.147:18888", - "47.254.144.25:18888", - "47.91.246.252:18888", - "47.91.216.69:18888", - "39.106.220.120:18888" - ] -} - -genesis.block = { - # Reserve balance - assets = [ - { - accountName = "Blackhole" - accountType = "AssetIssue" - address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" - balance = "-9223372036854775808" - } - ] - - witnesses = [ - - ] - - timestamp = "0" #2017-8-26 12:00:00 - - parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000" -} - -localwitness = [ - -] - -block = { - needSyncCheck = true # first node : false, other : true -} diff --git a/framework/src/test/resources/config-test-mainnet.conf b/framework/src/test/resources/config-test-mainnet.conf deleted file mode 100644 index 938812f8214..00000000000 --- a/framework/src/test/resources/config-test-mainnet.conf +++ /dev/null @@ -1,242 +0,0 @@ -net { - # type is deprecated and has no effect. - # type = mainnet -} - - -storage { - # Directory for storing persistent data - - db.directory = "database", - index.directory = "index", - - # You can custom these 14 databases' configs: - - # account, account-index, asset-issue, block, block-index, - # block_KDB, peers, properties, recent-block, trans, - # utxo, votes, witness, witness_schedule. - - # Otherwise, db configs will remain defualt and data will be stored in - # the path of "output-directory" or which is set by "-d" ("--output-directory"). - - # Attention: name is a required field that must be set !!! - properties = [ - // { - // name = "account", - // path = "storage_directory_test", - // createIfMissing = true, - // paranoidChecks = true, - // verifyChecksums = true, - // compressionType = 1, // compressed with snappy - // blockSize = 4096, // 4 KB = 4 * 1024 B - // writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // maxOpenFiles = 100 - // }, - // { - // name = "account-index", - // path = "storage_directory_test", - // createIfMissing = true, - // paranoidChecks = true, - // verifyChecksums = true, - // compressionType = 1, // compressed with snappy - // blockSize = 4096, // 4 KB = 4 * 1024 B - // writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // maxOpenFiles = 100 - // }, - ] - - needToUpdateAsset = false -} - -node.discovery = { - enable = true - persist = true - external.ip = "46.168.1.1" -} - -node { - - trustNode = "127.0.0.1:50051" - - listen.port = 18888 - - active = [ - # Sample entries: - # { url = "enode://@hostname.com:30303" } - # { - # ip = hostname.com - # port = 30303 - # nodeId = e437a4836b77ad9d9ffe73ee782ef2614e6d8370fcf62191a6e488276e23717147073a7ce0b444d485fff5a0c34c4577251a7a990cf80d8542e21b95aa8c5e6c - # } - ] - - maxConnections = 30 - minConnections = 8 - minActiveConnections = 3 - - p2p { - version = 43 # 43: testnet; 101: debug - } - - http { - fullNodeEnable = false - solidityEnable = false - PBFTEnable = false - } - - jsonrpc { - httpFullNodeEnable = false - httpSolidityEnable = false - httpPBFTEnable = false - # maxBlockRange = 5000 - # maxSubTopics = 1000 - # maxBlockFilterNum = 50000 - # maxLogFilterNum = 20000 - } - - rpc { - enable = false - solidityEnable = false - PBFTEnable = false - } - -} - -sync { - node.count = 30 -} - -seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] - ip.list = [ - "47.254.16.55:18888", - "47.254.18.49:18888", - "18.188.111.53:18888", - "54.219.41.56:18888", - "35.169.113.187:18888", - "34.214.241.188:18888", - "47.254.146.147:18888", - "47.254.144.25:18888", - "47.91.246.252:18888", - "47.91.216.69:18888", - "39.106.220.120:18888" - ] -} - -genesis.block = { - # Reserve balance - assets = [ - # { - # accountName = "tron" - # accountType = "AssetIssue" # Normal/AssetIssue/Contract - # address = "TFveVqgQKAdFa12DNnXTw7GHCDQK7fUVen" - # balance = "10" - # } - { - accountName = "Devaccount" - accountType = "AssetIssue" - address = "TPwJS5eC5BPGyMGtYTHNhPTB89sUWjDSSu" - balance = "10000000000000000" - }, - { - accountName = "Zion" - accountType = "AssetIssue" - address = "TSRNrjmrAbDdrsoqZsv7FZUtAo13fwoCzv" - balance = "15000000000000000" - }, - { - accountName = "Sun" - accountType = "AssetIssue" - address = "TDQE4yb3E7dvDjouvu8u7GgSnMZbxAEumV" - balance = "10000000000000000" - }, - { - accountName = "Blackhole" - accountType = "AssetIssue" - address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" - balance = "-9223372036854775808" - } - ] - - witnesses = [ - { - address: TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW - url = "http://Mercury.org", - voteCount = 105 - }, - { - address: TMgPX8uBr8XbBboxQgMK3zNS4SgjUa3eiP - url = "http://Venus.org", - voteCount = 104 - }, - { - address: THeN2mPrrkr5U9Nzfb7xwgAwRqcFWcL7pR - url = "http://Earth.org", - voteCount = 103 - }, - { - address: TNj21CppEn6PzHHtdLHoNZRpLJnxogNnAX - url = "http://Mars.org", - voteCount = 102 - }, - { - address: TS48wDnTskrLU49kmZKRVfkHXd2NQ3dZP4 - url = "http://Jupiter.org", - voteCount = 101 - }, - { - address: TAw7uHQUJw8FqRzuYqmEDQkFCyCGE4JcsW - url = "http://Saturn.org", - voteCount = 100 - }, - { - address: TKeAx8bYkB25RsyNTQ9gUa75CuEVfFbF6N - url = "http://Uranus.org", - voteCount = 99 - }, - { - address: TXX9e8tvYxg5MMbcoYAvqVT2wiXyacjs65 - url = "http://Neptune.org", - voteCount = 98 - }, - { - address: TYpqwW7bfamDfDqXA9EMPhAfmArKMicxp9 - url = "http://Pluto.org", - voteCount = 97 - }, - { - address: TBstX5L37A1WZBEJPM9nNDnDFa2kcTVSmc - url = "http://Altair.org", - voteCount = 96 - }, - { - address: TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W - url = "http://AlphaLyrae.org", - voteCount = 95 - } - ] - - timestamp = "0" #2017-8-26 12:00:00 - - parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000" -} - -localwitness = [ - -] - -block = { - needSyncCheck = true # first node : false, other : true -} - -committee = { - allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 -} diff --git a/framework/src/test/resources/config-test-storagetest.conf b/framework/src/test/resources/config-test-storagetest.conf deleted file mode 100644 index 113c8371ba1..00000000000 --- a/framework/src/test/resources/config-test-storagetest.conf +++ /dev/null @@ -1,287 +0,0 @@ -net { - # type is deprecated and has no effect. - # type = mainnet -} - - -storage { - # Directory for storing persistent data - - db.engine = "LEVELDB" - db.directory = "database", - index.directory = "index", - - # You can custom these 14 databases' configs: - - # account, account-index, asset-issue, block, block-index, - # block_KDB, peers, properties, recent-block, trans, - # utxo, votes, witness, witness_schedule. - - # Otherwise, db configs will remain defualt and data will be stored in - # the path of "output-directory" or which is set by "-d" ("--output-directory"). - - # Attention: name is a required field that must be set !!! - default = { - maxOpenFiles = 50 - } - defaultM = { - maxOpenFiles = 500 - } - defaultL = { - maxOpenFiles = 1000 - } - properties = [ - { - name = "account", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - { - name = "account-index", - path = "storage_directory_test", - createIfMissing = true, - paranoidChecks = true, - verifyChecksums = true, - compressionType = 1, // compressed with snappy - blockSize = 4096, // 4 KB = 4 * 1024 B - writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - maxOpenFiles = 100 - }, - { # only for unit test - name = "test_name", - path = "test_path", - createIfMissing = false, - paranoidChecks = false, - verifyChecksums = false, - compressionType = 1, - blockSize = 2, - writeBufferSize = 3, - cacheSize = 4, - maxOpenFiles = 5 - }, - ] - - needToUpdateAsset = false - -} - -node.discovery = { - enable = true - persist = true - external.ip = "46.168.1.1" -} - -node { - - trustNode = "127.0.0.1:50051" - - listen.port = 18888 - - active = [ - # Sample entries: - # { url = "enode://@hostname.com:30303" } - # { - # ip = hostname.com - # port = 30303 - # nodeId = e437a4836b77ad9d9ffe73ee782ef2614e6d8370fcf62191a6e488276e23717147073a7ce0b444d485fff5a0c34c4577251a7a990cf80d8542e21b95aa8c5e6c - # } - ] - - maxConnections = 30 - minConnections = 8 - minActiveConnections = 3 - - p2p { - version = 43 # 43: testnet; 101: debug - } - - rpc { - port = 50051 - - # Number of gRPC thread, default availableProcessors / 2 - # thread = 16 - - # The maximum number of concurrent calls permitted for each incoming connection - # maxConcurrentCallsPerConnection = - - # The HTTP/2 flow control window, default 1MB - # flowControlWindow = - - # Connection being idle for longer than which will be gracefully terminated - maxConnectionIdleInMillis = 60000 - - # Connection lasting longer than which will be gracefully terminated - # maxConnectionAgeInMillis = - - # The maximum message size allowed to be received on the server, default 4MB - # maxMessageSize = - - # The maximum size of header list allowed to be received, default 8192 - # maxHeaderListSize = - } - -} - -sync { - node.count = 30 -} - -seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] - ip.list = [ - "47.254.16.55:18888", - "47.254.18.49:18888", - "18.188.111.53:18888", - "54.219.41.56:18888", - "35.169.113.187:18888", - "34.214.241.188:18888", - "47.254.146.147:18888", - "47.254.144.25:18888", - "47.91.246.252:18888", - "47.91.216.69:18888", - "39.106.220.120:18888" - ] -} - -genesis.block = { - # Reserve balance - assets = [ - # { - # accountName = "tron" - # accountType = "AssetIssue" # Normal/AssetIssue/Contract - # address = "TFveVqgQKAdFa12DNnXTw7GHCDQK7fUVen" - # balance = "10" - # } - { - accountName = "Devaccount" - accountType = "AssetIssue" - address = "TPwJS5eC5BPGyMGtYTHNhPTB89sUWjDSSu" - balance = "10000000000000000" - }, - { - accountName = "Zion" - accountType = "AssetIssue" - address = "TSRNrjmrAbDdrsoqZsv7FZUtAo13fwoCzv" - balance = "15000000000000000" - }, - { - accountName = "Sun" - accountType = "AssetIssue" - address = "TDQE4yb3E7dvDjouvu8u7GgSnMZbxAEumV" - balance = "10000000000000000" - }, - { - accountName = "Blackhole" - accountType = "AssetIssue" - address = "THmtHi1Rzq4gSKYGEKv1DPkV7au6xU1AUB" - balance = "-9223372036854775808" - } - ] - - witnesses = [ - { - address: TDmHUBuko2qhcKBCGGafu928hMRj1tX2RW - url = "http://Mercury.org", - voteCount = 105 - }, - { - address: TMgPX8uBr8XbBboxQgMK3zNS4SgjUa3eiP - url = "http://Venus.org", - voteCount = 104 - }, - { - address: THeN2mPrrkr5U9Nzfb7xwgAwRqcFWcL7pR - url = "http://Earth.org", - voteCount = 103 - }, - { - address: TNj21CppEn6PzHHtdLHoNZRpLJnxogNnAX - url = "http://Mars.org", - voteCount = 102 - }, - { - address: TS48wDnTskrLU49kmZKRVfkHXd2NQ3dZP4 - url = "http://Jupiter.org", - voteCount = 101 - }, - { - address: TAw7uHQUJw8FqRzuYqmEDQkFCyCGE4JcsW - url = "http://Saturn.org", - voteCount = 100 - }, - { - address: TKeAx8bYkB25RsyNTQ9gUa75CuEVfFbF6N - url = "http://Uranus.org", - voteCount = 99 - }, - { - address: TXX9e8tvYxg5MMbcoYAvqVT2wiXyacjs65 - url = "http://Neptune.org", - voteCount = 98 - }, - { - address: TYpqwW7bfamDfDqXA9EMPhAfmArKMicxp9 - url = "http://Pluto.org", - voteCount = 97 - }, - { - address: TBstX5L37A1WZBEJPM9nNDnDFa2kcTVSmc - url = "http://Altair.org", - voteCount = 96 - }, - { - address: TGSzEq4t7oMTRcn1VxDghRu5r5bWAE5D1W - url = "http://AlphaLyrae.org", - voteCount = 95 - } - ] - - timestamp = "0" #2017-8-26 12:00:00 - - parentHash = "0x0000000000000000000000000000000000000000000000000000000000000000" -} - - -// Optional.The default is empty. -// It is used when the witness account has set the witnessPermission. -// When it is not empty, the localWitnessAccountAddress represents the address of the witness account, -// and the localwitness is configured with the private key of the witnessPermissionAddress in the witness account. -// When it is empty,the localwitness is configured with the private key of the witness account. - -//localWitnessAccountAddress = - -localwitness = [ - -] - -block = { - needSyncCheck = true # first node : false, other : true -} - -vm = { - supportConstant = true - minTimeRatio = 0.0 - maxTimeRatio = 5.0 - - # In rare cases, transactions that will be within the specified maximum execution time (default 10(ms)) are re-executed and packaged - # longRunningTime = 10 -} -committee = { - allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 - allowOldRewardOpt = 1 - allowNewRewardAlgorithm = 1 -} diff --git a/framework/src/test/resources/config-test.conf b/framework/src/test/resources/config-test.conf index 85172c37710..d4e7cd00e7c 100644 --- a/framework/src/test/resources/config-test.conf +++ b/framework/src/test/resources/config-test.conf @@ -220,25 +220,7 @@ sync { } seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] ip.list = [ - "47.254.16.55:18888", - "47.254.18.49:18888", - "18.188.111.53:18888", - "54.219.41.56:18888", - "35.169.113.187:18888", - "34.214.241.188:18888", - "47.254.146.147:18888", - "47.254.144.25:18888", - "47.91.246.252:18888", - "47.91.216.69:18888", - "39.106.220.120:18888" ] } diff --git a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java index 960c1414769..fd3592c5fff 100644 --- a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java @@ -74,7 +74,7 @@ public void init(String dbType, boolean historyBalanceLookup) throws IOException dbPath = folder.newFolder().toString(); Args.setParam(new String[] { "-d", dbPath, "-w", "--p2p-disable", "true", "--storage-db-engine", dbType}, - "config-localtest.conf"); + "config-shield.conf"); // allow account root Args.getInstance().setAllowAccountStateRoot(1); Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); From ca56f41944984994c4b48ae16c27b09597031b3d Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Wed, 20 May 2026 11:58:09 +0800 Subject: [PATCH 2/6] fix testcase of ArgsTest --- framework/src/test/java/org/tron/core/config/args/ArgsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java index 2fb563cf9af..b78879703ef 100644 --- a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java @@ -72,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(); From e0ab5f5d952446483511c826ca5917f2940ecda8 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Wed, 20 May 2026 13:31:52 +0800 Subject: [PATCH 3/6] use SHIELD_CONF instead of config file name --- .../runtime/vm/PrecompiledContractsVerifyProofTest.java | 3 ++- .../java/org/tron/core/config/args/LocalWitnessTest.java | 4 +++- .../java/org/tron/core/db/api/AssetUpdateHelperTest.java | 3 ++- .../src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java | 3 ++- .../test/java/org/tron/core/zksnark/NoteEncDecryTest.java | 3 ++- framework/src/test/resources/config-shield.conf | 6 ------ plugins/src/test/java/org/tron/plugins/DbLiteTest.java | 3 ++- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java index 27e7891e6d8..9ea9ab922a6 100644 --- a/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java +++ b/framework/src/test/java/org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.java @@ -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; @@ -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); diff --git a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java index 26b136a3648..1b30518c7e3 100644 --- a/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java +++ b/framework/src/test/java/org/tron/core/config/args/LocalWitnessTest.java @@ -177,10 +177,11 @@ public void testConstructor() { public void testLocalWitnessConfig() throws IOException { Args.setParam( new String[]{"--output-directory", temporaryFolder.newFolder().toString(), "-w", "--debug"}, - "config-shield.conf"); + TestConstants.SHIELD_CONF); LocalWitnesses witness = Args.getLocalWitnesses(); Assert.assertNotNull(witness.getPrivateKey()); Assert.assertNotNull(witness.getWitnessAccountAddress()); + Args.clearParam(); } @Test @@ -191,5 +192,6 @@ public void testNullLocalWitnessConfig() throws IOException { LocalWitnesses witness = Args.getLocalWitnesses(); Assert.assertNull(witness.getPrivateKey()); Assert.assertNull(witness.getWitnessAccountAddress()); + Args.clearParam(); } } diff --git a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java index d6fcd41f4f8..be4a0b87c1a 100644 --- a/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java +++ b/framework/src/test/java/org/tron/core/db/api/AssetUpdateHelperTest.java @@ -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; @@ -27,7 +28,7 @@ public class AssetUpdateHelperTest extends BaseTest { private static boolean init; static { - Args.setParam(new String[]{"-d", dbPath()}, "config-test.conf"); + Args.setParam(new String[]{"-d", dbPath()}, TestConstants.TEST_CONF); Args.getInstance().setSolidityNode(true); } diff --git a/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java index dda4879ba34..a74ca3a69a4 100644 --- a/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java +++ b/framework/src/test/java/org/tron/core/jsonrpc/ApiUtilTest.java @@ -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; @@ -21,7 +22,7 @@ public class ApiUtilTest { @BeforeClass public static void init() { - Args.setParam(new String[]{}, "config-shield.conf"); + Args.setParam(new String[]{}, TestConstants.TEST_CONF); } @AfterClass diff --git a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java index bb0d91e8e69..e41b9f64c9a 100644 --- a/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java +++ b/framework/src/test/java/org/tron/core/zksnark/NoteEncDecryTest.java @@ -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; @@ -39,7 +40,7 @@ public class NoteEncDecryTest extends BaseTest { private Wallet wallet; static { - Args.setParam(new String[]{"--output-directory", dbPath()}, "config-shield.conf"); + Args.setParam(new String[]{"--output-directory", dbPath()}, TestConstants.SHIELD_CONF); FROM_ADDRESS = Wallet.getAddressPreFixString() + "a7d8a35b260395c14aa456297662092ba3b76fc0"; } diff --git a/framework/src/test/resources/config-shield.conf b/framework/src/test/resources/config-shield.conf index f488799d9d8..4e257435c6d 100644 --- a/framework/src/test/resources/config-shield.conf +++ b/framework/src/test/resources/config-shield.conf @@ -270,9 +270,3 @@ committee = { allowTvmConstantinople = 1 allowTvmSolidity059 = 1 } - -log.level = { - root = "INFO" // TRACE;DEBUG;INFO;WARN;ERROR - allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 - allowMultiSign = 1 //mainnet:0 (reset by committee),test:1 -} diff --git a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java index fd3592c5fff..4ee7567ec28 100644 --- a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java @@ -15,6 +15,7 @@ import org.junit.Rule; import org.junit.rules.TemporaryFolder; import org.tron.api.WalletGrpc; +import org.tron.common.TestConstants; import org.tron.common.application.Application; import org.tron.common.application.ApplicationFactory; import org.tron.common.application.TronApplicationContext; @@ -74,7 +75,7 @@ public void init(String dbType, boolean historyBalanceLookup) throws IOException dbPath = folder.newFolder().toString(); Args.setParam(new String[] { "-d", dbPath, "-w", "--p2p-disable", "true", "--storage-db-engine", dbType}, - "config-shield.conf"); + TestConstants.SHIELD_CONF); // allow account root Args.getInstance().setAllowAccountStateRoot(1); Args.getInstance().setRpcPort(PublicMethod.chooseRandomPort()); From db6c27575d1e44ddeb69db35c8a9838e1e44ec13 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Thu, 21 May 2026 16:42:07 +0800 Subject: [PATCH 4/6] optimize ArgsTest and StorageTest --- .../org/tron/core/config/args/ArgsTest.java | 2 +- .../tron/core/config/args/StorageTest.java | 120 ++++-------------- 2 files changed, 24 insertions(+), 98 deletions(-) diff --git a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java index b78879703ef..37155171d72 100644 --- a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java @@ -50,7 +50,7 @@ public class ArgsTest { @Test public void get() { - Args.setParam(new String[] {"-c", TestConstants.TEST_CONF, "--keystore-factory"}, ""); + Args.setParam(new String[] {"--keystore-factory"}, TestConstants.TEST_CONF); CommonParameter parameter = Args.getInstance(); diff --git a/framework/src/test/java/org/tron/core/config/args/StorageTest.java b/framework/src/test/java/org/tron/core/config/args/StorageTest.java index 750e9c072f6..ea07275619f 100644 --- a/framework/src/test/java/org/tron/core/config/args/StorageTest.java +++ b/framework/src/test/java/org/tron/core/config/args/StorageTest.java @@ -15,9 +15,9 @@ package org.tron.core.config.args; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; import java.io.File; -import java.lang.reflect.Field; -import java.util.Arrays; import org.iq80.leveldb.CompressionType; import org.iq80.leveldb.Options; import org.junit.AfterClass; @@ -37,103 +37,29 @@ public class StorageTest { setupStorage(); } - /** - * set it as following: - * - * properties = [ - * { - * name = "account", - * path = "storage_directory_test", - * createIfMissing = true, - * paranoidChecks = true, - * verifyChecksums = true, - * compressionType = 1, // compressed with snappy - * blockSize = 4096, // 4 KB = 4 * 1024 B - * writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - * cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - * maxOpenFiles = 100 - * }, - * { - * name = "account-index", - * path = "storage_directory_test", - * createIfMissing = true, - * paranoidChecks = true, - * verifyChecksums = true, - * compressionType = 1, // compressed with snappy - * blockSize = 4096, // 4 KB = 4 * 1024 B - * writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - * cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - * maxOpenFiles = 100 - * }, - * { # only for unit test - * name = "test_name", - * path = "test_path", - * createIfMissing = false, - * paranoidChecks = false, - * verifyChecksums = false, - * compressionType = 1, - * blockSize = 2, - * writeBufferSize = 3, - * cacheSize = 4, - * maxOpenFiles = 5 - * }, - * ] - */ private static void setupStorage() { - StorageConfig sc = new StorageConfig(); - try { - setPrivateField(sc, "defaultDbOption", makeOverride(50)); - setPrivateField(sc, "defaultMDbOption", makeOverride(500)); - setPrivateField(sc, "defaultLDbOption", makeOverride(1000)); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } + 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); - - StorageConfig.PropertyConfig account = new StorageConfig.PropertyConfig(); - account.setName("account"); - account.setPath("storage_directory_test"); - account.setCompressionType(1); - account.setBlockSize(4096); - account.setWriteBufferSize(10485760); - account.setCacheSize(10485760); - account.setMaxOpenFiles(100); - - StorageConfig.PropertyConfig accountIndex = new StorageConfig.PropertyConfig(); - accountIndex.setName("account-index"); - accountIndex.setPath("storage_directory_test"); - accountIndex.setCompressionType(1); - accountIndex.setBlockSize(4096); - accountIndex.setWriteBufferSize(10485760); - accountIndex.setCacheSize(10485760); - accountIndex.setMaxOpenFiles(100); - - StorageConfig.PropertyConfig testName = new StorageConfig.PropertyConfig(); - testName.setName("test_name"); - testName.setPath("test_path"); - testName.setCreateIfMissing(false); - testName.setParanoidChecks(false); - testName.setVerifyChecksums(false); - testName.setCompressionType(1); - testName.setBlockSize(2); - testName.setWriteBufferSize(3); - testName.setCacheSize(4); - testName.setMaxOpenFiles(5); - - storage.setPropertyMapFromBean(Arrays.asList(account, accountIndex, testName)); - } - - private static StorageConfig.DbOptionOverride makeOverride(int maxOpenFiles) { - StorageConfig.DbOptionOverride o = new StorageConfig.DbOptionOverride(); - o.setMaxOpenFiles(maxOpenFiles); - return o; - } - - private static void setPrivateField(Object obj, String name, Object value) - throws ReflectiveOperationException { - Field f = StorageConfig.class.getDeclaredField(name); - f.setAccessible(true); - f.set(obj, value); + storage.setPropertyMapFromBean(sc.getProperties()); } @AfterClass From be582cbbdc7442743cd2b7716a4218005d5d512d Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Fri, 22 May 2026 09:22:28 +0800 Subject: [PATCH 5/6] delete unused config file from documents --- docs/implement-a-customized-actuator-en.md | 4 +- docs/implement-a-customized-actuator-zh.md | 4 +- .../utils/client/utils/Sha256Sm3Hash.java | 9 --- .../core/services/DelegationServiceTest.java | 59 ++++++++++++++++++- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/docs/implement-a-customized-actuator-en.md b/docs/implement-a-customized-actuator-en.md index 76e1852824c..912a49c5d63 100644 --- a/docs/implement-a-customized-actuator-en.md +++ b/docs/implement-a-customized-actuator-en.md @@ -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(); @@ -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 = ""; byte[] address = PublicMethed.getFinalAddress(key); ECKey ecKey = null; diff --git a/docs/implement-a-customized-actuator-zh.md b/docs/implement-a-customized-actuator-zh.md index 1128849916a..9aa0e258127 100644 --- a/docs/implement-a-customized-actuator-zh.md +++ b/docs/implement-a-customized-actuator-zh.md @@ -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(); @@ -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 = ""; byte[] address = PublicMethed.getFinalAddress(key); ECKey ecKey = null; diff --git a/framework/src/test/java/org/tron/common/utils/client/utils/Sha256Sm3Hash.java b/framework/src/test/java/org/tron/common/utils/client/utils/Sha256Sm3Hash.java index fde88385794..a034f9e816a 100644 --- a/framework/src/test/java/org/tron/common/utils/client/utils/Sha256Sm3Hash.java +++ b/framework/src/test/java/org/tron/common/utils/client/utils/Sha256Sm3Hash.java @@ -47,15 +47,6 @@ public class Sha256Sm3Hash implements Serializable, Comparable { 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); diff --git a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java index a16a71c4e59..d404dc77b64 100644 --- a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java @@ -7,24 +7,81 @@ import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.BaseTest; import org.tron.core.Wallet; import org.tron.core.capsule.AccountCapsule; +import org.tron.core.capsule.WitnessCapsule; import org.tron.core.config.args.Args; import org.tron.core.service.MortgageService; +import org.tron.core.store.WitnessStore; +import org.tron.protos.Protocol.AccountType; @Slf4j public class DelegationServiceTest extends BaseTest { + // The 27 genesis SR addresses and their vote counts from config.conf (GR1..GR27). + // GR1 has the highest votes (100000026), GR27 the lowest (100000000). + private static final String[] SR_ADDRESSES = { + "THKJYuUmMKKARNf7s2VT51g5uPY6KEqnat", + "TVDmPWGYxgi5DNeW8hXrzrhY8Y6zgxPNg4", + "TWKZN1JJPFydd5rMgMCV5aZTSiwmoksSZv", + "TDarXEG2rAD57oa7JTK785Yb2Et32UzY32", + "TAmFfS4Tmm8yKeoqZN8x51ASwdQBdnVizt", + "TK6V5Pw2UWQWpySnZyCDZaAvu1y48oRgXN", + "TGqFJPFiEqdZx52ZR4QcKHz4Zr3QXA24VL", + "TC1ZCj9Ne3j5v3TLx5ZCDLD55MU9g3XqQW", + "TWm3id3mrQ42guf7c4oVpYExyTYnEGy3JL", + "TCvwc3FV3ssq2rD82rMmjhT4PVXYTsFcKV", + "TFuC2Qge4GxA2U9abKxk1pw3YZvGM5XRir", + "TNGoca1VHC6Y5Jd2B1VFpFEhizVk92Rz85", + "TLCjmH6SqGK8twZ9XrBDWpBbfyvEXihhNS", + "TEEzguTtCihbRPfjf1CvW8Euxz1kKuvtR9", + "TZHvwiw9cehbMxrtTbmAexm9oPo4eFFvLS", + "TGK6iAKgBmHeQyp5hn3imB71EDnFPkXiPR", + "TLaqfGrxZ3dykAFps7M2B4gETTX1yixPgN", + "TX3ZceVew6yLC5hWTXnjrUFtiFfUDGKGty", + "TYednHaV9zXpnPchSywVpnseQxY9Pxw4do", + "TCf5cqLffPccEY7hcsabiFnMfdipfyryvr", + "TAa14iLEKPAetX49mzaxZmH6saRxcX7dT5", + "TBYsHxDmFaRmfCF3jZNmgeJE8sDnTNKHbz", + "TEVAq8dmSQyTYK7uP1ZnZpa6MBVR83GsV6", + "TRKJzrZxN34YyB8aBqqPDt7g4fv6sieemz", + "TRMP6SKeFUt5NtMLzJv8kdpYuHRnEGjGfe", + "TDbNE1VajxjpgM5p7FyGNDASt3UVoFbiD3", + "TLTDZBcPoJ8tZ6TTEeEqEvwYFk2wgotSfD" + }; + @Resource protected MortgageService mortgageService; + @Resource + protected WitnessStore witnessStore; + @BeforeClass public static void init() { Args.setParam(new String[] {"--output-directory", dbPath(), "--debug"}, - "config.conf"); + "config-test.conf"); + } + + @Before + public void setupWitnesses() { + Wallet.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); + // replace config-test.conf genesis witnesses with the 27 required ones + witnessStore.getAllWitnesses() + .forEach(w -> witnessStore.delete(w.getAddress().toByteArray())); + for (int i = 0; i < SR_ADDRESSES.length; i++) { + byte[] addr = decodeFromBase58Check(SR_ADDRESSES[i]); + long votes = 100000026L - i; + witnessStore.put(addr, new WitnessCapsule(ByteString.copyFrom(addr), votes, "http://GR.com")); + // payReward calls adjustAllowance(account, brokerage) which needs the account to exist + if (dbManager.getAccountStore().get(addr) == null) { + dbManager.getAccountStore().put(addr, + new AccountCapsule(ByteString.copyFrom(addr), AccountType.Normal)); + } + } } private void testPay(int cycle) { From 161d6f43156aeb573ed75537dd44e04e10d049d6 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Fri, 22 May 2026 11:49:49 +0800 Subject: [PATCH 6/6] revert changes of DelegationServiceTest --- .../core/services/DelegationServiceTest.java | 59 +------------------ 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java index d404dc77b64..a16a71c4e59 100644 --- a/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java +++ b/framework/src/test/java/org/tron/core/services/DelegationServiceTest.java @@ -7,81 +7,24 @@ import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.tron.common.BaseTest; import org.tron.core.Wallet; import org.tron.core.capsule.AccountCapsule; -import org.tron.core.capsule.WitnessCapsule; import org.tron.core.config.args.Args; import org.tron.core.service.MortgageService; -import org.tron.core.store.WitnessStore; -import org.tron.protos.Protocol.AccountType; @Slf4j public class DelegationServiceTest extends BaseTest { - // The 27 genesis SR addresses and their vote counts from config.conf (GR1..GR27). - // GR1 has the highest votes (100000026), GR27 the lowest (100000000). - private static final String[] SR_ADDRESSES = { - "THKJYuUmMKKARNf7s2VT51g5uPY6KEqnat", - "TVDmPWGYxgi5DNeW8hXrzrhY8Y6zgxPNg4", - "TWKZN1JJPFydd5rMgMCV5aZTSiwmoksSZv", - "TDarXEG2rAD57oa7JTK785Yb2Et32UzY32", - "TAmFfS4Tmm8yKeoqZN8x51ASwdQBdnVizt", - "TK6V5Pw2UWQWpySnZyCDZaAvu1y48oRgXN", - "TGqFJPFiEqdZx52ZR4QcKHz4Zr3QXA24VL", - "TC1ZCj9Ne3j5v3TLx5ZCDLD55MU9g3XqQW", - "TWm3id3mrQ42guf7c4oVpYExyTYnEGy3JL", - "TCvwc3FV3ssq2rD82rMmjhT4PVXYTsFcKV", - "TFuC2Qge4GxA2U9abKxk1pw3YZvGM5XRir", - "TNGoca1VHC6Y5Jd2B1VFpFEhizVk92Rz85", - "TLCjmH6SqGK8twZ9XrBDWpBbfyvEXihhNS", - "TEEzguTtCihbRPfjf1CvW8Euxz1kKuvtR9", - "TZHvwiw9cehbMxrtTbmAexm9oPo4eFFvLS", - "TGK6iAKgBmHeQyp5hn3imB71EDnFPkXiPR", - "TLaqfGrxZ3dykAFps7M2B4gETTX1yixPgN", - "TX3ZceVew6yLC5hWTXnjrUFtiFfUDGKGty", - "TYednHaV9zXpnPchSywVpnseQxY9Pxw4do", - "TCf5cqLffPccEY7hcsabiFnMfdipfyryvr", - "TAa14iLEKPAetX49mzaxZmH6saRxcX7dT5", - "TBYsHxDmFaRmfCF3jZNmgeJE8sDnTNKHbz", - "TEVAq8dmSQyTYK7uP1ZnZpa6MBVR83GsV6", - "TRKJzrZxN34YyB8aBqqPDt7g4fv6sieemz", - "TRMP6SKeFUt5NtMLzJv8kdpYuHRnEGjGfe", - "TDbNE1VajxjpgM5p7FyGNDASt3UVoFbiD3", - "TLTDZBcPoJ8tZ6TTEeEqEvwYFk2wgotSfD" - }; - @Resource protected MortgageService mortgageService; - @Resource - protected WitnessStore witnessStore; - @BeforeClass public static void init() { Args.setParam(new String[] {"--output-directory", dbPath(), "--debug"}, - "config-test.conf"); - } - - @Before - public void setupWitnesses() { - Wallet.setAddressPreFixByte(ADD_PRE_FIX_BYTE_MAINNET); - // replace config-test.conf genesis witnesses with the 27 required ones - witnessStore.getAllWitnesses() - .forEach(w -> witnessStore.delete(w.getAddress().toByteArray())); - for (int i = 0; i < SR_ADDRESSES.length; i++) { - byte[] addr = decodeFromBase58Check(SR_ADDRESSES[i]); - long votes = 100000026L - i; - witnessStore.put(addr, new WitnessCapsule(ByteString.copyFrom(addr), votes, "http://GR.com")); - // payReward calls adjustAllowance(account, brokerage) which needs the account to exist - if (dbManager.getAccountStore().get(addr) == null) { - dbManager.getAccountStore().put(addr, - new AccountCapsule(ByteString.copyFrom(addr), AccountType.Normal)); - } - } + "config.conf"); } private void testPay(int cycle) {