Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
link33
plugin
Commits
c47322b3
Commit
c47322b3
authored
Mar 11, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add auto test for burn mint
parent
3cc1f310
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
0 deletions
+106
-0
token.go
plugin/dapp/token/autotest/token.go
+1
-0
token.toml
plugin/dapp/token/autotest/token.toml
+9
-0
tokenCase.go
plugin/dapp/token/autotest/tokenCase.go
+96
-0
No files found.
plugin/dapp/token/autotest/token.go
View file @
c47322b3
...
@@ -19,6 +19,7 @@ type tokenAutoTest struct {
...
@@ -19,6 +19,7 @@ type tokenAutoTest struct {
WithdrawCaseArr
[]
autotest
.
WithdrawCase
`toml:"WithdrawCase,omitempty"`
WithdrawCaseArr
[]
autotest
.
WithdrawCase
`toml:"WithdrawCase,omitempty"`
TokenRevokeCaseArr
[]
TokenRevokeCase
`toml:"TokenRevokeCase,omitempty"`
TokenRevokeCaseArr
[]
TokenRevokeCase
`toml:"TokenRevokeCase,omitempty"`
TokenMintCaseArr
[]
TokenMintCase
`toml:"TokenMintCase,omitempty"`
TokenMintCaseArr
[]
TokenMintCase
`toml:"TokenMintCase,omitempty"`
TokenBurnCaseArr
[]
TokenBurnCase
`toml:"TokenBurnCase,omitempty"`
}
}
func
init
()
{
func
init
()
{
...
...
plugin/dapp/token/autotest/token.toml
View file @
c47322b3
...
@@ -25,6 +25,15 @@ dep = ["tokenPre"]
...
@@ -25,6 +25,15 @@ dep = ["tokenPre"]
id
=
"tokenMint"
id
=
"tokenMint"
command
=
"send token mint -a 100 -s TC -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
command
=
"send token mint -a 100 -s TC -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep
=
["tokenFinish"]
dep
=
["tokenFinish"]
amount
=
"100"
checkItem
=
["balance"]
[[TokenBurnCase]]
id
=
"tokenBurn"
command
=
"send token burn -a 50 -s TC -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep
=
["tokenMint"]
amount
=
"50"
checkItem
=
["balance"]
#send to token for precreate
#send to token for precreate
[[TransferCase]]
[[TransferCase]]
...
...
plugin/dapp/token/autotest/tokenCase.go
View file @
c47322b3
...
@@ -6,6 +6,8 @@ package autotest
...
@@ -6,6 +6,8 @@ package autotest
import
(
import
(
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
)
// TokenPreCreateCase token precreatecase command
// TokenPreCreateCase token precreatecase command
...
@@ -63,6 +65,8 @@ func (testCase *TokenFinishCreateCase) SendCommand(packID string) (types.PackFun
...
@@ -63,6 +65,8 @@ func (testCase *TokenFinishCreateCase) SendCommand(packID string) (types.PackFun
// TokenMintCase token mint case
// TokenMintCase token mint case
type
TokenMintCase
struct
{
type
TokenMintCase
struct
{
types
.
BaseCase
types
.
BaseCase
Amount
string
`toml:"amount"`
}
}
// TokenMintPack token mint pack command
// TokenMintPack token mint pack command
...
@@ -75,3 +79,95 @@ func (testCase *TokenMintCase) SendCommand(packID string) (types.PackFunc, error
...
@@ -75,3 +79,95 @@ func (testCase *TokenMintCase) SendCommand(packID string) (types.PackFunc, error
return
types
.
DefaultSend
(
testCase
,
&
TokenMintPack
{},
packID
)
return
types
.
DefaultSend
(
testCase
,
&
TokenMintPack
{},
packID
)
}
}
// GetCheckHandlerMap get check handle for map
func
(
pack
*
TokenMintPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
}
func
(
pack
*
TokenMintPack
)
checkBalance
(
txInfo
map
[
string
]
interface
{})
bool
{
logArr
:=
txInfo
[
"receipt"
]
.
(
map
[
string
]
interface
{})[
"logs"
]
.
([]
interface
{})
logTokenBurn
:=
logArr
[
1
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
logAccBurn
:=
logArr
[
2
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
interCase
:=
pack
.
TCase
.
(
*
TokenMintCase
)
amount1
,
_
:=
strconv
.
ParseInt
(
interCase
.
Amount
,
10
,
64
)
amount
:=
amount1
*
1e8
pack
.
FLog
.
Info
(
"MintDetails"
,
"TestID"
,
pack
.
PackID
,
"TokenPrev"
,
logTokenBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"total"
]
.
(
string
),
"TokenCurr"
,
logTokenBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"total"
]
.
(
string
),
"AccPrev"
,
logAccBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"AccCurr"
,
logAccBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"amount"
,
amount1
)
totalCurrent
:=
parseInt64
(
logTokenBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"total"
])
totalPrev
:=
parseInt64
(
logTokenBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"total"
])
accCurrent
:=
parseInt64
(
logAccBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
])
accPrev
:=
parseInt64
(
logAccBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
])
return
totalCurrent
-
amount
==
totalPrev
&&
accCurrent
-
amount
==
accPrev
}
// TokenBurnCase token mint case
type
TokenBurnCase
struct
{
types
.
BaseCase
Amount
string
`toml:"amount"`
}
// TokenBurnPack token mint pack command
type
TokenBurnPack
struct
{
types
.
BaseCasePack
}
// SendCommand send command function
func
(
testCase
*
TokenBurnCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
testCase
,
&
TokenBurnPack
{},
packID
)
}
// GetCheckHandlerMap get check handle for map
func
(
pack
*
TokenBurnPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
}
func
(
pack
*
TokenBurnPack
)
checkBalance
(
txInfo
map
[
string
]
interface
{})
bool
{
logArr
:=
txInfo
[
"receipt"
]
.
(
map
[
string
]
interface
{})[
"logs"
]
.
([]
interface
{})
logTokenBurn
:=
logArr
[
1
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
logAccBurn
:=
logArr
[
2
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
interCase
:=
pack
.
TCase
.
(
*
TokenBurnCase
)
amount1
,
_
:=
strconv
.
ParseInt
(
interCase
.
Amount
,
10
,
64
)
amount
:=
amount1
*
1e8
pack
.
FLog
.
Info
(
"BurnDetails"
,
"TestID"
,
pack
.
PackID
,
"TokenPrev"
,
logTokenBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"total"
]
.
(
string
),
"TokenCurr"
,
logTokenBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"total"
]
.
(
string
),
"AccPrev"
,
logAccBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"AccCurr"
,
logAccBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"amount"
,
amount1
)
totalCurrent
:=
parseInt64
(
logTokenBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"total"
])
totalPrev
:=
parseInt64
(
logTokenBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"total"
])
accCurrent
:=
parseInt64
(
logAccBurn
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
])
accPrev
:=
parseInt64
(
logAccBurn
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
])
return
totalCurrent
+
amount
==
totalPrev
&&
accCurrent
+
amount
==
accPrev
}
func
parseInt64
(
s
interface
{})
int64
{
i
,
_
:=
strconv
.
ParseInt
(
s
.
(
string
),
10
,
64
)
return
i
}
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