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
75478c00
Commit
75478c00
authored
Jun 01, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case
parent
48656f35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
operator.go
operator/operator.go
+7
-0
partlyRelatedCase.go
operator/partlyRelatedCase.go
+74
-0
No files found.
operator/operator.go
View file @
75478c00
...
@@ -163,6 +163,8 @@ func InitErc721AccMint(txArr []*types.Transaction, nonce uint64, contractLen int
...
@@ -163,6 +163,8 @@ func InitErc721AccMint(txArr []*types.Transaction, nonce uint64, contractLen int
for
i
:=
0
;
i
<
len
(
accArr
.
FromAddr
);
i
++
{
for
i
:=
0
;
i
<
len
(
accArr
.
FromAddr
);
i
++
{
tokenIds
=
append
(
tokenIds
,
big
.
NewInt
(
int64
(
i
)))
tokenIds
=
append
(
tokenIds
,
big
.
NewInt
(
int64
(
i
)))
}
}
auth
.
GasLimit
=
10000000
auth
.
GasPrice
=
big
.
NewInt
(
10000000
)
auth
.
Nonce
=
big
.
NewInt
(
int64
(
nonce
))
auth
.
Nonce
=
big
.
NewInt
(
int64
(
nonce
))
of
,
err
:=
newERC721
.
BalanceOf
(
&
bind
.
CallOpts
{},
tool
.
Cfg
.
DeployAddr
)
of
,
err
:=
newERC721
.
BalanceOf
(
&
bind
.
CallOpts
{},
tool
.
Cfg
.
DeployAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -462,6 +464,11 @@ func GetTranFunc(caseType int, startIndex int, txCount int, nonceMap *sync.Map,
...
@@ -462,6 +464,11 @@ func GetTranFunc(caseType int, startIndex int, txCount int, nonceMap *sync.Map,
{
{
return
PrReOneErc20TranCase
(
txCount
,
arr
,
contractArr
[
3
],
nonceMap
,
txArr
,
client
)
return
PrReOneErc20TranCase
(
txCount
,
arr
,
contractArr
[
3
],
nonceMap
,
txArr
,
client
)
}
}
// 部分相关-多层-erc20-transferFrom-发送者相关
case
30
:
{
return
PrReOneErc20TranCase1
(
txCount
,
arr
,
contractArr
[
6
],
nonceMap
,
txArr
,
client
)
}
// Erc20 approve
// Erc20 approve
case
26
:
case
26
:
{
{
...
...
operator/partlyRelatedCase.go
View file @
75478c00
...
@@ -1120,6 +1120,80 @@ func PrReOneErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMa
...
@@ -1120,6 +1120,80 @@ func PrReOneErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMa
return
resTxArr
,
verify
return
resTxArr
,
verify
}
}
// PrReOneErc20TranCase1 多层-erc20-transferFrom-接受者相关
func
PrReOneErc20TranCase1
(
txCount
int
,
testAccArr
*
tool
.
AccArrFormat
,
contractMap
map
[
string
]
common
.
Address
,
accountNonceMap
*
sync
.
Map
,
resTxArr
[]
*
types
.
Transaction
,
client
*
ethclient
.
Client
)
([]
*
types
.
Transaction
,
func
()
bool
)
{
amount
:=
big
.
NewInt
(
1000000000000
)
oneErc20Trade
:=
&
contractErc20
.
OneErc20Trade
{
TokenTransferAddr
:
contractMap
[
constant
.
TOKEN20_TRANSFER
],
Erc20Addr
:
contractMap
[
constant
.
ERC20
],
Amount
:
amount
,
}
tokenTransfer
,
err
:=
erc20
.
NewOneTokenTransfer
(
contractMap
[
constant
.
ONE_TOKEN20_TRANSFER
],
client
)
if
err
!=
nil
{
return
nil
,
nil
}
erc20Contract
,
err
:=
erc20
.
NewERC20
(
contractMap
[
constant
.
ERC20
],
client
)
if
err
!=
nil
{
log
.
Error
(
"NewTokenTransfer error:"
,
err
.
Error
())
return
nil
,
nil
}
beforeAddrErc20Bal
:=
make
(
map
[
common
.
Address
]
*
big
.
Int
,
0
)
toAddr
:=
testAccArr
.
ToAddr
[
0
]
toBal
,
err
:=
erc20Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
toAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc20 balanceOf error:"
,
err
.
Error
())
return
nil
,
nil
}
beforeAddrErc20Bal
[
toAddr
]
=
toBal
for
i
:=
0
;
i
<
txCount
;
i
++
{
fromBal
,
err
:=
erc20Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
testAccArr
.
FromAddr
[
i
])
if
err
!=
nil
{
log
.
Error
(
"Get erc20 balanceOf error:"
,
err
.
Error
())
return
nil
,
nil
}
beforeAddrErc20Bal
[
testAccArr
.
FromAddr
[
i
]]
=
fromBal
oneErc20Trade
.
ToAddr
=
[]
common
.
Address
{
testAccArr
.
ToAddr
[
i
]}
auth
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
testAccArr
.
FromPrv
[
i
],
tool
.
Cfg
.
ChainId
)
if
err
!=
nil
{
log
.
Errorf
(
"DeployTokenTransfer func newKeyedTransactorWithChainID err:"
,
err
)
}
value
,
_
:=
accountNonceMap
.
Load
(
testAccArr
.
FromAddr
[
i
])
auth
.
Nonce
=
big
.
NewInt
(
value
.
(
int64
))
auth
.
NoSend
=
true
auth
.
GasLimit
=
500000
auth
.
GasPrice
=
big
.
NewInt
(
10000000000
)
tx
,
err
:=
oneErc20Trade
.
Erc20OneTransferTx
(
auth
,
tokenTransfer
)
if
err
!=
nil
{
return
nil
,
nil
}
log
.
Info
(
"Erc20OneTransferTx tx:"
,
tx
.
Hash
()
.
Hex
())
resTxArr
=
append
(
resTxArr
,
tx
)
}
verify
:=
func
()
bool
{
res
:=
true
to
,
err
:=
erc20Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
toAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc20 balanceOf error:"
,
err
.
Error
())
res
=
false
}
if
to
.
Sub
(
to
,
beforeAddrErc20Bal
[
toAddr
])
.
Cmp
(
new
(
big
.
Int
)
.
Mul
(
big
.
NewInt
(
int64
(
txCount
)),
amount
))
!=
0
{
res
=
false
}
for
i
:=
0
;
i
<
txCount
;
i
++
{
from
,
err
:=
erc20Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
testAccArr
.
FromAddr
[
i
])
if
err
!=
nil
{
log
.
Error
(
"Get erc20 balanceOf error:"
,
err
.
Error
())
res
=
false
}
if
beforeAddrErc20Bal
[
testAccArr
.
FromAddr
[
i
]]
.
Sub
(
beforeAddrErc20Bal
[
testAccArr
.
FromAddr
[
i
]],
from
)
.
Cmp
(
amount
)
!=
1
{
res
=
false
}
}
return
res
}
return
resTxArr
,
verify
}
// PrSpErc20ApproveTranCase 单层-erc20-approve
// PrSpErc20ApproveTranCase 单层-erc20-approve
func
PrSpErc20ApproveTranCase
(
txCount
int
,
testAccArr
*
tool
.
AccArrFormat
,
contractMap
map
[
string
]
common
.
Address
,
accountNonceMap
*
sync
.
Map
,
resTxArr
[]
*
types
.
Transaction
,
client
*
ethclient
.
Client
)
([]
*
types
.
Transaction
,
func
()
bool
)
{
func
PrSpErc20ApproveTranCase
(
txCount
int
,
testAccArr
*
tool
.
AccArrFormat
,
contractMap
map
[
string
]
common
.
Address
,
accountNonceMap
*
sync
.
Map
,
resTxArr
[]
*
types
.
Transaction
,
client
*
ethclient
.
Client
)
([]
*
types
.
Transaction
,
func
()
bool
)
{
amount
:=
big
.
NewInt
(
0
)
amount
:=
big
.
NewInt
(
0
)
...
...
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