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
ec9fa4b1
Commit
ec9fa4b1
authored
May 24, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add erc721 test case
parent
a47658e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
partlyRelatedCase.go
operator/partlyRelatedCase.go
+82
-0
No files found.
operator/partlyRelatedCase.go
View file @
ec9fa4b1
...
@@ -1252,6 +1252,88 @@ func PrReErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrForm
...
@@ -1252,6 +1252,88 @@ func PrReErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrForm
return
resTxArr
,
verify
return
resTxArr
,
verify
}
}
// PrReErc721TranFromCase erc721-发送者相关
func
PrReErc721TranFromCase
(
startIndex
int
,
txCount
int
,
testAccArr
*
tool
.
AccArrFormat
,
contractMap
map
[
string
]
common
.
Address
,
accountNonceMap
*
sync
.
Map
,
resTxArr
[]
*
types
.
Transaction
,
client
*
ethclient
.
Client
)
([]
*
types
.
Transaction
,
func
()
bool
)
{
erc721Trade
:=
&
contractErc721
.
Erc721Trade
{
Erc721Addr
:
contractMap
[
constant
.
ERC721
],
}
erc721Contract
,
err
:=
erc721
.
NewERC721
(
contractMap
[
constant
.
ERC721
],
client
)
if
err
!=
nil
{
return
nil
,
nil
}
tokenTransfer
,
err
:=
erc721
.
NewNftTokenTransfer
(
contractMap
[
constant
.
TOKEN721_TRANSFER
],
client
)
if
err
!=
nil
{
return
nil
,
nil
}
beforeToErc721Bal
:=
make
(
map
[
common
.
Address
]
*
big
.
Int
,
0
)
fromAddr
:=
testAccArr
.
ToAddr
[
0
]
beforeFromErc721Bal
,
err
:=
erc721Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
fromAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc721 bal error:"
,
err
.
Error
())
return
nil
,
nil
}
log
.
Info
(
"Erc721 接受者相关 From balance:"
,
beforeFromErc721Bal
.
String
())
auth
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
testAccArr
.
ToPrv
[
0
],
tool
.
Cfg
.
ChainId
)
if
err
!=
nil
{
log
.
Errorf
(
"DeployTokenTransfer func newKeyedTransactorWithChainID err:"
,
err
)
}
value
,
_
:=
accountNonceMap
.
Load
(
fromAddr
)
nonce
:=
value
.
(
int64
)
auth
.
Nonce
=
big
.
NewInt
(
nonce
)
for
i
:=
0
;
i
<
txCount
;
i
++
{
toAddr
:=
testAccArr
.
FromAddr
[
i
]
erc721Trade
.
ToAddr
=
toAddr
toErc721Bal
,
err
:=
erc721Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
toAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc721 bal error:"
,
err
.
Error
())
return
nil
,
nil
}
log
.
Info
(
"Erc721 接受者相关 to balance:"
,
toErc721Bal
.
String
())
beforeToErc721Bal
[
toAddr
]
=
toErc721Bal
erc721Trade
.
FromAddr
=
fromAddr
erc721Trade
.
TokenId
=
big
.
NewInt
(
int64
(
startIndex
))
auth
.
NoSend
=
true
auth
.
GasLimit
=
500000
auth
.
GasPrice
=
big
.
NewInt
(
10000000000
)
tx
,
err
:=
erc721Trade
.
Erc721TransferFromSignTx
(
auth
,
tokenTransfer
)
if
err
!=
nil
{
log
.
Error
(
"Erc721TransferFromSignTx error:"
,
err
.
Error
())
return
nil
,
nil
}
log
.
Info
(
"Erc721TransferFromSignTx tx:"
,
tx
.
Hash
()
.
Hex
())
nonce
++
startIndex
++
resTxArr
=
append
(
resTxArr
,
tx
)
}
verify
:=
func
()
bool
{
res
:=
true
verifyToAddr
:=
testAccArr
.
ToAddr
[
0
]
fromErc721Bal
,
err
:=
erc721Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
verifyToAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc721 bal error:"
,
err
.
Error
())
res
=
false
}
log
.
Info
(
"Erc721 接受者相关 From balance:"
,
fromErc721Bal
.
String
())
if
beforeFromErc721Bal
.
Sub
(
beforeFromErc721Bal
,
fromErc721Bal
)
.
Cmp
(
big
.
NewInt
(
int64
(
txCount
)))
!=
0
{
res
=
false
}
for
i
:=
0
;
i
<
txCount
;
i
++
{
receiveToAddr
:=
testAccArr
.
FromAddr
[
i
]
toErc721Bal
,
err
:=
erc721Contract
.
BalanceOf
(
&
bind
.
CallOpts
{},
receiveToAddr
)
if
err
!=
nil
{
log
.
Error
(
"Get erc721 bal error:"
,
err
.
Error
())
res
=
false
}
log
.
Info
(
"Erc721 接受者相关 To balance:"
,
toErc721Bal
.
String
())
if
toErc721Bal
.
Sub
(
toErc721Bal
,
beforeToErc721Bal
[
receiveToAddr
])
.
Cmp
(
big
.
NewInt
(
1
))
!=
0
{
res
=
false
}
}
return
res
}
return
resTxArr
,
verify
}
// PrReContractOneCoinTranTwiceCase 多层-合约转账- 先set合约的对象地址-〉调用合约的方法 :两笔交易并行发送,同一个块中执行
// PrReContractOneCoinTranTwiceCase 多层-合约转账- 先set合约的对象地址-〉调用合约的方法 :两笔交易并行发送,同一个块中执行
func
PrReContractOneCoinTranTwiceCase
(
txCount
int
,
testAccArr
*
tool
.
AccArrFormat
,
contractMap
[]
map
[
string
]
common
.
Address
,
accountNonceMap
*
sync
.
Map
,
resTxArr
[]
*
types
.
Transaction
,
client
*
ethclient
.
Client
)
([]
*
types
.
Transaction
,
func
()
bool
)
{
func
PrReContractOneCoinTranTwiceCase
(
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
(
100000000000000000
)
amount
:=
big
.
NewInt
(
100000000000000000
)
...
...
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