Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
contract-case
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanjinfei
contract-case
Commits
50522bc1
Commit
50522bc1
authored
Apr 25, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add init console falg
parent
58fdecea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
23 deletions
+54
-23
app.json
config/app.json
+7
-2
operator.go
operator/operator.go
+32
-21
Config.go
tool/Config.go
+15
-0
No files found.
config/app.json
View file @
50522bc1
...
...
@@ -10,10 +10,15 @@
"goRoutine"
:
1
,
"generateAccCount"
:
500
,
"isDeployContract"
:
false
,
"isInitAccountBalance"
:
true
,
"isInitAccountBalance"
:
false
,
"isInitAccCoin"
:
true
,
"isInitContractCoin"
:
true
,
"isInitErc20"
:
true
,
"isInitErc721Mint"
:
true
,
"isInitErc721"
:
true
,
"startTokenId"
:
1
,
"endTokenId"
:
100
,
"transferType"
:
[]
"transferType"
:
[
1
,
2
,
3
,
4
,
5
,
6
,
7
]
}
...
...
operator/operator.go
View file @
50522bc1
...
...
@@ -285,30 +285,41 @@ func InitCaseAccount(client *ethclient.Client, txArr []*types.Transaction) []*ty
auth
.
NoSend
=
true
amount
:=
big
.
NewInt
(
0
)
amount
.
SetString
(
"10000000000000000000"
,
10
)
//
trade := &coin.Trade{
//
FromPrv: tool.Cfg.DeployPrv,
//
FromNonce: big.NewInt(int64(nonce)),
//
Amount: amount,
//
Gas: big.NewInt(50000),
//
GasPrice: big.NewInt(1000000000),
//
ChainId: tool.Cfg.ChainId,
//
}
trade
:=
&
coin
.
Trade
{
FromPrv
:
tool
.
Cfg
.
DeployPrv
,
FromNonce
:
big
.
NewInt
(
int64
(
nonce
)),
Amount
:
amount
,
Gas
:
big
.
NewInt
(
50000
),
GasPrice
:
big
.
NewInt
(
1000000000
),
ChainId
:
tool
.
Cfg
.
ChainId
,
}
contractMap
:=
tool
.
ParseContractConfig
(
"./config/contractConfig.json"
)
contractLen
:=
len
(
contractMap
)
tempTxArr
:=
make
([]
*
types
.
Transaction
,
0
)
//初始化From账户-500tx
//coinTxArr, nonce := InitAccountCoin(txArr, nonce, amount, accArr)
//txArr = append(txArr, coinTxArr...)
if
tool
.
Cfg
.
IsInitAccCoin
{
tempTxArr
,
nonce
=
InitAccountCoin
(
txArr
,
nonce
,
amount
,
accArr
)
txArr
=
append
(
txArr
,
tempTxArr
...
)
}
//初始化转账合约账户余额-10tx
//contractCoinTxArr, nonce := InitContractCoin(txArr, nonce, contractLen, contractMap, trade)
//txArr = append(txArr, contractCoinTxArr...)
//// 初始化erc20 并且mint
erc20TxArr
,
nonce
:=
InitErc20Acc
(
txArr
,
nonce
,
contractLen
,
contractMap
,
accArr
,
client
,
auth
)
txArr
=
append
(
txArr
,
erc20TxArr
...
)
////初始化erc721 并且mint
//erc721MintTxArr, nonce := InitErc721AccMint(txArr, nonce, contractLen, contractMap, accArr, client, auth)
//txArr = append(txArr, erc721MintTxArr...)
//erc721TransferTxArr, nonce := InitErc721AccTransfer(txArr, nonce, contractLen, contractMap, accArr, client, auth)
//txArr = append(txArr, erc721TransferTxArr...)
if
tool
.
Cfg
.
IsInitContractCoin
{
tempTxArr
,
nonce
=
InitContractCoin
(
txArr
,
nonce
,
contractLen
,
contractMap
,
trade
)
txArr
=
append
(
txArr
,
tempTxArr
...
)
}
// 初始化erc20 并且mint
if
tool
.
Cfg
.
IsInitErc20
{
tempTxArr
,
nonce
=
InitErc20Acc
(
txArr
,
nonce
,
contractLen
,
contractMap
,
accArr
,
client
,
auth
)
txArr
=
append
(
txArr
,
tempTxArr
...
)
}
//初始化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..........."
)
return
txArr
}
...
...
@@ -492,7 +503,7 @@ func SendTransaction(trans []*types.Transaction) {
tran
:=
trans
[
i
]
//tranChanel <- 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
{
log
.
Error
(
"send tx error:"
,
err
.
Error
(),
",tx:"
,
tran
.
Hash
()
.
Hex
())
return
...
...
tool/Config.go
View file @
50522bc1
...
...
@@ -22,6 +22,11 @@ type ConfigJson struct {
GenerateAccCount
int
`json:"generateAccCount"`
IsDeployContract
bool
`json:"isDeployContract"`
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
{
...
...
@@ -33,6 +38,11 @@ type Config struct {
GenerateAccCount
int
IsDeployContract
bool
IsInitAccountBalance
bool
IsInitAccCoin
bool
IsInitContractCoin
bool
IsInitErc20
bool
IsInitErc721Mint
bool
IsInitErc721
bool
ContractMap
[]
map
[
string
]
common
.
Address
}
...
...
@@ -92,6 +102,11 @@ func ParseConfig(path string) {
GenerateAccCount
:
cfgJson
.
GenerateAccCount
,
IsDeployContract
:
cfgJson
.
IsDeployContract
,
IsInitAccountBalance
:
cfgJson
.
IsInitAccountBalance
,
IsInitAccCoin
:
cfgJson
.
IsInitAccCoin
,
IsInitContractCoin
:
cfgJson
.
IsInitContractCoin
,
IsInitErc20
:
cfgJson
.
IsInitErc20
,
IsInitErc721Mint
:
cfgJson
.
IsInitErc721Mint
,
IsInitErc721
:
cfgJson
.
IsInitErc721
,
ContractMap
:
ParseContractConfig
(
"./config/contractConfig.json"
),
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment