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
1f5500ea
Commit
1f5500ea
authored
May 24, 2019
by
linj
Committed by
vipwzw
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tokenExec.Query_GetAccountTokenAssets
add test tokenExec.Query_GetAccountTokenAssets
parent
f2394f30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
token.go
plugin/dapp/token/executor/token.go
+4
-4
token_test.go
plugin/dapp/token/executor/token_test.go
+33
-6
No files found.
plugin/dapp/token/executor/token.go
View file @
1f5500ea
...
...
@@ -108,11 +108,11 @@ func (t *token) getAccountTokenAssets(req *tokenty.ReqAccountTokenAssets) (types
return
nil
,
err
}
var
acc1
*
types
.
Account
if
req
.
Execer
!=
""
{
execaddress
:=
address
.
ExecAddress
(
req
.
Execer
)
acc1
=
acc
.
LoadExecAccount
(
req
.
Address
,
execaddress
)
}
else
if
req
.
Execer
==
t
.
GetName
()
{
if
req
.
Execer
==
t
.
GetName
()
{
acc1
=
acc
.
LoadAccount
(
req
.
Address
)
}
else
if
req
.
Execer
!=
""
{
execAddress
:=
address
.
ExecAddress
(
req
.
Execer
)
acc1
=
acc
.
LoadExecAccount
(
req
.
Address
,
execAddress
)
}
if
acc1
==
nil
{
continue
...
...
plugin/dapp/token/executor/token_test.go
View file @
1f5500ea
...
...
@@ -152,6 +152,9 @@ func TestToken(t *testing.T) {
set
,
err
:=
exec
.
ExecLocal
(
createTx
,
receiptDate
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
p2
:=
&
pty
.
TokenFinishCreate
{
Symbol
:
Symbol
,
...
...
@@ -176,13 +179,16 @@ func TestToken(t *testing.T) {
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
accDB
,
_
:=
account
.
NewAccountDB
(
pty
.
TokenX
,
Symbol
,
stateDB
)
accCh
ce
k
:=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
,
accCh
ce
k
.
Balance
)
accCh
ec
k
:=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
,
accCh
ec
k
.
Balance
)
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx2
,
receiptDate
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// mint burn
p3
:=
&
pty
.
TokenMint
{
...
...
@@ -208,13 +214,16 @@ func TestToken(t *testing.T) {
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
accCh
ce
k
=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
+
tokenMint
,
accCh
ce
k
.
Balance
)
accCh
ec
k
=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
+
tokenMint
,
accCh
ec
k
.
Balance
)
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx3
,
receiptDate
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
p4
:=
&
pty
.
TokenBurn
{
Symbol
:
Symbol
,
...
...
@@ -238,13 +247,31 @@ func TestToken(t *testing.T) {
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
accCh
ce
k
=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
+
tokenMint
-
tokenBurn
,
accCh
ce
k
.
Balance
)
accCh
ec
k
=
accDB
.
LoadAccount
(
string
(
Nodes
[
0
]))
assert
.
Equal
(
t
,
tokenTotal
+
tokenMint
-
tokenBurn
,
accCh
ec
k
.
Balance
)
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx4
,
receiptDate
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
tokenExec
,
ok
:=
exec
.
(
*
token
)
assert
.
True
(
t
,
ok
)
in
:=
pty
.
ReqAccountTokenAssets
{
Address
:
string
(
Nodes
[
0
]),
Execer
:
pty
.
TokenX
,
}
out
,
err
:=
tokenExec
.
Query_GetAccountTokenAssets
(
&
in
)
assert
.
Nil
(
t
,
err
)
reply
:=
out
.
(
*
pty
.
ReplyAccountTokenAssets
)
assert
.
Equal
(
t
,
1
,
len
(
reply
.
TokenAssets
))
assert
.
NotEqual
(
t
,
0
,
reply
.
TokenAssets
[
0
]
.
Account
.
Balance
)
assert
.
Equal
(
t
,
string
(
Nodes
[
0
]),
reply
.
TokenAssets
[
0
]
.
Account
.
Addr
)
t
.
Log
(
reply
.
TokenAssets
)
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
...
...
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