Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
geb789 committed Nov 17, 2019
1 parent fbdc5de commit 641800e
Show file tree
Hide file tree
Showing 16 changed files with 588 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.apache.commons.lang3.StringUtils;
import org.iq80.leveldb.CompressionType;
import org.iq80.leveldb.Options;
import org.tron.common.args.GenesisBlock;
import org.tron.common.setting.RocksDbSettings;
import org.tron.core.config.args.GenesisBlock;

public class DBConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.core.config.args;
package org.tron.common.args;

import static org.tron.common.utils.DecodeUtil.addressValid;

import com.google.protobuf.ByteString;
import java.io.Serializable;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.Commons;
import org.tron.common.utils.StringUtil;
import org.tron.protos.Protocol.AccountType;

Expand Down Expand Up @@ -48,7 +49,7 @@ public class Account implements Serializable {
* Account address is a 21-bits hex string.
*/
public void setAddress(final byte[] address) {
if (!Commons.addressValid(address)) {
if (!addressValid(address)) {
throw new IllegalArgumentException(
"The address(" + StringUtil.createReadableString(address) + ") must be a 21 bytes.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.tron.core.config.args;
package org.tron.common.args;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import lombok.Getter;

import org.tron.common.args.Witness;
import org.tron.common.args.Account;

public class GenesisBlock implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.core.config.args;
package org.tron.common.args;

import static org.tron.common.utils.DecodeUtil.addressValid;

import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.tron.common.utils.Commons;
import org.tron.common.utils.StringUtil;

public class Witness implements Serializable {
Expand All @@ -40,7 +41,7 @@ public class Witness implements Serializable {
* set address.
*/
public void setAddress(final byte[] address) {
if (!Commons.addressValid(address)) {
if (!addressValid(address)) {
throw new IllegalArgumentException(
"The address(" + StringUtil.createReadableString(address) + ") must be a 21 bytes.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import org.tron.common.args.GenesisBlock;
import org.tron.common.config.DbBackupConfig;
import org.tron.common.setting.RocksDbSettings;

Expand Down Expand Up @@ -421,6 +422,9 @@ public class CommonParameter {
@Getter
protected RocksDbSettings rocksDBCustomSettings;

@Getter
protected GenesisBlock genesisBlock;

private static double calcMaxTimeRatio() {
//return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1)));
return 5.0;
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/main/java/org/tron/consensus/base/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.tron.core.config.args.GenesisBlock;
import org.tron.common.args.GenesisBlock;

public class Param {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.tron.common.args.GenesisBlock;
import org.tron.common.utils.ByteArray;
import org.tron.consensus.ConsensusDelegate;
import org.tron.consensus.base.BlockHandle;
import org.tron.consensus.base.ConsensusInterface;
import org.tron.consensus.base.Param;
import org.tron.consensus.base.Param.Miner;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.config.args.GenesisBlock;

@Slf4j(topic = "consensus")
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import com.google.protobuf.ByteString;
import java.util.List;
import java.util.stream.Collectors;
import org.tron.common.args.GenesisBlock;
import org.tron.common.utils.ByteArray;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.config.args.Args;
import org.tron.core.config.args.GenesisBlock;
import org.tron.protos.Protocol.Transaction;

public class BlockUtil {
Expand Down
31 changes: 28 additions & 3 deletions framework/src/main/java/org/tron/core/config/args/Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
import org.apache.commons.lang3.StringUtils;
import org.spongycastle.util.encoders.Hex;
import org.springframework.stereotype.Component;
import org.tron.common.args.Account;
import org.tron.common.args.GenesisBlock;
import org.tron.common.args.Witness;
import org.tron.common.config.DbBackupConfig;
import org.tron.common.crypto.ECKey;
import org.tron.common.logsfilter.EventPluginConfig;
Expand Down Expand Up @@ -89,9 +92,6 @@ public class Args extends CommonParameter {
@Getter
private SeedNode seedNode;

@Getter
private GenesisBlock genesisBlock;

@Getter
@Setter
private LocalWitnesses localWitnesses = new LocalWitnesses();
Expand Down Expand Up @@ -1051,7 +1051,32 @@ public static void initDBConfig(Args cfgArgs) {

DBConfig.setOutputDirectoryConfig(cfgArgs.getOutputDirectory());
DBConfig.setRocksDbSettings(cfgArgs.getRocksDBCustomSettings());
DBConfig.setAllowMultiSign(cfgArgs.getAllowMultiSign());
DBConfig.setMaintenanceTimeInterval(cfgArgs.getMaintenanceTimeInterval());
DBConfig.setAllowAdaptiveEnergy(cfgArgs.getAllowAdaptiveEnergy());
DBConfig.setAllowDelegateResource(cfgArgs.getAllowDelegateResource());
DBConfig.setAllowTvmTransferTrc10(cfgArgs.getAllowTvmTransferTrc10());
DBConfig.setAllowTvmConstantinople(cfgArgs.getAllowTvmConstantinople());
DBConfig.setAllowTvmSolidity059(cfgArgs.getAllowTvmSolidity059());
DBConfig.setAllowSameTokenName(cfgArgs.getAllowSameTokenName());
DBConfig.setAllowCreationOfContracts(cfgArgs.getAllowCreationOfContracts());
DBConfig.setAllowShieldedTransaction(cfgArgs.getAllowShieldedTransaction());
DBConfig.setAllowAccountStateRoot(cfgArgs.getAllowAccountStateRoot());
DBConfig.setAllowProtoFilterNum(cfgArgs.getAllowProtoFilterNum());
DBConfig.setProposalExpireTime(cfgArgs.getProposalExpireTime());
DBConfig.setBlockNumForEneryLimit(cfgArgs.getBlockNumForEneryLimit());
DBConfig.setFullNodeAllowShieldedTransaction(cfgArgs.isFullNodeAllowShieldedTransactionArgs());
DBConfig.setZenTokenId(cfgArgs.getZenTokenId());
DBConfig.setCheckFrozenTime(cfgArgs.getCheckFrozenTime());
DBConfig.setValidContractProtoThreadNum(cfgArgs.getValidContractProtoThreadNum());
DBConfig.setVmTrace(cfgArgs.isVmTrace());
DBConfig.setDebug(cfgArgs.isDebug());
DBConfig.setMinTimeRatio(cfgArgs.getMinTimeRatio());
DBConfig.setMaxTimeRatio(cfgArgs.getMaxTimeRatio());
DBConfig.setSolidityNode(cfgArgs.isSolidityNode());
DBConfig.setSupportConstant(cfgArgs.isSupportConstant());
DBConfig.setLongRunningTime(cfgArgs.getLongRunningTime());
DBConfig.setChangedDelegation(cfgArgs.getChangedDelegation());
DBConfig.setActuatorSet(cfgArgs.getActuatorSet());
}

Expand Down
2 changes: 1 addition & 1 deletion framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.spongycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.tron.common.args.GenesisBlock;
import org.tron.common.logsfilter.EventPluginLoader;
import org.tron.common.logsfilter.FilterQuery;
import org.tron.common.logsfilter.capsule.BlockLogTriggerCapsule;
Expand Down Expand Up @@ -79,7 +80,6 @@
import org.tron.core.capsule.utils.BlockUtil;
import org.tron.core.config.Parameter.ChainConstant;
import org.tron.core.config.args.Args;
import org.tron.core.config.args.GenesisBlock;
import org.tron.core.consensus.ProposalController;
import org.tron.core.db.KhaosDatabase.KhaosBlock;
import org.tron.core.db.accountstate.TrieService;
Expand Down
Loading

0 comments on commit 641800e

Please sign in to comment.