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
2331a033
Commit
2331a033
authored
Jan 27, 2019
by
jiangpeng
Committed by
vipwzw
Jan 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add autotest
parent
37e9aea1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
433 additions
and
0 deletions
+433
-0
confirm.go
plugin/dapp/multisig/autotest/confirm.go
+45
-0
create.go
plugin/dapp/multisig/autotest/create.go
+82
-0
multisig.go
plugin/dapp/multisig/autotest/multisig.go
+37
-0
multisig.toml
plugin/dapp/multisig/autotest/multisig.toml
+106
-0
transferIn.go
plugin/dapp/multisig/autotest/transferIn.go
+75
-0
transferOut.go
plugin/dapp/multisig/autotest/transferOut.go
+87
-0
plugin.go
plugin/dapp/multisig/plugin.go
+1
-0
No files found.
plugin/dapp/multisig/autotest/confirm.go
0 → 100644
View file @
2331a033
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"fmt"
"github.com/33cn/chain33/cmd/autotest/types"
)
type
confirmCase
struct
{
types
.
BaseCase
From
string
`toml:"from"`
Amount
string
`toml:"amount"`
txID
string
info
*
multisigInfo
}
type
confirmPack
struct
{
types
.
BaseCasePack
}
// SendCommand defines send command
func
(
testCase
*
confirmCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
if
testCase
.
txID
==
""
||
testCase
.
info
==
nil
||
testCase
.
info
.
account
==
""
{
return
nil
,
fmt
.
Errorf
(
"nil confirm tx id or multi sign account"
)
}
return
types
.
DefaultSend
(
testCase
,
&
confirmPack
{},
packID
)
}
// SetDependData defines set depend data function
func
(
testCase
*
confirmCase
)
SetDependData
(
depData
interface
{})
{
if
txid
,
ok
:=
depData
.
(
string
);
ok
&&
txid
!=
""
{
testCase
.
txID
=
txid
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -i %s"
,
testCase
.
Command
,
testCase
.
txID
)
}
else
if
info
,
ok
:=
depData
.
(
*
multisigInfo
);
ok
&&
info
!=
nil
{
testCase
.
info
=
info
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -a %s"
,
testCase
.
Command
,
testCase
.
info
.
account
)
}
}
plugin/dapp/multisig/autotest/create.go
0 → 100644
View file @
2331a033
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"encoding/json"
"github.com/33cn/chain33/cmd/autotest/types"
)
type
createMultisigCase
struct
{
types
.
BaseCase
Creator
string
`toml:"creator"`
Owners
[]
string
`toml:"owners"`
}
type
createMultisigPack
struct
{
types
.
BaseCasePack
info
*
multisigInfo
}
type
multisigInfo
struct
{
account
string
}
// SendCommand send command
func
(
t
*
createMultisigCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
return
types
.
DefaultSend
(
t
,
&
createMultisigPack
{},
packID
)
}
// GetCheckHandlerMap defines get check handle for map
func
(
pack
*
createMultisigPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
types
.
CheckHandlerMap
,
1
)
funcMap
[
"create"
]
=
pack
.
checkCreate
return
funcMap
}
// GetDependData defines get depend data function
func
(
pack
*
createMultisigPack
)
GetDependData
()
interface
{}
{
return
pack
.
info
}
func
(
pack
*
createMultisigPack
)
checkCreate
(
txInfo
types
.
CheckHandlerParamType
)
bool
{
var
createLog
map
[
string
]
interface
{}
err
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
1
]
.
Log
,
&
createLog
)
if
err
!=
nil
{
pack
.
FLog
.
Error
(
"checkMultisigCreate"
,
"id"
,
pack
.
PackID
,
"unmarshalErr"
,
err
)
return
false
}
interCase
:=
pack
.
TCase
.
(
*
createMultisigCase
)
info
:=
&
multisigInfo
{}
info
.
account
=
createLog
[
"multiSigAddr"
]
.
(
string
)
pack
.
info
=
info
creator
:=
createLog
[
"createAddr"
]
.
(
string
)
owners
:=
createLog
[
"owners"
]
.
([]
interface
{})
if
creator
!=
interCase
.
Creator
{
pack
.
FLog
.
Error
(
"WrongMultiSignCreator"
,
"id"
,
pack
.
PackID
,
"creator"
,
creator
,
"expect"
,
interCase
.
Creator
)
return
false
}
for
i
,
owner
:=
range
owners
{
addr
:=
owner
.
(
map
[
string
]
interface
{})[
"ownerAddr"
]
.
(
string
)
if
addr
!=
interCase
.
Owners
[
i
]
{
pack
.
FLog
.
Error
(
"WrongMultiSignOwner"
,
"id"
,
pack
.
PackID
,
"owner"
,
addr
,
"expect"
,
interCase
.
Owners
[
i
])
return
false
}
}
return
true
}
plugin/dapp/multisig/autotest/multisig.go
0 → 100644
View file @
2331a033
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"reflect"
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/system/dapp/coins/autotest"
)
type
multisigAutoTest
struct
{
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TransferCaseArr
[]
autotest
.
TransferCase
`toml:"TransferCase,omitempty"`
CreateCaseArr
[]
createMultisigCase
`toml:"MultiSigCreateCase"`
TransferInArr
[]
transferInCase
`toml:"MultiSigTransInCase"`
TransferOutArr
[]
transferOutCase
`toml:"MultiSigTransOutCase"`
ConfirmArr
[]
confirmCase
`toml:"MultiSigConfirmCase"`
}
func
init
()
{
types
.
RegisterAutoTest
(
multisigAutoTest
{})
}
func
(
config
multisigAutoTest
)
GetName
()
string
{
return
"multisig"
}
func
(
config
multisigAutoTest
)
GetTestConfigType
()
reflect
.
Type
{
return
reflect
.
TypeOf
(
config
)
}
plugin/dapp/multisig/autotest/multisig.toml
0 → 100644
View file @
2331a033
#import multi sign test, 13P8wznbULh6GWJ9LWNdSp4so3bejZ91YV
#send to token for precreate
[[TransferCase]]
id
=
"trans"
command
=
"send bty transfer -a 20 -t 14uBEP6LSHKdFvy97pTYRPVPAqij6bteee -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"14uBEP6LSHKdFvy97pTYRPVPAqij6bteee"
amount
=
"20"
checkItem
=
["balance"]
[[MultiSigCreateCase]]
id
=
"create"
command
=
"send multisig account create -d 1 -e coins -s bty -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv-14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -w 20-10 -r 15 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
creator
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
owners
=
[
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
,
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
]
checkItem
=
["create"]
[[MultiSigTransInCase]]
id
=
"transIn"
command
=
"send multisig tx transfer_in -a 5 -e coins -s bty -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"5"
repeat
=
2
dep
=
[
"trans"
,
"create"
]
checkItem
=
["balance"]
[[MultiSigTransInCase]]
id
=
"failTransIn"
command
=
"send multisig tx transfer_in -a 25 -e coins -s bty -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"25"
dep
=
["create"]
checkItem
=
["balance"]
fail
=
true
[[MultiSigTransOutCase]]
id
=
"transOut1"
command
=
"send multisig tx transfer_out -a 0.1 -e coins -s bty -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"0.1"
dep
=
[
"create"
,
"transIn"
]
checkItem
=
["balance"]
repeat
=
10
#allow daily limit
[[MultiSigTransOutCase]]
id
=
"transOut2"
command
=
"send multisig tx transfer_out -a 0.1 -e coins -s bty -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"0.1"
dep
=
[
"create"
,
"transIn"
]
checkItem
=
["balance"]
repeat
=
10
#not enough weight, need more owner confirm
[[MultiSigTransOutCase]]
id
=
"transOut3"
command
=
"send multisig tx transfer_out -a 1.1 -e coins -s bty -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"1.1"
dep
=
[
"create"
,
"transIn"
]
checkItem
=
["balance"]
#need fail confirm
[[MultiSigTransOutCase]]
id
=
"transOut4"
command
=
"send multisig tx transfer_out -a 10.1 -e coins -s bty -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"10.1"
dep
=
[
"create"
,
"transIn"
]
checkItem
=
["balance"]
[[MultiSigTransOutCase]]
id
=
"failTransOut"
command
=
"send multisig tx transfer_out -a 10.1 -e coins -s bty -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"10.1"
dep
=
[
"create"
,
"transIn"
]
checkItem
=
["balance"]
fail
=
true
[[MultiSigConfirmCase]]
id
=
"confirm"
command
=
"send multisig tx confirm -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep
=
[
"create"
,
"transOut3"
]
[[MultiSigConfirmCase]]
id
=
"failConfirm"
command
=
"send multisig tx confirm -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep
=
[
"create"
,
"transOut4"
]
fail
=
true
plugin/dapp/multisig/autotest/transferIn.go
0 → 100644
View file @
2331a033
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"encoding/json"
"fmt"
"strconv"
"github.com/33cn/chain33/cmd/autotest/types"
)
type
transferInCase
struct
{
types
.
BaseCase
From
string
`toml:"from"`
Amount
string
`toml:"amount"`
info
*
multisigInfo
}
type
transferInPack
struct
{
types
.
BaseCasePack
}
// SendCommand defines send command
func
(
testCase
*
transferInCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
if
testCase
.
info
==
nil
||
len
(
testCase
.
info
.
account
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"nil multiSign account addr"
)
}
return
types
.
DefaultSend
(
testCase
,
&
transferInPack
{},
packID
)
}
// SetDependData defines set depend data function
func
(
testCase
*
transferInCase
)
SetDependData
(
depData
interface
{})
{
if
info
,
ok
:=
depData
.
(
*
multisigInfo
);
ok
&&
info
!=
nil
{
testCase
.
info
=
info
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -t %s"
,
testCase
.
Command
,
testCase
.
info
.
account
)
}
}
// GetCheckHandlerMap defines get check handle for map
func
(
pack
*
transferInPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
types
.
CheckHandlerMap
,
1
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
}
func
(
pack
*
transferInPack
)
checkBalance
(
txInfo
types
.
CheckHandlerParamType
)
bool
{
var
fromLog
map
[
string
]
interface
{}
var
toLog
map
[
string
]
interface
{}
var
frozenLog
map
[
string
]
interface
{}
err1
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
1
]
.
Log
,
&
fromLog
)
err2
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
2
]
.
Log
,
&
toLog
)
err3
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
3
]
.
Log
,
&
frozenLog
)
if
err1
!=
nil
||
err2
!=
nil
||
err3
!=
nil
{
pack
.
FLog
.
Error
(
"checkMultiSignTransferIn"
,
"id"
,
pack
.
PackID
,
"unmarshalErr1"
,
err1
,
"unmarshalErr2"
,
err2
,
"unmarshalErr3"
,
err3
)
return
false
}
interCase
:=
pack
.
TCase
.
(
*
transferInCase
)
amount
,
_
:=
strconv
.
ParseFloat
(
interCase
.
Amount
,
64
)
return
types
.
CheckBalanceDeltaWithAddr
(
fromLog
,
interCase
.
From
,
-
amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
toLog
,
interCase
.
info
.
account
,
amount
)
&&
types
.
CheckFrozenDeltaWithAddr
(
frozenLog
,
interCase
.
info
.
account
,
amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
frozenLog
,
interCase
.
info
.
account
,
-
amount
)
}
plugin/dapp/multisig/autotest/transferOut.go
0 → 100644
View file @
2331a033
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
autotest
import
(
"encoding/json"
"fmt"
"strconv"
"github.com/33cn/chain33/cmd/autotest/types"
)
type
transferOutCase
struct
{
types
.
BaseCase
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
info
*
multisigInfo
}
type
transferOutPack
struct
{
types
.
BaseCasePack
txID
string
}
// SendCommand defines send command
func
(
testCase
*
transferOutCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
if
testCase
.
info
==
nil
||
len
(
testCase
.
info
.
account
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"nil multiSign account addr"
)
}
return
types
.
DefaultSend
(
testCase
,
&
transferOutPack
{},
packID
)
}
// GetDependData defines get depend data function
func
(
pack
*
transferOutPack
)
GetDependData
()
interface
{}
{
return
pack
.
txID
}
// SetDependData defines set depend data function
func
(
testCase
*
transferOutCase
)
SetDependData
(
depData
interface
{})
{
if
info
,
ok
:=
depData
.
(
*
multisigInfo
);
ok
&&
info
!=
nil
{
testCase
.
info
=
info
testCase
.
Command
=
fmt
.
Sprintf
(
"%s -f %s"
,
testCase
.
Command
,
testCase
.
info
.
account
)
}
}
// GetCheckHandlerMap defines get check handle for map
func
(
pack
*
transferOutPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
types
.
CheckHandlerMap
,
1
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
}
func
(
pack
*
transferOutPack
)
checkBalance
(
txInfo
types
.
CheckHandlerParamType
)
bool
{
logLen
:=
len
(
txInfo
.
Receipt
.
Logs
)
var
txLog
map
[
string
]
interface
{}
_
=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
logLen
-
1
]
.
Log
,
&
txLog
)
pack
.
txID
=
txLog
[
"multiSigTxOwner"
]
.
(
map
[
string
]
interface
{})[
"txid"
]
.
(
string
)
if
logLen
<
6
{
//need confirm
return
true
}
var
fromLog
map
[
string
]
interface
{}
var
toLog
map
[
string
]
interface
{}
err1
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
1
]
.
Log
,
&
fromLog
)
err2
:=
json
.
Unmarshal
(
txInfo
.
Receipt
.
Logs
[
2
]
.
Log
,
&
toLog
)
if
err1
!=
nil
||
err2
!=
nil
{
pack
.
FLog
.
Error
(
"checkMultiSignTransferOut"
,
"id"
,
pack
.
PackID
,
"unmarshalErr1"
,
err1
,
"unmarshalErr2"
)
return
false
}
interCase
:=
pack
.
TCase
.
(
*
transferOutCase
)
amount
,
_
:=
strconv
.
ParseFloat
(
interCase
.
Amount
,
64
)
return
types
.
CheckFrozenDeltaWithAddr
(
fromLog
,
interCase
.
info
.
account
,
-
amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
toLog
,
interCase
.
To
,
amount
)
}
plugin/dapp/multisig/plugin.go
View file @
2331a033
...
...
@@ -2,6 +2,7 @@ package multisig
import
(
"github.com/33cn/chain33/pluginmgr"
_
"github.com/33cn/plugin/plugin/dapp/multisig/autotest"
//register auto test
"github.com/33cn/plugin/plugin/dapp/multisig/commands"
"github.com/33cn/plugin/plugin/dapp/multisig/executor"
"github.com/33cn/plugin/plugin/dapp/multisig/rpc"
...
...
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