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
625cf528
Commit
625cf528
authored
Jan 11, 2019
by
linj
Committed by
vipwzw
Jan 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test ; fmt
parent
049a8db4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
token_new_test.go
plugin/dapp/token/executor/token_new_test.go
+36
-0
tokendb.go
plugin/dapp/token/executor/tokendb.go
+1
-1
No files found.
plugin/dapp/token/executor/token_new_test.go
View file @
625cf528
...
...
@@ -19,6 +19,7 @@ import (
cty
"github.com/33cn/chain33/system/dapp/coins/types"
"github.com/33cn/chain33/types"
tokenty
"github.com/33cn/plugin/plugin/dapp/token/types"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
)
...
...
@@ -382,3 +383,38 @@ func getprivkey(key string) crypto.PrivKey {
}
return
priv
}
func
TestToken_validSymbolWithHeight
(
t
*
testing
.
T
)
{
types
.
SetTitleOnlyForTest
(
"chain33"
)
forkBadTokenSymbol
:=
types
.
GetDappFork
(
tokenty
.
TokenX
,
"ForkBadTokenSymbol"
)
forkTokenSymbolWithNumber
:=
types
.
GetDappFork
(
tokenty
.
TokenX
,
"ForkTokenSymbolWithNumber"
)
t
.
Log
(
"x"
,
"1"
,
forkBadTokenSymbol
,
"2"
,
forkTokenSymbolWithNumber
)
assert
.
Equal
(
t
,
true
,
(
forkTokenSymbolWithNumber
>=
forkBadTokenSymbol
))
cases
:=
[]
struct
{
symbol
[]
byte
height
int64
expect
bool
}{
{[]
byte
(
"x"
),
int64
(
forkBadTokenSymbol
-
1
),
false
},
{[]
byte
(
"X林"
),
int64
(
forkBadTokenSymbol
-
1
),
true
},
{[]
byte
(
"x"
),
int64
(
forkBadTokenSymbol
),
false
},
{[]
byte
(
"X林"
),
int64
(
forkBadTokenSymbol
),
false
},
{[]
byte
(
"x"
),
int64
(
forkTokenSymbolWithNumber
-
1
),
false
},
{[]
byte
(
"X林"
),
int64
(
forkTokenSymbolWithNumber
-
1
),
false
},
{[]
byte
(
"X1"
),
int64
(
forkTokenSymbolWithNumber
-
1
),
false
},
{[]
byte
(
"x"
),
int64
(
forkTokenSymbolWithNumber
),
false
},
{[]
byte
(
"X林"
),
int64
(
forkTokenSymbolWithNumber
),
false
},
{[]
byte
(
"X1"
),
int64
(
forkTokenSymbolWithNumber
),
true
},
}
for
_
,
c
:=
range
cases
{
c
:=
c
t
.
Run
(
"validSymbol"
,
func
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
c
.
expect
,
validSymbolWithHeight
(
c
.
symbol
,
c
.
height
))
})
}
}
plugin/dapp/token/executor/tokendb.go
View file @
625cf528
...
...
@@ -438,7 +438,7 @@ func validSymbolForkBadTokenSymbol(cs []byte) bool {
}
func
validSymbolForkTokenSymbolWithNumber
(
cs
[]
byte
)
bool
{
for
_
,
c
:=
range
cs
{
for
_
,
c
:=
range
cs
{
if
!
isUpperChar
(
c
)
&&
!
isDigit
(
c
)
{
return
false
}
...
...
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