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
adc9354e
Commit
adc9354e
authored
Nov 28, 2018
by
郝东博
Committed by
vipwzw
Nov 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix golint warning
parent
87d3a21b
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
114 additions
and
107 deletions
+114
-107
golinter.sh
golinter.sh
+1
-0
init.go
plugin/consensus/init/init.go
+5
-5
evidence.go
plugin/consensus/tendermint/types/evidence.go
+1
-1
init.go
plugin/crypto/init/init.go
+2
-2
evm.go
plugin/dapp/evm/executor/evm.go
+1
-1
hashlock.go
plugin/dapp/hashlock/types/hashlock.go
+2
-2
init.go
plugin/dapp/init/init.go
+16
-16
pokerbulldb.go
plugin/dapp/pokerbull/executor/pokerbulldb.go
+1
-1
plugin.go
plugin/dapp/privacy/plugin.go
+3
-3
errors.go
plugin/dapp/privacy/types/errors.go
+1
-1
token.go
plugin/dapp/token/autotest/token.go
+7
-6
tokenCase.go
plugin/dapp/token/autotest/tokenCase.go
+24
-22
plugin.go
plugin/dapp/token/plugin.go
+1
-1
buyCase.go
plugin/dapp/trade/autotest/buyCase.go
+19
-18
sellCase.go
plugin/dapp/trade/autotest/sellCase.go
+16
-15
trade.go
plugin/dapp/trade/autotest/trade.go
+9
-8
plugin.go
plugin/dapp/trade/plugin.go
+1
-1
init.go
plugin/init.go
+1
-1
init.go
plugin/store/init/init.go
+3
-3
No files found.
golinter.sh
View file @
adc9354e
...
@@ -16,6 +16,7 @@ function filterLinter() {
...
@@ -16,6 +16,7 @@ function filterLinter() {
--enable
=
structcheck
\
--enable
=
structcheck
\
--enable
=
goimports
\
--enable
=
goimports
\
--enable
=
misspell
\
--enable
=
misspell
\
--enable
=
golint
\
--vendor
./...
)
--vendor
./...
)
# --enable=staticcheck \
# --enable=staticcheck \
# --enable=gocyclo \
# --enable=gocyclo \
...
...
plugin/consensus/init/init.go
View file @
adc9354e
package
init
package
init
import
(
import
(
_
"github.com/33cn/plugin/plugin/consensus/para"
_
"github.com/33cn/plugin/plugin/consensus/para"
// register para package
_
"github.com/33cn/plugin/plugin/consensus/pbft"
_
"github.com/33cn/plugin/plugin/consensus/pbft"
// register pbft package
_
"github.com/33cn/plugin/plugin/consensus/raft"
_
"github.com/33cn/plugin/plugin/consensus/raft"
// register raft package
_
"github.com/33cn/plugin/plugin/consensus/tendermint"
_
"github.com/33cn/plugin/plugin/consensus/tendermint"
// register tendermint package
_
"github.com/33cn/plugin/plugin/consensus/ticket"
_
"github.com/33cn/plugin/plugin/consensus/ticket"
// register ticket package
)
)
plugin/consensus/tendermint/types/evidence.go
View file @
adc9354e
...
@@ -165,7 +165,7 @@ func (dve *DuplicateVoteEvidence) Verify(chainID string) error {
...
@@ -165,7 +165,7 @@ func (dve *DuplicateVoteEvidence) Verify(chainID string) error {
}
}
// BlockIDs must be different
// BlockIDs must be different
if
blockIDA
.
Equals
(
blockIDB
)
{
if
blockIDA
.
Equals
(
blockIDB
)
{
return
fmt
.
Errorf
(
"DuplicateVoteEvidence Error: BlockIDs are the same (%v) - not a real duplicate vote
!
"
,
dve
.
VoteA
.
BlockID
)
return
fmt
.
Errorf
(
"DuplicateVoteEvidence Error: BlockIDs are the same (%v) - not a real duplicate vote"
,
dve
.
VoteA
.
BlockID
)
}
}
// Signatures must be valid
// Signatures must be valid
...
...
plugin/crypto/init/init.go
View file @
adc9354e
package
init
package
init
import
(
import
(
_
"github.com/33cn/plugin/plugin/crypto/ecdsa"
_
"github.com/33cn/plugin/plugin/crypto/ecdsa"
// register ecdsa package
_
"github.com/33cn/plugin/plugin/crypto/sm2"
_
"github.com/33cn/plugin/plugin/crypto/sm2"
// register sm2 package
)
)
plugin/dapp/evm/executor/evm.go
View file @
adc9354e
...
@@ -118,7 +118,7 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac
...
@@ -118,7 +118,7 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac
}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
// CheckReceiptExecOk return true to check if receipt ty is ok
func
(
c
*
EVMExecutor
)
CheckReceiptExecOk
()
bool
{
func
(
evm
*
EVMExecutor
)
CheckReceiptExecOk
()
bool
{
return
true
return
true
}
}
...
...
plugin/dapp/hashlock/types/hashlock.go
View file @
adc9354e
...
@@ -68,9 +68,9 @@ func (hashlock *HashlockType) CreateTx(action string, message json.RawMessage) (
...
@@ -68,9 +68,9 @@ func (hashlock *HashlockType) CreateTx(action string, message json.RawMessage) (
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
CreateRawHashlockSendTx
(
&
param
)
return
CreateRawHashlockSendTx
(
&
param
)
}
else
{
return
nil
,
types
.
ErrNotSupport
}
}
return
nil
,
types
.
ErrNotSupport
}
}
// GetTypeMap method
// GetTypeMap method
...
...
plugin/dapp/init/init.go
View file @
adc9354e
package
init
package
init
import
(
import
(
_
"github.com/33cn/plugin/plugin/dapp/blackwhite"
_
"github.com/33cn/plugin/plugin/dapp/blackwhite"
// register blackwhite package
_
"github.com/33cn/plugin/plugin/dapp/cert"
_
"github.com/33cn/plugin/plugin/dapp/cert"
// register cert package
_
"github.com/33cn/plugin/plugin/dapp/evm"
_
"github.com/33cn/plugin/plugin/dapp/evm"
// register evm package
_
"github.com/33cn/plugin/plugin/dapp/game"
_
"github.com/33cn/plugin/plugin/dapp/game"
// register game package
_
"github.com/33cn/plugin/plugin/dapp/hashlock"
_
"github.com/33cn/plugin/plugin/dapp/hashlock"
// register hashlock package
_
"github.com/33cn/plugin/plugin/dapp/lottery"
_
"github.com/33cn/plugin/plugin/dapp/lottery"
// register lottery package
_
"github.com/33cn/plugin/plugin/dapp/norm"
_
"github.com/33cn/plugin/plugin/dapp/norm"
// register norm package
_
"github.com/33cn/plugin/plugin/dapp/paracross"
_
"github.com/33cn/plugin/plugin/dapp/paracross"
// register paracross package
_
"github.com/33cn/plugin/plugin/dapp/pokerbull"
_
"github.com/33cn/plugin/plugin/dapp/pokerbull"
// register pokerbull package
_
"github.com/33cn/plugin/plugin/dapp/privacy"
_
"github.com/33cn/plugin/plugin/dapp/privacy"
// register privacy package
_
"github.com/33cn/plugin/plugin/dapp/relay"
_
"github.com/33cn/plugin/plugin/dapp/relay"
// register relay package
_
"github.com/33cn/plugin/plugin/dapp/retrieve"
_
"github.com/33cn/plugin/plugin/dapp/retrieve"
// register retrieve package
_
"github.com/33cn/plugin/plugin/dapp/ticket"
_
"github.com/33cn/plugin/plugin/dapp/ticket"
// register ticker package
_
"github.com/33cn/plugin/plugin/dapp/token"
_
"github.com/33cn/plugin/plugin/dapp/token"
// register token package
_
"github.com/33cn/plugin/plugin/dapp/trade"
_
"github.com/33cn/plugin/plugin/dapp/trade"
// register trade package
_
"github.com/33cn/plugin/plugin/dapp/valnode"
_
"github.com/33cn/plugin/plugin/dapp/valnode"
// register valnode package
)
)
plugin/dapp/pokerbull/executor/pokerbulldb.go
View file @
adc9354e
...
@@ -27,7 +27,7 @@ const (
...
@@ -27,7 +27,7 @@ const (
MaxPlayerNum
=
5
MaxPlayerNum
=
5
// MinPlayValue 最小赌注
// MinPlayValue 最小赌注
MinPlayValue
=
10
*
types
.
Coin
MinPlayValue
=
10
*
types
.
Coin
// DefaultStyle默认游戏类型
// DefaultStyle
默认游戏类型
DefaultStyle
=
pkt
.
PlayStyleDefault
DefaultStyle
=
pkt
.
PlayStyleDefault
)
)
...
...
plugin/dapp/privacy/plugin.go
View file @
adc9354e
...
@@ -6,13 +6,13 @@ package privacy
...
@@ -6,13 +6,13 @@ package privacy
import
(
import
(
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/pluginmgr"
_
"github.com/33cn/plugin/plugin/dapp/privacy/autotest"
_
"github.com/33cn/plugin/plugin/dapp/privacy/autotest"
// register autotest package
"github.com/33cn/plugin/plugin/dapp/privacy/commands"
"github.com/33cn/plugin/plugin/dapp/privacy/commands"
_
"github.com/33cn/plugin/plugin/dapp/privacy/crypto"
_
"github.com/33cn/plugin/plugin/dapp/privacy/crypto"
// register crypto package
"github.com/33cn/plugin/plugin/dapp/privacy/executor"
"github.com/33cn/plugin/plugin/dapp/privacy/executor"
"github.com/33cn/plugin/plugin/dapp/privacy/rpc"
"github.com/33cn/plugin/plugin/dapp/privacy/rpc"
"github.com/33cn/plugin/plugin/dapp/privacy/types"
"github.com/33cn/plugin/plugin/dapp/privacy/types"
_
"github.com/33cn/plugin/plugin/dapp/privacy/wallet"
_
"github.com/33cn/plugin/plugin/dapp/privacy/wallet"
// register wallet package
)
)
func
init
()
{
func
init
()
{
...
...
plugin/dapp/privacy/types/errors.go
View file @
adc9354e
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
package
types
package
types
import
"errors"
import
"errors"
// ErrXXX defines error message
var
(
var
(
ErrGeFromBytesVartime
=
errors
.
New
(
"ErrGeFromBytesVartime"
)
ErrGeFromBytesVartime
=
errors
.
New
(
"ErrGeFromBytesVartime"
)
ErrPrivacyNotEnabled
=
errors
.
New
(
"ErrPrivacyNotEnabled"
)
ErrPrivacyNotEnabled
=
errors
.
New
(
"ErrPrivacyNotEnabled"
)
...
...
plugin/dapp/token/autotest/token.go
View file @
adc9354e
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
autotest
package
autotest
import
(
import
(
"reflect"
"reflect"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
.
"github.com/33cn/chain33/system/dapp/coins/autotest"
"github.com/33cn/chain33/system/dapp/coins/autotest"
)
)
type
tokenAutoTest
struct
{
type
tokenAutoTest
struct
{
SimpleCaseArr
[]
SimpleCase
`toml:"SimpleCase,omitempty"`
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr
[]
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenPreCreateCaseArr
[]
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
TransferCaseArr
[]
autotest
.
TransferCase
`toml:"TransferCase,omitempty"`
WithdrawCaseArr
[]
WithdrawCase
`toml:"WithdrawCase,omitempty"`
WithdrawCaseArr
[]
autotest
.
WithdrawCase
`toml:"WithdrawCase,omitempty"`
TokenRevokeCaseArr
[]
TokenRevokeCase
`toml:"TokenRevokeCase,omitempty"`
TokenRevokeCaseArr
[]
TokenRevokeCase
`toml:"TokenRevokeCase,omitempty"`
}
}
func
init
()
{
func
init
()
{
RegisterAutoTest
(
tokenAutoTest
{})
types
.
RegisterAutoTest
(
tokenAutoTest
{})
}
}
...
...
plugin/dapp/token/autotest/tokenCase.go
View file @
adc9354e
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
autotest
package
autotest
import
(
import
(
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
// TokenPreCreateCase token precreatecase command
type
TokenPreCreateCase
struct
{
type
TokenPreCreateCase
struct
{
BaseCase
types
.
BaseCase
//From string `toml:"from"`
//From string `toml:"from"`
//Amount string `toml:"amount"`
//Amount string `toml:"amount"`
}
}
// TokenPreCreatePack defines token precreate package command
type
TokenPreCreatePack
struct
{
type
TokenPreCreatePack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// TokenFinishCreateCase token finish create case command
type
TokenFinishCreateCase
struct
{
type
TokenFinishCreateCase
struct
{
BaseCase
types
.
BaseCase
//From string `toml:"from"`
//From string `toml:"from"`
//Amount string `toml:"amount"`
//Amount string `toml:"amount"`
}
}
// TokenFinishCreatePack token finish create pack command
type
TokenFinishCreatePack
struct
{
type
TokenFinishCreatePack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// TokenRevokeCase token revoke case command
type
TokenRevokeCase
struct
{
type
TokenRevokeCase
struct
{
BaseCase
types
.
BaseCase
}
}
// TokenRevokePack token revoke pack command
type
TokenRevokePack
struct
{
type
TokenRevokePack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// SendCommand defines send command function of tokenprecreatecase
func
(
testCase
*
TokenPreCreateCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
func
(
testCase
*
TokenPreCreateCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
testCase
,
&
TokenPreCreatePack
{},
packID
)
return
DefaultSend
(
testCase
,
&
TokenPreCreatePack
{},
packID
)
}
}
// SendCommand defines send command function of tokenrevokecase
func
(
testCase
*
TokenRevokeCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
func
(
testCase
*
TokenRevokeCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
testCase
,
&
TokenRevokePack
{},
packID
)
return
DefaultSend
(
testCase
,
&
TokenRevokePack
{},
packID
)
}
}
// SendCommand send command function of tokenfinishcreatecase
func
(
testCase
*
TokenFinishCreateCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
func
(
testCase
*
TokenFinishCreateCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
testCase
,
&
TokenFinishCreatePack
{},
packID
)
return
DefaultSend
(
testCase
,
&
TokenFinishCreatePack
{},
packID
)
}
}
plugin/dapp/token/plugin.go
View file @
adc9354e
...
@@ -7,7 +7,7 @@ package token
...
@@ -7,7 +7,7 @@ package token
import
(
import
(
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/pluginmgr"
_
"github.com/33cn/plugin/plugin/dapp/token/autotest"
_
"github.com/33cn/plugin/plugin/dapp/token/autotest"
// register token autotest package
"github.com/33cn/plugin/plugin/dapp/token/commands"
"github.com/33cn/plugin/plugin/dapp/token/commands"
"github.com/33cn/plugin/plugin/dapp/token/executor"
"github.com/33cn/plugin/plugin/dapp/token/executor"
"github.com/33cn/plugin/plugin/dapp/token/rpc"
"github.com/33cn/plugin/plugin/dapp/token/rpc"
...
...
plugin/dapp/trade/autotest/buyCase.go
View file @
adc9354e
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
autotest
package
autotest
import
(
import
(
...
@@ -8,40 +9,40 @@ import (
...
@@ -8,40 +9,40 @@ import (
"fmt"
"fmt"
"strconv"
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
// BuyCase defines buycase command
type
BuyCase
struct
{
type
BuyCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
From
string
`toml:"from"`
To
string
`toml:"to"`
To
string
`toml:"to"`
TokenAmount
string
`toml:"tokenAmount"`
TokenAmount
string
`toml:"tokenAmount"`
BtyAmount
string
`toml:"btyAmount"`
BtyAmount
string
`toml:"btyAmount"`
}
}
// BuyPack defines buypack command
type
BuyPack
struct
{
type
BuyPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// DependBuyCase defines depend buycase command
type
DependBuyCase
struct
{
type
DependBuyCase
struct
{
BuyCase
BuyCase
SellID
string
`toml:"sellID,omitempty"`
SellID
string
`toml:"sellID,omitempty"`
}
}
// DependBuyPack defines depend buy pack command
type
DependBuyPack
struct
{
type
DependBuyPack
struct
{
BuyPack
BuyPack
}
}
// SendCommand defines send command function of dependbuycase
func
(
testCase
*
DependBuyCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
func
(
testCase
*
DependBuyCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
if
len
(
testCase
.
SellID
)
==
0
{
if
len
(
testCase
.
SellID
)
==
0
{
return
nil
,
errors
.
New
(
"depend sell case failed, Can't buy without sell id"
)
return
nil
,
errors
.
New
(
"depend sell case failed, Can't buy without sell id"
)
}
}
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -s %s"
,
testCase
.
Command
,
testCase
.
SellID
)
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -s %s"
,
testCase
.
Command
,
testCase
.
SellID
)
return
DefaultSend
(
&
testCase
.
BuyCase
,
&
BuyPack
{},
packID
)
return
types
.
DefaultSend
(
&
testCase
.
BuyCase
,
&
BuyPack
{},
packID
)
}
}
// SetDependData defines set depend data function
func
(
testCase
*
DependBuyCase
)
SetDependData
(
depData
interface
{})
{
func
(
testCase
*
DependBuyCase
)
SetDependData
(
depData
interface
{})
{
if
orderInfo
,
ok
:=
depData
.
(
*
SellOrderInfo
);
ok
&&
orderInfo
!=
nil
{
if
orderInfo
,
ok
:=
depData
.
(
*
SellOrderInfo
);
ok
&&
orderInfo
!=
nil
{
...
@@ -49,10 +50,10 @@ func (testCase *DependBuyCase) SetDependData(depData interface{}) {
...
@@ -49,10 +50,10 @@ func (testCase *DependBuyCase) SetDependData(depData interface{}) {
testCase
.
SellID
=
orderInfo
.
sellID
testCase
.
SellID
=
orderInfo
.
sellID
}
}
}
}
// GetCheckHandlerMap defines get check handler for map
func
(
pack
*
BuyPack
)
GetCheckHandlerMap
()
interface
{}
{
func
(
pack
*
BuyPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"frozen"
]
=
pack
.
checkFrozen
funcMap
[
"frozen"
]
=
pack
.
checkFrozen
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"balance"
]
=
pack
.
checkBalance
...
@@ -85,10 +86,10 @@ func (pack *BuyPack) checkBalance(txInfo map[string]interface{}) bool {
...
@@ -85,10 +86,10 @@ func (pack *BuyPack) checkBalance(txInfo map[string]interface{}) bool {
"BuyerTokenPrev"
,
logBuyToken
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"BuyerTokenPrev"
,
logBuyToken
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"BuyerTokenCurr"
,
logBuyToken
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
"BuyerTokenCurr"
,
logBuyToken
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logBuyBty
,
interCase
.
From
,
-
btyAmount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logBuyBty
,
interCase
.
From
,
-
btyAmount
)
&&
CheckBalanceDeltaWithAddr
(
logSellBty
,
interCase
.
To
,
btyAmount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSellBty
,
interCase
.
To
,
btyAmount
)
&&
CheckBalanceDeltaWithAddr
(
logBuyToken
,
interCase
.
From
,
tokenAmount
)
types
.
CheckBalanceDeltaWithAddr
(
logBuyToken
,
interCase
.
From
,
tokenAmount
)
}
}
...
@@ -104,6 +105,6 @@ func (pack *BuyPack) checkFrozen(txInfo map[string]interface{}) bool {
...
@@ -104,6 +105,6 @@ func (pack *BuyPack) checkFrozen(txInfo map[string]interface{}) bool {
"SellerTokenPrev"
,
logSellToken
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
),
"SellerTokenPrev"
,
logSellToken
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
),
"SellerTokenCurr"
,
logSellToken
[
"current"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
))
"SellerTokenCurr"
,
logSellToken
[
"current"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
))
return
CheckFrozenDeltaWithAddr
(
logSellToken
,
interCase
.
To
,
-
tokenAmount
)
return
types
.
CheckFrozenDeltaWithAddr
(
logSellToken
,
interCase
.
To
,
-
tokenAmount
)
}
}
plugin/dapp/trade/autotest/sellCase.go
View file @
adc9354e
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
autotest
package
autotest
import
(
import
(
"strconv"
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
// SellCase defines sell case command
type
SellCase
struct
{
type
SellCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
From
string
`toml:"from"`
Amount
string
`toml:"amount"`
Amount
string
`toml:"amount"`
}
}
// SellPack defines sell pack command
type
SellPack
struct
{
type
SellPack
struct
{
BaseCasePack
types
.
BaseCasePack
orderInfo
*
SellOrderInfo
orderInfo
*
SellOrderInfo
}
}
// SellOrderInfo sell order information
type
SellOrderInfo
struct
{
type
SellOrderInfo
struct
{
sellID
string
sellID
string
}
}
// SendCommand send command of sellcase
func
(
testCase
*
SellCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
func
(
testCase
*
SellCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
testCase
,
&
SellPack
{},
packID
)
return
DefaultSend
(
testCase
,
&
SellPack
{},
packID
)
}
}
// GetCheckHandlerMap defines get check handle for map
func
(
pack
*
SellPack
)
GetCheckHandlerMap
()
interface
{}
{
func
(
pack
*
SellPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"frozen"
]
=
pack
.
checkFrozen
funcMap
[
"frozen"
]
=
pack
.
checkFrozen
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
return
funcMap
}
}
// GetDependData defines get depend data function
func
(
pack
*
SellPack
)
GetDependData
()
interface
{}
{
func
(
pack
*
SellPack
)
GetDependData
()
interface
{}
{
return
pack
.
orderInfo
return
pack
.
orderInfo
...
@@ -65,8 +66,8 @@ func (pack *SellPack) checkBalance(txInfo map[string]interface{}) bool {
...
@@ -65,8 +66,8 @@ func (pack *SellPack) checkBalance(txInfo map[string]interface{}) bool {
pack
.
orderInfo
=
&
SellOrderInfo
{}
pack
.
orderInfo
=
&
SellOrderInfo
{}
pack
.
orderInfo
.
sellID
=
sellOrderInfo
[
"sellID"
]
.
(
string
)
pack
.
orderInfo
.
sellID
=
sellOrderInfo
[
"sellID"
]
.
(
string
)
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
amount
)
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
amount
)
}
}
...
@@ -82,6 +83,6 @@ func (pack *SellPack) checkFrozen(txInfo map[string]interface{}) bool {
...
@@ -82,6 +83,6 @@ func (pack *SellPack) checkFrozen(txInfo map[string]interface{}) bool {
"SellerFrozenPrev"
,
logSend
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
),
"SellerFrozenPrev"
,
logSend
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
),
"SellerFrozenCurr"
,
logSend
[
"current"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
))
"SellerFrozenCurr"
,
logSend
[
"current"
]
.
(
map
[
string
]
interface
{})[
"frozen"
]
.
(
string
))
return
CheckFrozenDeltaWithAddr
(
logSend
,
interCase
.
From
,
amount
)
return
types
.
CheckFrozenDeltaWithAddr
(
logSend
,
interCase
.
From
,
amount
)
}
}
plugin/dapp/trade/autotest/trade.go
View file @
adc9354e
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
autotest
package
autotest
import
(
import
(
"reflect"
"reflect"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
.
"github.com/33cn/chain33/system/dapp/coins/autotest"
coinautotest
"github.com/33cn/chain33/system/dapp/coins/autotest"
.
"github.com/33cn/plugin/plugin/dapp/token/autotest"
tokenautotest
"github.com/33cn/plugin/plugin/dapp/token/autotest"
)
)
type
tradeAutoTest
struct
{
type
tradeAutoTest
struct
{
SimpleCaseArr
[]
SimpleCase
`toml:"SimpleCase,omitempty"`
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr
[]
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenPreCreateCaseArr
[]
tokenautotest
.
TokenPreCreateCase
`toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TokenFinishCreateCaseArr
[]
tokenautotest
.
TokenFinishCreateCase
`toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
TransferCaseArr
[]
coinautotest
.
TransferCase
`toml:"TransferCase,omitempty"`
SellCaseArr
[]
SellCase
`toml:"SellCase,omitempty"`
SellCaseArr
[]
SellCase
`toml:"SellCase,omitempty"`
DependBuyCaseArr
[]
DependBuyCase
`toml:"DependBuyCase,omitempty"`
DependBuyCaseArr
[]
DependBuyCase
`toml:"DependBuyCase,omitempty"`
}
}
func
init
()
{
func
init
()
{
RegisterAutoTest
(
tradeAutoTest
{})
types
.
RegisterAutoTest
(
tradeAutoTest
{})
}
}
...
...
plugin/dapp/trade/plugin.go
View file @
adc9354e
...
@@ -6,7 +6,7 @@ package trade
...
@@ -6,7 +6,7 @@ package trade
import
(
import
(
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/pluginmgr"
_
"github.com/33cn/plugin/plugin/dapp/trade/autotest"
_
"github.com/33cn/plugin/plugin/dapp/trade/autotest"
// register autotest package
"github.com/33cn/plugin/plugin/dapp/trade/commands"
"github.com/33cn/plugin/plugin/dapp/trade/commands"
"github.com/33cn/plugin/plugin/dapp/trade/executor"
"github.com/33cn/plugin/plugin/dapp/trade/executor"
"github.com/33cn/plugin/plugin/dapp/trade/rpc"
"github.com/33cn/plugin/plugin/dapp/trade/rpc"
...
...
plugin/init.go
View file @
adc9354e
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
package
plugin
package
plugin
import
(
import
(
_
"github.com/33cn/plugin/plugin/consensus/init"
_
"github.com/33cn/plugin/plugin/consensus/init"
// register consensus init package
_
"github.com/33cn/plugin/plugin/crypto/init"
_
"github.com/33cn/plugin/plugin/crypto/init"
_
"github.com/33cn/plugin/plugin/dapp/init"
_
"github.com/33cn/plugin/plugin/dapp/init"
_
"github.com/33cn/plugin/plugin/store/init"
_
"github.com/33cn/plugin/plugin/store/init"
...
...
plugin/store/init/init.go
View file @
adc9354e
package
init
package
init
import
(
import
(
_
"github.com/33cn/plugin/plugin/store/kvdb"
_
"github.com/33cn/plugin/plugin/store/kvdb"
// register kvdb package
_
"github.com/33cn/plugin/plugin/store/kvmvcc"
_
"github.com/33cn/plugin/plugin/store/kvmvcc"
// register kvmvcc package
_
"github.com/33cn/plugin/plugin/store/mpt"
_
"github.com/33cn/plugin/plugin/store/mpt"
// register mpt package
)
)
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