Commit 50522bc1 authored by duanjinfei's avatar duanjinfei

add init console falg

parent 58fdecea
...@@ -10,10 +10,15 @@ ...@@ -10,10 +10,15 @@
"goRoutine": 1, "goRoutine": 1,
"generateAccCount": 500, "generateAccCount": 500,
"isDeployContract": false, "isDeployContract": false,
"isInitAccountBalance": true, "isInitAccountBalance": false,
"isInitAccCoin": true,
"isInitContractCoin": true,
"isInitErc20": true,
"isInitErc721Mint": true,
"isInitErc721":true ,
"startTokenId": 1, "startTokenId": 1,
"endTokenId": 100, "endTokenId": 100,
"transferType": [] "transferType": [1,2,3,4,5,6,7]
} }
......
...@@ -285,30 +285,41 @@ func InitCaseAccount(client *ethclient.Client, txArr []*types.Transaction) []*ty ...@@ -285,30 +285,41 @@ func InitCaseAccount(client *ethclient.Client, txArr []*types.Transaction) []*ty
auth.NoSend = true auth.NoSend = true
amount := big.NewInt(0) amount := big.NewInt(0)
amount.SetString("10000000000000000000", 10) amount.SetString("10000000000000000000", 10)
//trade := &coin.Trade{ trade := &coin.Trade{
// FromPrv: tool.Cfg.DeployPrv, FromPrv: tool.Cfg.DeployPrv,
// FromNonce: big.NewInt(int64(nonce)), FromNonce: big.NewInt(int64(nonce)),
// Amount: amount, Amount: amount,
// Gas: big.NewInt(50000), Gas: big.NewInt(50000),
// GasPrice: big.NewInt(1000000000), GasPrice: big.NewInt(1000000000),
// ChainId: tool.Cfg.ChainId, ChainId: tool.Cfg.ChainId,
//} }
contractMap := tool.ParseContractConfig("./config/contractConfig.json") contractMap := tool.ParseContractConfig("./config/contractConfig.json")
contractLen := len(contractMap) contractLen := len(contractMap)
tempTxArr := make([]*types.Transaction, 0)
//初始化From账户-500tx //初始化From账户-500tx
//coinTxArr, nonce := InitAccountCoin(txArr, nonce, amount, accArr) if tool.Cfg.IsInitAccCoin {
//txArr = append(txArr, coinTxArr...) tempTxArr, nonce = InitAccountCoin(txArr, nonce, amount, accArr)
txArr = append(txArr, tempTxArr...)
}
//初始化转账合约账户余额-10tx //初始化转账合约账户余额-10tx
//contractCoinTxArr, nonce := InitContractCoin(txArr, nonce, contractLen, contractMap, trade) if tool.Cfg.IsInitContractCoin {
//txArr = append(txArr, contractCoinTxArr...) tempTxArr, nonce = InitContractCoin(txArr, nonce, contractLen, contractMap, trade)
//// 初始化erc20 并且mint txArr = append(txArr, tempTxArr...)
erc20TxArr, nonce := InitErc20Acc(txArr, nonce, contractLen, contractMap, accArr, client, auth) }
txArr = append(txArr, erc20TxArr...) // 初始化erc20 并且mint
////初始化erc721 并且mint if tool.Cfg.IsInitErc20 {
//erc721MintTxArr, nonce := InitErc721AccMint(txArr, nonce, contractLen, contractMap, accArr, client, auth) tempTxArr, nonce = InitErc20Acc(txArr, nonce, contractLen, contractMap, accArr, client, auth)
//txArr = append(txArr, erc721MintTxArr...) txArr = append(txArr, tempTxArr...)
//erc721TransferTxArr, nonce := InitErc721AccTransfer(txArr, nonce, contractLen, contractMap, accArr, client, auth) }
//txArr = append(txArr, erc721TransferTxArr...) //初始化erc721 并且mint
if tool.Cfg.IsInitErc721Mint {
tempTxArr, nonce = InitErc721AccMint(txArr, nonce, contractLen, contractMap, accArr, client, auth)
txArr = append(txArr, tempTxArr...)
}
if tool.Cfg.IsInitErc721 {
tempTxArr, nonce = InitErc721AccTransfer(txArr, nonce, contractLen, contractMap, accArr, client, auth)
txArr = append(txArr, tempTxArr...)
}
log.Info("Init balance successful,wait send tran...........") log.Info("Init balance successful,wait send tran...........")
return txArr return txArr
} }
...@@ -492,7 +503,7 @@ func SendTransaction(trans []*types.Transaction) { ...@@ -492,7 +503,7 @@ func SendTransaction(trans []*types.Transaction) {
tran := trans[i] tran := trans[i]
//tranChanel <- tran //tranChanel <- tran
err := client.SendTransaction(context.Background(), tran) err := client.SendTransaction(context.Background(), tran)
log.Info("Send tran:", tran.Hash()) log.Info("Send tran:", tran.Hash(), ",nonce:", tran.Nonce())
if err != nil { if err != nil {
log.Error("send tx error:", err.Error(), ",tx:", tran.Hash().Hex()) log.Error("send tx error:", err.Error(), ",tx:", tran.Hash().Hex())
return return
......
...@@ -22,6 +22,11 @@ type ConfigJson struct { ...@@ -22,6 +22,11 @@ type ConfigJson struct {
GenerateAccCount int `json:"generateAccCount"` GenerateAccCount int `json:"generateAccCount"`
IsDeployContract bool `json:"isDeployContract"` IsDeployContract bool `json:"isDeployContract"`
IsInitAccountBalance bool `json:"isInitAccountBalance"` IsInitAccountBalance bool `json:"isInitAccountBalance"`
IsInitAccCoin bool `json:"isInitAccCoin"`
IsInitContractCoin bool `json:"isInitContractCoin"`
IsInitErc20 bool `json:"isInitErc20"`
IsInitErc721Mint bool `json:"isInitErc721Mint"`
IsInitErc721 bool `json:"isInitErc721"`
} }
type Config struct { type Config struct {
...@@ -33,6 +38,11 @@ type Config struct { ...@@ -33,6 +38,11 @@ type Config struct {
GenerateAccCount int GenerateAccCount int
IsDeployContract bool IsDeployContract bool
IsInitAccountBalance bool IsInitAccountBalance bool
IsInitAccCoin bool
IsInitContractCoin bool
IsInitErc20 bool
IsInitErc721Mint bool
IsInitErc721 bool
ContractMap []map[string]common.Address ContractMap []map[string]common.Address
} }
...@@ -92,6 +102,11 @@ func ParseConfig(path string) { ...@@ -92,6 +102,11 @@ func ParseConfig(path string) {
GenerateAccCount: cfgJson.GenerateAccCount, GenerateAccCount: cfgJson.GenerateAccCount,
IsDeployContract: cfgJson.IsDeployContract, IsDeployContract: cfgJson.IsDeployContract,
IsInitAccountBalance: cfgJson.IsInitAccountBalance, IsInitAccountBalance: cfgJson.IsInitAccountBalance,
IsInitAccCoin: cfgJson.IsInitAccCoin,
IsInitContractCoin: cfgJson.IsInitContractCoin,
IsInitErc20: cfgJson.IsInitErc20,
IsInitErc721Mint: cfgJson.IsInitErc721Mint,
IsInitErc721: cfgJson.IsInitErc721,
ContractMap: ParseContractConfig("./config/contractConfig.json"), ContractMap: ParseContractConfig("./config/contractConfig.json"),
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment