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
6dde0d18
Commit
6dde0d18
authored
Apr 12, 2019
by
vipwzw
Committed by
vipwzw
Apr 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 0412
parent
d8258991
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
167 additions
and
22 deletions
+167
-22
execaccount.go
vendor/github.com/33cn/chain33/account/execaccount.go
+19
-8
execaccount_test.go
vendor/github.com/33cn/chain33/account/execaccount_test.go
+21
-0
execenv.go
vendor/github.com/33cn/chain33/executor/execenv.go
+9
-1
executor_test.go
vendor/github.com/33cn/chain33/executor/executor_test.go
+37
-2
listener.go
vendor/github.com/33cn/chain33/p2p/listener.go
+14
-3
p2p_test.go
vendor/github.com/33cn/chain33/p2p/p2p_test.go
+26
-0
coins.go
...thub.com/33cn/chain33/system/dapp/coins/executor/coins.go
+7
-2
driver_test.go
vendor/github.com/33cn/chain33/system/dapp/driver_test.go
+0
-3
util.go
vendor/github.com/33cn/chain33/system/dapp/util.go
+15
-3
util_test.go
vendor/github.com/33cn/chain33/system/dapp/util_test.go
+10
-0
tx.go
vendor/github.com/33cn/chain33/types/tx.go
+9
-0
No files found.
vendor/github.com/33cn/chain33/account/execaccount.go
View file @
6dde0d18
...
@@ -223,15 +223,30 @@ func (acc *DB) ExecAddress(name string) string {
...
@@ -223,15 +223,30 @@ func (acc *DB) ExecAddress(name string) string {
return
address
.
ExecAddress
(
name
)
return
address
.
ExecAddress
(
name
)
}
}
// ExecDepositFrozen 执行增发coins
// ExecDepositFrozen 执行增发coins
到具体的地址,并冻结
func
(
acc
*
DB
)
ExecDepositFrozen
(
addr
,
execaddr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
func
(
acc
*
DB
)
ExecDepositFrozen
(
addr
,
execaddr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
if
addr
==
execaddr
{
if
addr
==
execaddr
{
return
nil
,
types
.
ErrSendSameToRecv
return
nil
,
types
.
ErrSendSameToRecv
}
}
//issue coins to exec addr
receipt1
,
err
:=
acc
.
ExecIssueCoins
(
execaddr
,
amount
)
if
err
!=
nil
{
return
nil
,
err
}
receipt2
,
err
:=
acc
.
execDepositFrozen
(
addr
,
execaddr
,
amount
)
if
err
!=
nil
{
return
nil
,
err
}
return
acc
.
mergeReceipt
(
receipt1
,
receipt2
),
nil
}
// ExecIssueCoins 增发coins到具体的挖矿合约
func
(
acc
*
DB
)
ExecIssueCoins
(
execaddr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
//这个函数只有挖矿的合约才能调用
//这个函数只有挖矿的合约才能调用
allow
:=
false
allow
:=
false
for
_
,
exec
:=
range
types
.
GetMinerExecs
()
{
for
_
,
exec
:=
range
types
.
GetMinerExecs
()
{
if
acc
.
ExecAddress
(
exec
)
==
execaddr
{
if
acc
.
ExecAddress
(
types
.
ExecName
(
exec
)
)
==
execaddr
{
allow
=
true
allow
=
true
break
break
}
}
...
@@ -239,15 +254,11 @@ func (acc *DB) ExecDepositFrozen(addr, execaddr string, amount int64) (*types.Re
...
@@ -239,15 +254,11 @@ func (acc *DB) ExecDepositFrozen(addr, execaddr string, amount int64) (*types.Re
if
!
allow
{
if
!
allow
{
return
nil
,
types
.
ErrNotAllowDeposit
return
nil
,
types
.
ErrNotAllowDeposit
}
}
receipt1
,
err
:=
acc
.
depositBalance
(
execaddr
,
amount
)
receipt
,
err
:=
acc
.
depositBalance
(
execaddr
,
amount
)
if
err
!=
nil
{
return
nil
,
err
}
receipt2
,
err
:=
acc
.
execDepositFrozen
(
addr
,
execaddr
,
amount
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
acc
.
mergeReceipt
(
receipt1
,
receipt2
)
,
nil
return
receipt
,
nil
}
}
func
(
acc
*
DB
)
execDepositFrozen
(
addr
,
execaddr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
func
(
acc
*
DB
)
execDepositFrozen
(
addr
,
execaddr
string
,
amount
int64
)
(
*
types
.
Receipt
,
error
)
{
...
...
vendor/github.com/33cn/chain33/account/execaccount_test.go
View file @
6dde0d18
...
@@ -174,3 +174,24 @@ func TestExecDepositFrozen(t *testing.T) {
...
@@ -174,3 +174,24 @@ func TestExecDepositFrozen(t *testing.T) {
accCoin
.
LoadExecAccount
(
addr1
,
execaddress
)
.
Frozen
)
accCoin
.
LoadExecAccount
(
addr1
,
execaddress
)
.
Frozen
)
require
.
Equal
(
t
,
int64
(
20
*
1e8
+
25
*
1e8
),
accCoin
.
LoadExecAccount
(
addr1
,
execaddress
)
.
Frozen
)
require
.
Equal
(
t
,
int64
(
20
*
1e8
+
25
*
1e8
),
accCoin
.
LoadExecAccount
(
addr1
,
execaddress
)
.
Frozen
)
}
}
func
TestExecIssueCoins
(
t
*
testing
.
T
)
{
q
:=
initEnv
()
blockchainProcess
(
q
)
storeProcess
(
q
)
accCoin
,
_
:=
GenerAccDb
()
execaddress
:=
address
.
ExecAddress
(
"token"
)
_
,
err
:=
accCoin
.
ExecIssueCoins
(
execaddress
,
25
*
1e8
)
require
.
Equal
(
t
,
types
.
ErrNotAllowDeposit
,
err
)
require
.
Zero
(
t
,
accCoin
.
LoadAccount
(
execaddress
)
.
Balance
)
execaddress
=
address
.
ExecAddress
(
"user.p.para.ticket"
)
_
,
err
=
accCoin
.
ExecIssueCoins
(
execaddress
,
25
*
1e8
)
require
.
Equal
(
t
,
types
.
ErrNotAllowDeposit
,
err
)
execaddress
=
address
.
ExecAddress
(
"ticket"
)
_
,
err
=
accCoin
.
ExecIssueCoins
(
execaddress
,
25
*
1e8
)
require
.
NoError
(
t
,
err
)
t
.
Logf
(
"ExecIssueCoins [%d]"
,
accCoin
.
LoadAccount
(
execaddress
)
.
Balance
)
require
.
Equal
(
t
,
int64
(
25
*
1e8
),
accCoin
.
LoadAccount
(
execaddress
)
.
Balance
)
}
vendor/github.com/33cn/chain33/executor/execenv.go
View file @
6dde0d18
...
@@ -188,10 +188,18 @@ func (e *executor) execCheckTx(tx *types.Transaction, index int) error {
...
@@ -188,10 +188,18 @@ func (e *executor) execCheckTx(tx *types.Transaction, index int) error {
if
!
exec
.
IsFree
()
&&
types
.
GInt
(
"MinFee"
)
>
0
{
if
!
exec
.
IsFree
()
&&
types
.
GInt
(
"MinFee"
)
>
0
{
from
:=
tx
.
From
()
from
:=
tx
.
From
()
accFrom
:=
e
.
coinsAccount
.
LoadAccount
(
from
)
accFrom
:=
e
.
coinsAccount
.
LoadAccount
(
from
)
//余额少于手续费时直接返回错误
if
accFrom
.
GetBalance
()
<
tx
.
GetTxFee
()
{
elog
.
Error
(
"execCheckTx"
,
"ispara"
,
types
.
IsPara
(),
"exec"
,
string
(
tx
.
Execer
),
"Balance"
,
accFrom
.
GetBalance
(),
"TxFee"
,
tx
.
GetTxFee
())
return
types
.
ErrNoBalance
}
if
accFrom
.
GetBalance
()
<
types
.
GInt
(
"MinBalanceTransfer"
)
{
if
accFrom
.
GetBalance
()
<
types
.
GInt
(
"MinBalanceTransfer"
)
{
elog
.
Error
(
"execCheckTx"
,
"ispara"
,
types
.
IsPara
(),
"exec"
,
string
(
tx
.
Execer
),
"nonce"
,
tx
.
Nonce
)
elog
.
Error
(
"execCheckTx"
,
"ispara"
,
types
.
IsPara
(),
"exec"
,
string
(
tx
.
Execer
),
"nonce"
,
tx
.
Nonce
,
"Balance"
,
accFrom
.
GetBalance
()
)
return
types
.
ErrBalanceLessThanTenTimesFee
return
types
.
ErrBalanceLessThanTenTimesFee
}
}
}
}
return
exec
.
CheckTx
(
tx
,
index
)
return
exec
.
CheckTx
(
tx
,
index
)
}
}
...
...
vendor/github.com/33cn/chain33/executor/executor_test.go
View file @
6dde0d18
...
@@ -5,14 +5,15 @@
...
@@ -5,14 +5,15 @@
package
executor
package
executor
import
(
import
(
"encoding/hex"
"fmt"
"fmt"
"testing"
"testing"
"time"
"time"
"encoding/hex"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/store"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
drivers
"github.com/33cn/chain33/system/dapp"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
...
@@ -219,3 +220,37 @@ func TestExecutorErrAPIEnv(t *testing.T) {
...
@@ -219,3 +220,37 @@ func TestExecutorErrAPIEnv(t *testing.T) {
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
assert
.
Equal
(
t
,
true
,
api
.
IsAPIEnvError
(
err
))
assert
.
Equal
(
t
,
true
,
api
.
IsAPIEnvError
(
err
))
}
}
func
TestCheckTx
(
t
*
testing
.
T
)
{
prev
:=
types
.
GInt
(
"MinFee"
)
types
.
SetMinFee
(
100000
)
defer
types
.
SetMinFee
(
prev
)
q
:=
queue
.
New
(
"channel"
)
cfg
,
sub
:=
types
.
InitCfg
(
"../cmd/chain33/chain33.test.toml"
)
store
:=
store
.
New
(
cfg
.
Store
,
sub
.
Store
)
store
.
SetQueueClient
(
q
.
Client
())
defer
store
.
Close
()
addr
,
priv
:=
util
.
Genaddress
()
tx
:=
util
.
CreateCoinsTx
(
priv
,
addr
,
types
.
Coin
)
tx
.
Execer
=
[]
byte
(
"user.xxx"
)
tx
.
To
=
address
.
ExecAddress
(
"user.xxx"
)
tx
.
Fee
=
2
*
types
.
Coin
tx
.
Sign
(
types
.
SECP256K1
,
priv
)
var
txs
[]
*
types
.
Transaction
txs
=
append
(
txs
,
tx
)
ctx
:=
&
executorCtx
{
stateHash
:
nil
,
height
:
0
,
blocktime
:
time
.
Now
()
.
Unix
(),
difficulty
:
1
,
mainHash
:
nil
,
parentHash
:
nil
,
}
execute
:=
newExecutor
(
ctx
,
&
Executor
{},
nil
,
txs
,
nil
)
err
:=
execute
.
execCheckTx
(
tx
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNoBalance
)
}
vendor/github.com/33cn/chain33/p2p/listener.go
View file @
6dde0d18
...
@@ -6,6 +6,7 @@ package p2p
...
@@ -6,6 +6,7 @@ package p2p
import
(
import
(
"fmt"
"fmt"
"math/rand"
"net"
"net"
"sync"
"sync"
"time"
"time"
...
@@ -53,11 +54,21 @@ type listener struct {
...
@@ -53,11 +54,21 @@ type listener struct {
// NewListener produce a listener object
// NewListener produce a listener object
func
NewListener
(
protocol
string
,
node
*
Node
)
Listener
{
func
NewListener
(
protocol
string
,
node
*
Node
)
Listener
{
log
.
Debug
(
"NewListener"
,
"localPort"
,
node
.
listenPort
)
Retry
:
log
.
Info
(
"NewListener"
,
"localPort"
,
node
.
listenPort
)
l
,
err
:=
net
.
Listen
(
protocol
,
fmt
.
Sprintf
(
":%v"
,
node
.
listenPort
))
l
,
err
:=
net
.
Listen
(
protocol
,
fmt
.
Sprintf
(
":%v"
,
node
.
listenPort
))
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Crit
(
"Failed to listen"
,
"Error"
,
err
.
Error
())
log
.
Error
(
"Failed to listen"
,
"Error"
,
err
.
Error
())
return
nil
for
{
randPort
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
.
Int31n
(
65535
)
if
int
(
randPort
)
==
node
.
listenPort
||
randPort
<
2048
{
continue
}
node
.
listenPort
=
int
(
randPort
)
break
}
log
.
Info
(
"Flush Listen Port"
,
"RandPort"
,
node
.
listenPort
)
goto
Retry
}
}
dl
:=
&
listener
{
dl
:=
&
listener
{
...
...
vendor/github.com/33cn/chain33/p2p/p2p_test.go
View file @
6dde0d18
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
//"github.com/33cn/chain33/util/testnode"
//"github.com/33cn/chain33/util/testnode"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"golang.org/x/net/context"
...
@@ -129,6 +130,7 @@ func TestNetInfo(t *testing.T) {
...
@@ -129,6 +130,7 @@ func TestNetInfo(t *testing.T) {
p2pModule
.
node
.
nodeInfo
.
IsNatDone
()
p2pModule
.
node
.
nodeInfo
.
IsNatDone
()
p2pModule
.
node
.
nodeInfo
.
SetNatDone
()
p2pModule
.
node
.
nodeInfo
.
SetNatDone
()
p2pModule
.
node
.
nodeInfo
.
Get
()
p2pModule
.
node
.
nodeInfo
.
Get
()
p2pModule
.
node
.
nodeInfo
.
Set
(
p2pModule
.
node
.
nodeInfo
)
}
}
//测试Peer
//测试Peer
...
@@ -269,6 +271,19 @@ func TestGrpcStreamConns(t *testing.T) {
...
@@ -269,6 +271,19 @@ func TestGrpcStreamConns(t *testing.T) {
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
_
,
err
=
resp
.
Recv
()
_
,
err
=
resp
.
Recv
()
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
"no authorized"
))
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
"no authorized"
))
ping
,
err
:=
P2pComm
.
NewPingData
(
p2pModule
.
node
.
nodeInfo
)
assert
.
Nil
(
t
,
err
)
_
,
err
=
cli
.
ServerStreamSend
(
context
.
Background
(),
ping
)
assert
.
Nil
(
t
,
err
)
_
,
err
=
cli
.
ServerStreamRead
(
context
.
Background
())
assert
.
Nil
(
t
,
err
)
var
emptyBlock
types
.
P2PBlock
_
,
err
=
cli
.
BroadCastBlock
(
context
.
Background
(),
&
emptyBlock
)
assert
.
Equal
(
t
,
true
,
strings
.
Contains
(
err
.
Error
(),
"no authorized"
))
conn
.
Close
()
conn
.
Close
()
}
}
...
@@ -367,6 +382,17 @@ func TestNetAddress(t *testing.T) {
...
@@ -367,6 +382,17 @@ func TestNetAddress(t *testing.T) {
}
}
func
TestP2pListen
(
t
*
testing
.
T
)
{
var
node
Node
node
.
listenPort
=
3333
listen1
:=
NewListener
(
"tcp"
,
&
node
)
assert
.
Equal
(
t
,
true
,
listen1
!=
nil
)
listen2
:=
NewListener
(
"tcp"
,
&
node
)
assert
.
Equal
(
t
,
true
,
listen2
!=
nil
)
listen1
.
Close
()
listen2
.
Close
()
}
func
TestP2pClose
(
t
*
testing
.
T
)
{
func
TestP2pClose
(
t
*
testing
.
T
)
{
p2pModule
.
Wait
()
p2pModule
.
Wait
()
p2pModule
.
Close
()
p2pModule
.
Close
()
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/executor/coins.go
View file @
6dde0d18
...
@@ -81,9 +81,14 @@ func (c *Coins) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bo
...
@@ -81,9 +81,14 @@ func (c *Coins) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bo
return
false
return
false
}
}
//step2 判定 othertx 的 执行器名称(只允许主链,并且是挖矿的行为)
//step2 判定 othertx 的 执行器名称(只允许主链,并且是挖矿的行为)
if
string
(
othertx
.
Execer
)
==
"ticket"
&&
othertx
.
ActionName
()
==
"miner"
{
if
othertx
.
ActionName
()
==
"miner"
{
return
true
for
_
,
exec
:=
range
types
.
GetMinerExecs
()
{
if
types
.
ExecName
(
exec
)
==
string
(
othertx
.
Execer
)
{
return
true
}
}
}
}
return
false
return
false
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/driver_test.go
View file @
6dde0d18
...
@@ -193,9 +193,6 @@ func TestDriverBase(t *testing.T) {
...
@@ -193,9 +193,6 @@ func TestDriverBase(t *testing.T) {
data
:=
types
.
Encode
(
&
types
.
LocalDBSet
{
KV
:
rollbackkvs
})
data
:=
types
.
Encode
(
&
types
.
LocalDBSet
{
KV
:
rollbackkvs
})
assert
.
Equal
(
t
,
string
(
newkvs
[
1
]
.
Value
),
string
(
types
.
Encode
(
&
types
.
ReceiptLog
{
Ty
:
types
.
TyLogRollback
,
Log
:
data
})))
assert
.
Equal
(
t
,
string
(
newkvs
[
1
]
.
Value
),
string
(
types
.
Encode
(
&
types
.
ReceiptLog
{
Ty
:
types
.
TyLogRollback
,
Log
:
data
})))
_
,
err
=
demo
.
DelRollbackKV
(
tx
,
[]
byte
(
execer
))
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
kvdb
.
Set
(
newkvs
[
1
]
.
Key
,
newkvs
[
1
]
.
Value
)
kvdb
.
Set
(
newkvs
[
1
]
.
Key
,
newkvs
[
1
]
.
Value
)
newkvs
,
err
=
demo
.
DelRollbackKV
(
tx
,
[]
byte
(
execer
))
newkvs
,
err
=
demo
.
DelRollbackKV
(
tx
,
[]
byte
(
execer
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
...
vendor/github.com/33cn/chain33/system/dapp/util.go
View file @
6dde0d18
...
@@ -150,18 +150,27 @@ func (c *KVCreator) KVList() []*types.KeyValue {
...
@@ -150,18 +150,27 @@ func (c *KVCreator) KVList() []*types.KeyValue {
//AddRollbackKV 添加回滚数据到 KV
//AddRollbackKV 添加回滚数据到 KV
func
(
c
*
KVCreator
)
AddRollbackKV
()
{
func
(
c
*
KVCreator
)
AddRollbackKV
()
{
v
:=
types
.
Encode
(
c
.
rollbackLog
())
rbLog
:=
c
.
rollbackLog
()
c
.
kvs
=
append
(
c
.
kvs
,
&
types
.
KeyValue
{
Key
:
c
.
rollbackkey
,
Value
:
v
})
if
rbLog
!=
nil
{
v
:=
types
.
Encode
(
rbLog
)
c
.
kvs
=
append
(
c
.
kvs
,
&
types
.
KeyValue
{
Key
:
c
.
rollbackkey
,
Value
:
v
})
}
}
}
//DelRollbackKV 删除rollback kv
//DelRollbackKV 删除rollback kv
func
(
c
*
KVCreator
)
DelRollbackKV
()
{
func
(
c
*
KVCreator
)
DelRollbackKV
()
{
c
.
kvs
=
append
(
c
.
kvs
,
&
types
.
KeyValue
{
Key
:
c
.
rollbackkey
})
if
len
(
c
.
kvs
)
>
0
{
c
.
kvs
=
append
(
c
.
kvs
,
&
types
.
KeyValue
{
Key
:
c
.
rollbackkey
})
}
}
}
//GetRollbackKVList 获取 rollback 到 Key and Vaue
//GetRollbackKVList 获取 rollback 到 Key and Vaue
func
(
c
*
KVCreator
)
GetRollbackKVList
()
([]
*
types
.
KeyValue
,
error
)
{
func
(
c
*
KVCreator
)
GetRollbackKVList
()
([]
*
types
.
KeyValue
,
error
)
{
data
,
err
:=
c
.
kvdb
.
Get
(
c
.
rollbackkey
)
data
,
err
:=
c
.
kvdb
.
Get
(
c
.
rollbackkey
)
if
err
==
types
.
ErrNotFound
{
return
nil
,
nil
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -183,6 +192,9 @@ func (c *KVCreator) GetRollbackKVList() ([]*types.KeyValue, error) {
...
@@ -183,6 +192,9 @@ func (c *KVCreator) GetRollbackKVList() ([]*types.KeyValue, error) {
//rollbackLog rollback log
//rollbackLog rollback log
func
(
c
*
KVCreator
)
rollbackLog
()
*
types
.
ReceiptLog
{
func
(
c
*
KVCreator
)
rollbackLog
()
*
types
.
ReceiptLog
{
if
len
(
c
.
rollbackkvs
)
==
0
{
return
nil
}
data
:=
types
.
Encode
(
&
types
.
LocalDBSet
{
KV
:
c
.
rollbackkvs
})
data
:=
types
.
Encode
(
&
types
.
LocalDBSet
{
KV
:
c
.
rollbackkvs
})
return
&
types
.
ReceiptLog
{
Ty
:
types
.
TyLogRollback
,
Log
:
data
}
return
&
types
.
ReceiptLog
{
Ty
:
types
.
TyLogRollback
,
Log
:
data
}
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/util_test.go
View file @
6dde0d18
...
@@ -80,6 +80,16 @@ func TestKVCreator(t *testing.T) {
...
@@ -80,6 +80,16 @@ func TestKVCreator(t *testing.T) {
creator
.
AddKVListOnly
([]
*
types
.
KeyValue
{{
Key
:
[]
byte
(
"k"
),
Value
:
[]
byte
(
"v"
)}})
creator
.
AddKVListOnly
([]
*
types
.
KeyValue
{{
Key
:
[]
byte
(
"k"
),
Value
:
[]
byte
(
"v"
)}})
creator
.
DelRollbackKV
()
creator
.
DelRollbackKV
()
creator
.
AddToLogs
(
nil
)
creator
.
AddToLogs
(
nil
)
creator
=
NewKVCreator
(
kvdb
,
[]
byte
(
"prefix-"
),
[]
byte
(
"emptyrollback"
))
creator
.
AddListNoPrefix
(
nil
)
creator
.
AddRollbackKV
()
assert
.
Zero
(
t
,
len
(
creator
.
kvs
))
kvs
,
err
=
creator
.
GetRollbackKVList
()
assert
.
Zero
(
t
,
len
(
kvs
))
assert
.
Nil
(
t
,
err
)
creator
.
DelRollbackKV
()
assert
.
Zero
(
t
,
len
(
creator
.
kvs
))
}
}
func
TestHeightIndexStr
(
t
*
testing
.
T
)
{
func
TestHeightIndexStr
(
t
*
testing
.
T
)
{
...
...
vendor/github.com/33cn/chain33/types/tx.go
View file @
6dde0d18
...
@@ -540,6 +540,15 @@ func (tx *Transaction) IsExpire(height, blocktime int64) bool {
...
@@ -540,6 +540,15 @@ func (tx *Transaction) IsExpire(height, blocktime int64) bool {
return
group
.
IsExpire
(
height
,
blocktime
)
return
group
.
IsExpire
(
height
,
blocktime
)
}
}
//GetTxFee 获取交易的费用,区分单笔交易和交易组
func
(
tx
*
Transaction
)
GetTxFee
()
int64
{
group
,
_
:=
tx
.
GetTxGroup
()
if
group
==
nil
{
return
tx
.
Fee
}
return
group
.
Txs
[
0
]
.
Fee
}
//From 交易from地址
//From 交易from地址
func
(
tx
*
Transaction
)
From
()
string
{
func
(
tx
*
Transaction
)
From
()
string
{
return
address
.
PubKeyToAddr
(
tx
.
GetSignature
()
.
GetPubkey
())
return
address
.
PubKeyToAddr
(
tx
.
GetSignature
()
.
GetPubkey
())
...
...
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