Unverified Commit 9545e07c authored by vipwzw's avatar vipwzw Committed by GitHub

Merge branch 'master' into update_chain33

parents 15334ac8 87d3a21b
......@@ -15,6 +15,7 @@ function filterLinter() {
--enable=varcheck \
--enable=structcheck \
--enable=goimports \
--enable=misspell \
--vendor ./...)
# --enable=staticcheck \
# --enable=gocyclo \
......
......@@ -148,5 +148,5 @@ func clearTestData() {
if err != nil {
fmt.Println("delete wallet have a err:", err.Error())
}
fmt.Println("test data clear sucessfully!")
fmt.Println("test data clear successfully!")
}
......@@ -175,5 +175,5 @@ func clearTestData() {
if err != nil {
fmt.Println("delete chain33_raft dir have a err:", err.Error())
}
fmt.Println("test data clear sucessfully!")
fmt.Println("test data clear successfully!")
}
......@@ -181,7 +181,7 @@ func remoteScp(si *ScpInfo, reqnum chan struct{}) {
}()
ScpFileFromLocalToRemote(si)
//session, err := sshconnect("ubuntu", "Fuzamei#123456", "raft15258.chinacloudapp.cn", 22)
fmt.Println("remoteScp file sucessfully!:")
fmt.Println("remoteScp file successfully!:")
}
......
......@@ -396,7 +396,7 @@ func (node *Node) stopAndRemovePeer(peer Peer, reason interface{}) {
peer.Stop()
}
// StopPeerForError called if error occured
// StopPeerForError called if error occurred
func (node *Node) StopPeerForError(peer Peer, reason interface{}) {
tendermintlog.Error("Stopping peer for error", "peer", peer, "err", reason)
addr, err := peer.RemoteAddr()
......
......@@ -161,7 +161,7 @@ func clearTestData() {
if err != nil {
fmt.Println("delete datadir have a err:", err.Error())
}
fmt.Println("test data clear sucessfully!")
fmt.Println("test data clear successfully!")
}
func NormPut() {
......
......@@ -51,7 +51,7 @@ func TestTicket(t *testing.T) {
//js, _ := json.MarshalIndent(detail, "", " ")
//fmt.Println(string(js))
assert.Equal(t, int32(2), detail.Receipt.Ty)
reply, err = mock33.GetAPI().ExecWalletFunc("ticket", "WalletAutoMiner", &ty.MinerFlag{Flag: 1})
_, err = mock33.GetAPI().ExecWalletFunc("ticket", "WalletAutoMiner", &ty.MinerFlag{Flag: 1})
assert.Nil(t, err)
err = mock33.WaitHeight(100)
assert.Nil(t, err)
......
......@@ -528,26 +528,26 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL
addrRes := round.AddrResult
loop := int(round.Loop)
for _, addres := range addrRes {
if len(addres.ShowSecret) > 0 && len(addres.HashValues) == loop {
for _, address := range addrRes {
if len(address.ShowSecret) > 0 && len(address.HashValues) == loop {
var isBlack []bool
// 加入分叉高度判断:分叉高度在ForkV25BlackWhite到ForkV25BlackWhiteV2之间的执行原来逻辑,大于ForkV25BlackWhiteV2执行新逻辑,
// 小于ForkV25BlackWhite则无法进入
if !types.IsDappFork(a.height, gt.BlackwhiteX, "ForkBlackWhiteV2") {
for _, hash := range addres.HashValues {
if bytes.Equal(common.Sha256([]byte(addres.ShowSecret+black)), hash) {
for _, hash := range address.HashValues {
if bytes.Equal(common.Sha256([]byte(address.ShowSecret+black)), hash) {
isBlack = append(isBlack, true)
} else if bytes.Equal(common.Sha256([]byte(addres.ShowSecret+white)), hash) {
} else if bytes.Equal(common.Sha256([]byte(address.ShowSecret+white)), hash) {
isBlack = append(isBlack, false)
} else {
isBlack = append(isBlack, false)
}
}
} else {
for i, hash := range addres.HashValues {
if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+addres.ShowSecret+black)), hash) {
for i, hash := range address.HashValues {
if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+address.ShowSecret+black)), hash) {
isBlack = append(isBlack, true)
} else if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+addres.ShowSecret+white)), hash) {
} else if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+address.ShowSecret+white)), hash) {
isBlack = append(isBlack, false)
} else {
isBlack = append(isBlack, false)
......@@ -555,8 +555,8 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL
}
}
addresX := &resultCalc{
Addr: addres.Addr,
amount: addres.Amount,
Addr: address.Addr,
amount: address.Amount,
IsWin: true,
IsBlack: isBlack,
}
......
......@@ -217,7 +217,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
Loop: 4,
}
addres := &gt.AddressResult{
address := &gt.AddressResult{
Addr: "1",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -225,9 +225,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
addres = &gt.AddressResult{
address = &gt.AddressResult{
Addr: "2",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -235,9 +235,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
addres = &gt.AddressResult{
address = &gt.AddressResult{
Addr: "3",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -245,7 +245,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
round.AddrResult = addrRes
......@@ -257,7 +257,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
//t.Logf("winers1 is %v", winers)
//t.Logf("losers1 is %v", losers)
addres = &gt.AddressResult{
address = &gt.AddressResult{
Addr: "4",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -265,9 +265,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
addres = &gt.AddressResult{
address = &gt.AddressResult{
Addr: "5",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -275,7 +275,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
round.AddrResult = addrRes
......@@ -286,7 +286,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
//t.Logf("winers2 is %v", winers)
//t.Logf("losers2 is %v", losers)
addres = &gt.AddressResult{
address = &gt.AddressResult{
Addr: "6",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
......@@ -298,7 +298,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(7) + showSecret + white))},
ShowSecret: showSecret,
}
addrRes = append(addrRes, addres)
addrRes = append(addrRes, address)
round.AddrResult = addrRes
......
......@@ -285,3 +285,8 @@ func heightIndexToIndex(height int64, index int32) int64 {
func (c *Blackwhite) GetPayloadValue() types.Message {
return &gt.BlackwhiteAction{}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Blackwhite) CheckReceiptExecOk() bool {
return true
}
......@@ -67,7 +67,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string {
var g BlackwhiteAction
err := types.Decode(tx.Payload, &g)
if err != nil {
return "unkown-Blackwhite-action-err"
return "unknown-Blackwhite-action-err"
}
if g.Ty == BlackwhiteActionCreate && g.GetCreate() != nil {
return "BlackwhiteCreate"
......@@ -78,7 +78,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string {
} else if g.Ty == BlackwhiteActionTimeoutDone && g.GetTimeoutDone() != nil {
return "BlackwhiteTimeoutDone"
}
return "unkown"
return "unknown"
}
// Amount ...
......
......@@ -139,3 +139,8 @@ func (c *Cert) loadHistoryByHeight() error {
}
return ct.ErrGetHistoryCertData
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Cert) CheckReceiptExecOk() bool {
return true
}
......@@ -22,9 +22,6 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority
}
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet
historityCertdata := &types.HistoryCertStore{}
......@@ -54,9 +51,6 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority
}
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet
// 写入上一纪录的next-height
......@@ -87,9 +81,6 @@ func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, r
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority
}
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet
return &set, nil
......
......@@ -117,6 +117,11 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac
return false
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *EVMExecutor) CheckReceiptExecOk() bool {
return true
}
// 生成一个新的合约对象地址
func (evm *EVMExecutor) getNewAddr(txHash []byte) common.Address {
return common.NewAddress(txHash)
......
......@@ -106,7 +106,7 @@ func runDir(tt *testing.T, basePath string) {
}
func runCase(tt *testing.T, c VMCase, file string) {
tt.Logf("runing test case:%s in file:%s", c.name, file)
tt.Logf("running test case:%s in file:%s", c.name, file)
// 1 构建预置环境 pre
inst := evm.NewEVMExecutor()
......
......@@ -12,9 +12,6 @@ import (
// roll back local db data
func (g *Game) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs {
switch log.GetTy() {
case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame:
......
......@@ -12,9 +12,6 @@ import (
// save receiptData to local db
func (g *Game) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs {
switch log.Ty {
case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame:
......
......@@ -174,3 +174,8 @@ func (g *Game) GetTypeMap() map[string]int32 {
"Close": gt.GameActionClose,
}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *Game) CheckReceiptExecOk() bool {
return true
}
......@@ -12,9 +12,6 @@ import (
// ExecDelLocal_Hlock Action
func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
if err != nil {
......@@ -25,9 +22,6 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac
// ExecDelLocal_Hsend Action
func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
if err != nil {
......@@ -38,9 +32,6 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac
// ExecDelLocal_Hunlock Action
func (h *Hashlock) ExecDelLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
if err != nil {
......
......@@ -12,9 +12,6 @@ import (
// ExecLocal_Hlock Action
func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
......@@ -26,9 +23,6 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio
// ExecLocal_Hsend Action
func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
......@@ -40,9 +34,6 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio
// ExecLocal_Hunlock Action
func (h *Hashlock) ExecLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
......
......@@ -52,3 +52,8 @@ func (h *Hashlock) GetDriverName() string {
func (h *Hashlock) CheckTx(tx *types.Transaction, index int) error {
return nil
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (h *Hashlock) CheckReceiptExecOk() bool {
return true
}
......@@ -188,7 +188,7 @@ func estHashlock(t *testing.T) {
func estHashunlock(t *testing.T) {
fmt.Println("TestHashunlock start")
defer fmt.Println("TestHashunlock end")
//not sucess as time not enough
//not success as time not enough
time.Sleep(5 * time.Second)
err := unlock(secret)
if err != nil {
......
......@@ -33,8 +33,8 @@ message Hashlockquery {
}
message HashRecv {
bytes HashlockId = 1;
Hashlockquery Infomation = 2;
bytes HashlockId = 1;
Hashlockquery Information = 2;
}
message HashlockUnlock {
......
......@@ -291,7 +291,7 @@ func (m *Hashlockquery) GetCurrentTime() int64 {
type HashRecv struct {
HashlockId []byte `protobuf:"bytes,1,opt,name=HashlockId,proto3" json:"HashlockId,omitempty"`
Infomation *Hashlockquery `protobuf:"bytes,2,opt,name=Infomation,proto3" json:"Infomation,omitempty"`
Information *Hashlockquery `protobuf:"bytes,2,opt,name=Information,proto3" json:"Information,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -329,9 +329,9 @@ func (m *HashRecv) GetHashlockId() []byte {
return nil
}
func (m *HashRecv) GetInfomation() *Hashlockquery {
func (m *HashRecv) GetInformation() *Hashlockquery {
if m != nil {
return m.Infomation
return m.Information
}
return nil
}
......@@ -576,32 +576,32 @@ func init() {
func init() { proto.RegisterFile("hashlock.proto", fileDescriptor_acb83e90536b5ff8) }
var fileDescriptor_acb83e90536b5ff8 = []byte{
// 420 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6e, 0x9b, 0x40,
0x10, 0xc7, 0xbd, 0xd8, 0xd8, 0xf5, 0x60, 0xfb, 0xb0, 0xfd, 0x10, 0x87, 0xaa, 0x42, 0xa8, 0xaa,
0x90, 0x2a, 0x59, 0xaa, 0xdb, 0x17, 0x70, 0x7b, 0xc1, 0x52, 0x4f, 0x9b, 0xe4, 0x1e, 0x02, 0x6b,
0xd9, 0x8a, 0xbd, 0xeb, 0x2c, 0x8b, 0x25, 0xf2, 0x18, 0x91, 0xf2, 0x2a, 0x79, 0x9c, 0x3c, 0x4b,
0xb4, 0x03, 0x64, 0x31, 0x49, 0x6e, 0xb9, 0x31, 0x7f, 0x7e, 0xcc, 0xc7, 0x7f, 0x06, 0x98, 0x6d,
0x92, 0x7c, 0xb3, 0x93, 0xe9, 0xf5, 0xfc, 0xa0, 0xa4, 0x96, 0xd4, 0xd5, 0xe5, 0x81, 0xe7, 0xe1,
0x23, 0x81, 0x0f, 0x71, 0xfd, 0x86, 0x7e, 0x03, 0x68, 0xa8, 0x55, 0xe6, 0x93, 0x80, 0x44, 0x13,
0xd6, 0x52, 0xe8, 0x17, 0x18, 0xe6, 0x3a, 0xd1, 0x45, 0xee, 0x3b, 0x01, 0x89, 0x5c, 0x56, 0x47,
0xe6, 0xbb, 0x7f, 0x8a, 0x27, 0x9a, 0x9f, 0x6f, 0xf7, 0xdc, 0xef, 0x07, 0x24, 0xea, 0xb3, 0x96,
0x42, 0xbf, 0xc2, 0x58, 0xcb, 0x65, 0x96, 0x29, 0x9e, 0xe7, 0xfe, 0x20, 0x20, 0xd1, 0x98, 0x59,
0x81, 0x7e, 0x87, 0xa9, 0xe2, 0xba, 0x50, 0xa2, 0x21, 0x5c, 0x24, 0x4e, 0x45, 0x53, 0x3b, 0xd9,
0xcb, 0x42, 0x68, 0x7f, 0x88, 0xf9, 0xeb, 0xc8, 0xd4, 0x5e, 0x2b, 0x79, 0xcb, 0x85, 0x36, 0xb5,
0x47, 0x55, 0x6d, 0xab, 0x84, 0x77, 0x04, 0x26, 0xcd, 0x80, 0xff, 0xcd, 0x90, 0x36, 0x11, 0x39,
0x49, 0x44, 0x61, 0x80, 0x29, 0x1c, 0x54, 0xf1, 0xd9, 0x68, 0x66, 0x7c, 0x1c, 0x69, 0xc2, 0xf0,
0xf9, 0x3d, 0x86, 0x09, 0x7f, 0xd8, 0x9e, 0xce, 0xb8, 0xa8, 0x8c, 0xe5, 0xa9, 0xe2, 0xba, 0x36,
0xbd, 0x8e, 0xc2, 0x7b, 0x02, 0xd3, 0x06, 0xbc, 0x29, 0xb8, 0x2a, 0x9f, 0xbb, 0x24, 0xad, 0x2e,
0xdf, 0x5a, 0x8b, 0x9d, 0xb4, 0xdf, 0xb5, 0x2c, 0xb5, 0xeb, 0x1a, 0x54, 0x96, 0x59, 0x85, 0x06,
0xe0, 0xa5, 0x85, 0x52, 0x5c, 0x68, 0x04, 0x5c, 0x04, 0xda, 0x52, 0x78, 0x59, 0x1d, 0x0d, 0xe3,
0xe9, 0xd1, 0x64, 0x8b, 0x5f, 0x1c, 0x8d, 0x55, 0xe8, 0x1f, 0x80, 0x95, 0x58, 0xcb, 0x7d, 0xa2,
0xb7, 0x52, 0x60, 0x87, 0xde, 0xe2, 0xd3, 0x1c, 0xaf, 0x6f, 0x7e, 0x32, 0x1b, 0x6b, 0x71, 0x61,
0x04, 0xb3, 0xe6, 0xe5, 0x85, 0xd8, 0xd5, 0x7b, 0x7b, 0xd5, 0xa3, 0x07, 0x62, 0xd1, 0x65, 0x6a,
0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xcd, 0x9c, 0x41, 0xdc, 0x63,
0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xb7, 0xd6, 0x85, 0xcd, 0x7e, 0x10, 0x36, 0x0c, 0xfd, 0x05,
0xa3, 0x4d, 0x81, 0xfd, 0xa0, 0xa7, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac, 0xe1,
0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcb, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x31, 0xd9, 0x15,
0xfc, 0x6a, 0x88, 0x3f, 0xe2, 0xef, 0xa7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, 0x5e, 0xa0, 0xf4,
0x9a, 0x03, 0x00, 0x00,
// 421 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6a, 0xdb, 0x40,
0x10, 0xc7, 0xbd, 0xb2, 0x65, 0xd7, 0x23, 0xdb, 0x87, 0xed, 0x07, 0x3a, 0x94, 0x22, 0x44, 0x29,
0x82, 0x82, 0xa1, 0x2e, 0xf4, 0xee, 0xf6, 0x22, 0x43, 0x4f, 0x9b, 0xe4, 0x01, 0x64, 0x69, 0x8d,
0x4d, 0xec, 0x5d, 0x67, 0xb5, 0x32, 0x28, 0x8f, 0x11, 0xc8, 0xab, 0xe4, 0x71, 0xf2, 0x2c, 0x61,
0x47, 0x52, 0x56, 0x56, 0x92, 0x5b, 0x6e, 0x9a, 0xbf, 0x7e, 0x9a, 0x8f, 0xff, 0x8c, 0x60, 0xb6,
0x4d, 0xf2, 0xed, 0x5e, 0xa6, 0xd7, 0xf3, 0xa3, 0x92, 0x5a, 0x52, 0x57, 0x97, 0x47, 0x9e, 0x87,
0x8f, 0x04, 0x3e, 0xc4, 0xf5, 0x1b, 0xfa, 0x0d, 0xa0, 0xa1, 0x56, 0x99, 0x4f, 0x02, 0x12, 0x4d,
0x58, 0x4b, 0xa1, 0x5f, 0x60, 0x98, 0xeb, 0x44, 0x17, 0xb9, 0xef, 0x04, 0x24, 0x72, 0x59, 0x1d,
0x99, 0xef, 0xfe, 0x29, 0x9e, 0x68, 0x7e, 0xb9, 0x3b, 0x70, 0xbf, 0x1f, 0x90, 0xa8, 0xcf, 0x5a,
0x0a, 0xfd, 0x0a, 0x63, 0x2d, 0x97, 0x59, 0xa6, 0x78, 0x9e, 0xfb, 0x83, 0x80, 0x44, 0x63, 0x66,
0x05, 0xfa, 0x1d, 0xa6, 0x8a, 0xeb, 0x42, 0x89, 0x86, 0x70, 0x91, 0x38, 0x17, 0x4d, 0xed, 0xe4,
0x20, 0x0b, 0xa1, 0xfd, 0x21, 0xe6, 0xaf, 0x23, 0x53, 0x7b, 0xa3, 0xe4, 0x2d, 0x17, 0xda, 0xd4,
0x1e, 0x55, 0xb5, 0xad, 0x12, 0xde, 0x11, 0x98, 0x34, 0x03, 0xfe, 0x37, 0x43, 0xda, 0x44, 0xe4,
0x2c, 0x11, 0x85, 0x01, 0xa6, 0x70, 0x50, 0xc5, 0x67, 0xa3, 0x99, 0xf1, 0x71, 0xa4, 0x09, 0xc3,
0xe7, 0xf7, 0x18, 0x26, 0xfc, 0x61, 0x7b, 0xba, 0xe0, 0xa2, 0x32, 0x96, 0xa7, 0x8a, 0xeb, 0xda,
0xf4, 0x3a, 0x0a, 0xef, 0x09, 0x4c, 0x1b, 0xf0, 0xa6, 0xe0, 0xaa, 0x7c, 0xee, 0x92, 0xb4, 0xba,
0x7c, 0x6b, 0x2d, 0x76, 0xd2, 0x7e, 0xd7, 0xb2, 0xd4, 0xae, 0x6b, 0x50, 0x59, 0x66, 0x15, 0x1a,
0x80, 0x97, 0x16, 0x4a, 0x71, 0xa1, 0x11, 0x70, 0x11, 0x68, 0x4b, 0xe1, 0xba, 0x3a, 0x1a, 0xc6,
0xd3, 0x93, 0xc9, 0x16, 0xbf, 0x38, 0x1a, 0xab, 0xd0, 0x3f, 0xe0, 0xad, 0xc4, 0x46, 0xaa, 0x43,
0xa2, 0x77, 0x52, 0x60, 0x8b, 0xde, 0xe2, 0xd3, 0x1c, 0xcf, 0x6f, 0x7e, 0x36, 0x1c, 0x6b, 0x83,
0x61, 0x04, 0xb3, 0xe6, 0xed, 0x95, 0xd8, 0xd7, 0x9b, 0x7b, 0xd5, 0xa5, 0x07, 0x62, 0xd1, 0x65,
0x6a, 0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xce, 0x1c, 0x42, 0xdc,
0x63, 0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xf7, 0xd6, 0x85, 0xcd, 0x86, 0x10, 0x36, 0x0c, 0xfd,
0x05, 0xa3, 0x6d, 0x81, 0xfd, 0xa0, 0xab, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac,
0xe1, 0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcf, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x29, 0xd9,
0x17, 0x7c, 0x3d, 0xc4, 0x5f, 0xf1, 0xf7, 0x53, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0xf6, 0x91,
0xc1, 0x9c, 0x03, 0x00, 0x00,
}
......@@ -12,9 +12,6 @@ import (
func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
for _, item := range receiptData.Logs {
switch item.Ty {
case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose:
......
......@@ -12,9 +12,6 @@ import (
func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
for _, item := range receipt.Logs {
switch item.Ty {
case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose:
......
......@@ -229,3 +229,8 @@ func dellottery(lotteryID string, status int32) *types.KeyValue {
func (lott *Lottery) GetPayloadValue() types.Message {
return &pty.LotteryAction{}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (lott *Lottery) CheckReceiptExecOk() bool {
return true
}
......@@ -548,11 +548,11 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt
return modify, nil
}
//random used for verfication in solo
//random used for verification in solo
func (action *Action) findLuckyNum(isSolo bool, lott *LotteryDB) int64 {
var num int64
if isSolo {
//used for internal verfication
//used for internal verification
num = 12345
} else {
randMolNum := (lott.TotalPurchasedTxNum+action.height-lott.LastTransToPurState)%3 + 2 //3~5
......
......@@ -58,3 +58,8 @@ func Key(str []byte) (key []byte) {
key = append(key, str...)
return key
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (n *Norm) CheckReceiptExecOk() bool {
return true
}
......@@ -354,3 +354,8 @@ func (c *Paracross) allowIsParaAssetTx(execer []byte) bool {
}
return false
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Paracross) CheckReceiptExecOk() bool {
return true
}
......@@ -25,9 +25,6 @@ func (g *PokerBull) rollbackIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue
func (g *PokerBull) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs {
switch log.GetTy() {
case pkt.TyLogPBGameStart, pkt.TyLogPBGameContinue, pkt.TyLogPBGameQuit:
......
......@@ -55,9 +55,6 @@ func (c *PokerBull) updateIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue)
func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return dbSet, nil
}
for i := 0; i < len(receipt.Logs); i++ {
item := receipt.Logs[i]
if item.Ty == pkt.TyLogPBGameStart || item.Ty == pkt.TyLogPBGameContinue || item.Ty == pkt.TyLogPBGameQuit {
......
......@@ -139,3 +139,8 @@ func delPBGameStatusAndPlayer(status int32, player int32, value, index int64) *t
kv.Value = nil
return kv
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *PokerBull) CheckReceiptExecOk() bool {
return true
}
......@@ -520,9 +520,9 @@ func (action *Action) checkPlayerExistInGame() bool {
}
var value pkt.PBGameRecord
lenght := len(values)
if lenght != 0 {
valueBytes := values[lenght-1]
length := len(values)
if length != 0 {
valueBytes := values[length-1]
err := types.Decode(valueBytes, &value)
if err == nil && value.Status == pkt.PBGameActionQuit {
return false
......
......@@ -499,7 +499,7 @@ func showPrivacyAccountInfoFlag(cmd *cobra.Command) {
cmd.MarkFlagRequired("addr")
cmd.Flags().StringP("token", "t", types.BTY, "coins token, BTY supported.")
cmd.Flags().Int32P("displaymode", "d", 0, "display mode.(0: display collect. 1:display avaliable detail. 2:display frozen detail. 3:display all")
cmd.Flags().Int32P("displaymode", "d", 0, "display mode.(0: display collect. 1:display available detail. 2:display frozen detail. 3:display all")
}
func showPrivacyAccountInfo(cmd *cobra.Command, args []string) {
......
......@@ -108,17 +108,22 @@ func TestGenerateRingSignature1(t *testing.T) {
var signs [maxCount]*Sign
index := 0
prefixHash, err := common.FromHex("fd1f64844a7d6a9f74fc2141bceba9d9d69b1fd6104f93bfa42a6d708a6ab22c")
assert.Nil(t, err)
tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4")
assert.Nil(t, err)
copy(image[:], tmp)
tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub
}
tmp, err = common.FromHex("fd8de2e12410e3da20350e6f4083b73cc3396b4812c09af633d7c223bfb2560b")
assert.Nil(t, err)
copy(sec[:], tmp)
tmp, err = common.FromHex("b5c0a53bce99106e74284ee1d2c64a68a14e8b4c1735e8ab9ca7215a414f97084749935d87d516b5659a01e84b08279c42e649b2e500e2ede443fe68885b0206")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
signs[i] = &Sign{}
}
......@@ -139,14 +144,17 @@ func TestCheckRingSignature1(t *testing.T) {
t.Error("initialize public key from hex failed.")
}
tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4")
assert.Nil(t, err)
copy(image[:], tmp)
tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub
}
tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)])
......@@ -172,11 +180,13 @@ func TestCheckRingSignatureAPI1(t *testing.T) {
}
tmp, err := common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
publickeys[i] = append(publickeys[i], tmp...)
}
tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f")
assert.Nil(t, err)
data := make([][]byte, maxCount)
for i := 0; i < maxCount; i++ {
data[i] = make([]byte, 0)
......@@ -200,14 +210,17 @@ func TestCheckRingSignature3(t *testing.T) {
t.Error("initialize public key from hex failed.")
}
tmp, err := common.FromHex("04e593e5e4028ce1c1194eb473efc21359b114737e5a64f14420b3cf5b22204b")
assert.Nil(t, err)
copy(image[:], tmp)
tmp, err = common.FromHex("6bfc9654082a7da3055121aa69ddb46852577be71d6c9a204aae3492f0db7e41194f27c9fe4d81cc8421bf8256374edf660806d78b4ed7914a3b74359c8ac0bd65ff1bca674607f7948ea0ae8e83b6d9c5092942b52d2847b6cf44c9c609264d")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub
}
tmp, err = common.FromHex("30041e9694c3184980c3bb87f817eab3f973cd969810ec9df4d2feeee907970693eba4bc5436dc7cf49ce476e091bf74d20003f0f73f6d0412909ed8c1a10701c9c4ec11623dd3c50980ead83865a03dfa27614e5e9fb875d75667c11ced390d438f5dd04a137c73a0ec9ca36dfab62c948ce596722067de0315b570db1f720bab7fb7ea1b124f55c9633548f06d1bb403d7e2e15a1fed70ab2865e324ef340327f6d0ad0a7129b272ce12a5a63836a4e96e95897ee44cc22a7048023f438006")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)])
......@@ -250,15 +263,18 @@ func TestCheckRingSignature17(t *testing.T) {
t.Error("initialize public key from hex failed.")
}
tmp, err := common.FromHex("199c5e78a71b320b704e01850a67c371fed3aca11a04077a36e10c808fdc5f57")
assert.Nil(t, err)
copy(image[:], tmp)
for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{}
tmp, err = common.FromHex(pubstrs[i])
assert.Nil(t, err)
copy(pub[:], tmp)
pubs[i] = &pub
}
tmp, err = common.FromHex("f5b1a5079f6122d2370da403efc2e5504b07d67ade7ca57ad3720c7e00a676096ad418262cd9f8c9afee8e58be894cb2bf6387a5018f67d629bf8845bdc9b307aee86f85f8612f74ed870abc81d54cb38f2f9108c20dbf81eb7c1160935bc801cdca5d3f09f1d4bac810cb03ec32753f65a2071a97ba787c2d550ea5ff4d890ac398a1576d108ee67138e7596af54199247c6413e06124af8db76c0ad67c160f351e53029cac4a073c8b188eb8b5151ebf1f34a6693ddbf467ac8c20eec51204c3ca29fd5814f0848b966d2bca9543fc953a0d04bb4782950123d87bd378f60d3cdc5e44160ed4265b7cd84a8200244fa24bac86c50c35b885a15f1bc1de9909fabab87d504fc0cb0b263564e606505477ded1f89543bd4d6ed87ce61918f705359c525c0e0a4cc1d77043c71dfdf9c6834e2623197af1629e34962d940eb4080d06dddaa6e12953232595906289e4712f6aa8c1189f336b823a6a38ac95390b63c508a3409256f0c4df687d4b49990d9878fc5c97af32aa99bc9ffa1215860f69fc141c763fe1f4ed3ccc72e6817e926164752686d55238e74032c47c8c580f7042a62bd74858768815a05b58887f9828bf0f184eceba1416ac294abe453105a0de353316374b1c0560acc0f98181e3229084721a0d2a6ed891d57b805984044372cbb566c91696f5d63e7e5d8cc906c5fb029e71e87a339fcbaee9502f3d01dfd203dbd04797c33370dd0626baabfb9577ca1c294d1d8c6b82ac9624496f04893ad6b2222799cfd1d4ec525b011ecf72b01f6f3b8a6a165f0169fa7cc0960025787d4253e1064e71190d36965605adb850e72e17685e35772cdd3fdfb3d505e96e5eb0ecf8c11bcef62c79e0d49e3ebc76e56d18753403a880b7d7ed399c0e143df235ac8b0748d99e1b0cdcc511abc079c1bdbfead04265d9ad44e5dd7c0e97e4afbacba478539071db02315cc9326c8edb3d8530c7fc78af9ca12b241c04f87bffab95d85f8486ff01aec75e7e38a75ff023e4b2b0f59999c4ac067b500863a63de803da2c89de74878879a39aec6cf800b117ef89ea068a71db5ef70200163d1b4beaeea8c642430e15a64baefd350cb16ca5dae6563c13162904908301485d2c4e5bac6d55dd947a169a38df2848d5e227482760f6d818c45f66a6380507d691ef87e3550626254da3ec65411e8e5aa2ab4846222e208c9ba18cd5ee09617398af31b9eac38b59180bfaec538e5542d698da20016720ced6edb7ba270059c1e1e7107d71524e4a9cf562b5da263b52368f477c5205c768ac36975a250310c37d1f40f5a6eac857ed6082c12f5cf20a0403afcde3f1ea2e4743cb1ba10fd5d92038b1fc65d09467aeac9fe7cd24f78b9376d47d2ef1d3677ede62b2640544dd1b301292b8d082a97bd910ca24fbb5eea878f2cfa4e983bb25a8a66a25065988477eec0c1815a3fa2ff421621707954e9eacdf823eea02c2e3742797c6097e570479b36ca4580c5be9bab187de6a1fa6609768b3fa6448b5bc56d6de820d")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ {
sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)])
......
......@@ -13,10 +13,6 @@ import (
func (p *privacy) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
txhashstr := common.Bytes2Hex(tx.Hash())
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
privacylog.Error("execDelLocal", "txhash", txhashstr, "receipt.GetTy() = ", receiptData.GetTy())
return dbSet, nil
}
localDB := p.GetLocalDB()
for i, item := range receiptData.Logs {
if item.Ty != ty.TyLogPrivacyOutput {
......
......@@ -272,7 +272,7 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
totalOutput += output.Amount
}
feeAmount := int64(0)
var feeAmount int64
if action.Ty == pty.ActionPrivacy2Privacy {
feeAmount = totalInput - totalOutput
} else {
......@@ -331,3 +331,8 @@ func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32
return true, invalidIndex
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (p *privacy) CheckReceiptExecOk() bool {
return true
}
......@@ -38,7 +38,7 @@ func (policy *privacyPolicy) rescanAllTxAddToUpdateUTXOs() {
go policy.rescanReqTxDetailByAddr(acc.Addr, policy.rescanwg)
}
policy.rescanwg.Wait()
bizlog.Debug("rescanAllTxToUpdateUTXOs sucess!")
bizlog.Debug("rescanAllTxToUpdateUTXOs success!")
}
//从blockchain模块同步addr参与的所有交易详细信息
......@@ -312,8 +312,8 @@ func (policy *privacyPolicy) showPrivacyKeyPair(reqAddr *types.ReqString) (*priv
return nil, err
}
pair := privacyInfo.ViewPubkey[:]
pair = append(pair, privacyInfo.SpendPubkey[:]...)
//pair := privacyInfo.ViewPubkey[:]
//pair = append(pair, privacyInfo.SpendPubkey[:]...)
replyPrivacyPkPair := &privacytypes.ReplyPrivacyPkPair{
ShowSuccessful: true,
......@@ -333,6 +333,10 @@ func (policy *privacyPolicy) getPrivacyAccountInfo(req *privacytypes.ReqPPrivacy
// 搜索可用余额
privacyDBStore, err := policy.store.listAvailableUTXOs(token, addr)
if err != nil {
bizlog.Error("getPrivacyAccountInfo", "listAvailableUTXOs")
return nil, err
}
utxos := make([]*privacytypes.UTXO, 0)
for _, ele := range privacyDBStore {
utxoBasic := &privacytypes.UTXOBasic{
......@@ -820,7 +824,7 @@ func (policy *privacyPolicy) rescanReqUtxosByAddr(addrs []string) {
defer policy.getWalletOperate().GetWaitGroup().Done()
bizlog.Debug("RescanAllUTXO begin!")
policy.reqUtxosByAddr(addrs)
bizlog.Debug("RescanAllUTXO sucess!")
bizlog.Debug("RescanAllUTXO success!")
}
func (policy *privacyPolicy) reqUtxosByAddr(addrs []string) {
......
......@@ -118,7 +118,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
defer wallet.GetMutex().Unlock()
ok, err := wallet.CheckWalletStatus()
if !ok {
if !ok || err != nil {
return
}
......@@ -128,7 +128,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
//校验label是否已经被使用
Account, err := wallet.GetAccountByLabel(PrivKey.GetLabel())
if Account != nil {
if Account != nil || err != nil {
return
}
......@@ -161,7 +161,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
Encrypteredstr := common.ToHex(Encryptered)
//校验PrivKey对应的addr是否已经存在钱包中
Account, err = wallet.GetAccountByAddr(addr)
if Account != nil {
if Account != nil || err != nil {
if Account.Privkey == Encrypteredstr {
return
} else {
......@@ -277,7 +277,7 @@ func Test_EnablePrivacy(t *testing.T) {
req: &ty.ReqEnablePrivacy{Addrs: []string{testAddrs[0]}},
needReply: &ty.RepEnablePrivacy{
Results: []*ty.PriAddrResult{
{IsOK: true, Addr: testAddrs[0]}},
{Addr: testAddrs[0], Msg: "ErrAddrNotExist"}},
},
},
}
......@@ -305,14 +305,15 @@ func Test_ShowPrivacyKey(t *testing.T) {
}{
{
req: &types.ReqString{Data: testAddrs[1]},
needError: ty.ErrPrivacyNotEnabled,
needError: types.ErrAddrNotExist,
},
{
req: &types.ReqString{Data: testAddrs[0]},
needReply: &ty.ReplyPrivacyPkPair{
/*needReply: &ty.ReplyPrivacyPkPair{
ShowSuccessful: true,
Pubkeypair: "92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389",
},
},*/
needError: types.ErrAddrNotExist,
},
}
......@@ -349,6 +350,7 @@ func Test_CreateUTXOs(t *testing.T) {
Sender: testAddrs[0],
Pubkeypair: testPubkeyPairs[0],
},
needError: types.ErrAddrNotExist,
},
}
......@@ -379,6 +381,7 @@ func Test_SendPublic2PrivacyTransaction(t *testing.T) {
Pubkeypair: testPubkeyPairs[0],
},
needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
},
}
......@@ -418,6 +421,7 @@ func Test_SendPrivacy2PrivacyTransaction(t *testing.T) {
Pubkeypair: testPubkeyPairs[1],
},
needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
},
}
......@@ -457,6 +461,7 @@ func Test_SendPrivacy2PublicTransaction(t *testing.T) {
Receiver: testAddrs[0],
},
needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
},
}
......@@ -496,6 +501,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0],
Pubkeypair: testPubkeyPairs[0],
},
//needError:types.ErrAddrNotExist,
},
{ // 私对私测试
req: &types.ReqCreateTransaction{
......@@ -505,6 +511,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0],
Pubkeypair: testPubkeyPairs[1],
},
needError: types.ErrAddrNotExist,
},
{ // 私对公测试
req: &types.ReqCreateTransaction{
......@@ -514,6 +521,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0],
Pubkeypair: testPubkeyPairs[0],
},
needError: types.ErrAddrNotExist,
},
}
for index, testCase := range testCases {
......@@ -621,7 +629,7 @@ func Test_RescanUTXOs(t *testing.T) {
Addrs: testAddrs,
Flag: 0,
},
needError: ty.ErrPrivacyNotEnabled,
needError: types.ErrAccountNotExist,
},
{
enable: true,
......@@ -629,6 +637,7 @@ func Test_RescanUTXOs(t *testing.T) {
Addrs: testAddrs,
Flag: 0,
},
needError: types.ErrAccountNotExist,
},
}
for index, testCase := range testCases {
......
......@@ -255,8 +255,10 @@ func testStore_listAvailableUTXOs(t *testing.T) {
err = store.Set(key, []byte("AccKey"))
assert.NoError(t, err)
utxos, err = store.listAvailableUTXOs(token, addr)
assert.Nil(t, utxos)
assert.NotNil(t, err)
err = store.Set([]byte("AccKey"), bt)
assert.NoError(t, err)
utxos, err = store.listAvailableUTXOs(token, addr)
assert.NoError(t, err)
assert.Equal(t, 1, len(utxos))
......@@ -290,6 +292,7 @@ func testStore_getAccountByAddr(t *testing.T) {
bt, err := proto.Marshal(account)
assert.NoError(t, err)
err = store.Set(calcAddrKey(addr), bt)
assert.NoError(t, err)
was, err = store.getAccountByAddr(addr)
assert.Equal(t, true, proto.Equal(was, account))
assert.NoError(t, err)
......@@ -345,6 +348,7 @@ func testStore_getVersion(t *testing.T) {
bt, err = json.Marshal(PRIVACYDBVERSION)
assert.NoError(t, err)
err = store.Set(calcPrivacyDBVersion(), bt)
assert.NoError(t, err)
version = store.getVersion()
assert.Equal(t, PRIVACYDBVERSION, version)
}
......@@ -243,3 +243,8 @@ func deleteCreateOrderKeyValue(kv []*types.KeyValue, order *ty.RelayOrder, statu
return kv
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (r *relay) CheckReceiptExecOk() bool {
return true
}
......@@ -51,9 +51,6 @@ func DelRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types.
// ExecDelLocal_Backup Action
func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Backup")
info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup}
......@@ -72,9 +69,6 @@ func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Tran
// ExecDelLocal_Prepare Action
func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Prepare")
info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: c.GetBlockTime(), RemainTime: zeroRemainTime, Status: retrievePrepare}
......@@ -93,9 +87,6 @@ func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Trans
// ExecDelLocal_Perform Action
func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Perform")
info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform}
......@@ -114,9 +105,6 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran
// ExecDelLocal_Cancel Action
func (c *Retrieve) ExecDelLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Cancel")
info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel}
......
......@@ -54,9 +54,6 @@ func SaveRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types
// ExecLocal_Backup Action
func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Backup")
info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup}
kv, err := SaveRetrieveInfo(&info, retrieveBackup, c.GetLocalDB())
......@@ -74,9 +71,6 @@ func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transac
// ExecLocal_Prepare Action
func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Prepare")
info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePrepare}
......@@ -95,9 +89,6 @@ func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transact
// ExecLocal_Perform Action
func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Perf")
info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform}
......@@ -116,9 +107,6 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac
// ExecLocal_Cancel Action
func (c *Retrieve) ExecLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Cancel")
info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel}
......
......@@ -82,3 +82,8 @@ func getRetrieveInfo(db dbm.KVDB, backupAddr string, defaultAddr string) (*rt.Re
}
return &info, nil
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (r *Retrieve) CheckReceiptExecOk() bool {
return true
}
......@@ -344,7 +344,7 @@ func estRetrievePerform(t *testing.T) {
func estRetrieveCancel(t *testing.T) {
fmt.Println("\nTestRetrieveCancel start")
fmt.Println("*This case is used for checking cancel operation\n*Cancel action is done with privkey of account A/B, although the cancel action for A could succeed, but the balance have been transfered by last action with backup a\n*currBalanceA = currBalanceA - 2*fee currBalanceB = currBalanceB + 1e8 - 2*fee")
fmt.Println("*This case is used for checking cancel operation\n*Cancel action is done with privkey of account A/B, although the cancel action for A could succeed, but the balance have been transferred by last action with backup a\n*currBalanceA = currBalanceA - 2*fee currBalanceB = currBalanceB + 1e8 - 2*fee")
defer fmt.Println("TestRetrieveCancel end")
var hashes [][]byte
......
......@@ -11,9 +11,6 @@ import (
func (t *Ticket) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, item := range receiptData.Logs {
//这三个是ticket 的log
if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket {
......
......@@ -11,9 +11,6 @@ import (
func (t *Ticket) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, item := range receiptData.Logs {
//这三个是ticket 的log
if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket {
......
......@@ -186,3 +186,8 @@ func (t *Ticket) CheckTx(tx *types.Transaction, index int) error {
}
return nil
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *Ticket) CheckReceiptExecOk() bool {
return true
}
......@@ -59,7 +59,7 @@ func init() {
types.AllowUserExec = append(types.AllowUserExec, []byte(TicketX))
types.RegistorExecutor(TicketX, NewType())
types.RegisterDappFork(TicketX, "Enable", 0)
types.RegisterDappFork(TicketX, "ForkTicketId", 1200000)
types.RegisterDappFork(TicketX, "ForkTicketId", 1062000)
}
// TicketType ticket exec type
......
......@@ -338,3 +338,8 @@ func (t *token) getTxByToken(req *tokenty.ReqTokenTx) (types.Message, error) {
}
return &replyTxInfos, nil
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *token) CheckReceiptExecOk() bool {
return true
}
......@@ -202,3 +202,8 @@ func saveBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBas
func deleteBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase, status int32, height int64) []*types.KeyValue {
return genBuyMarketOrderKeyValue(kv, receipt, status, height, nil)
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *trade) CheckReceiptExecOk() bool {
return true
}
......@@ -12,9 +12,6 @@ import (
// ExecDelLocal_Node method
func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeUpdateHeightIndexKey(val.GetHeight(), index)
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil})
return set, nil
......@@ -23,9 +20,6 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction,
// ExecDelLocal_BlockInfo method
func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeBlockInfoHeightKey(val.GetHeight())
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil})
return set, nil
......
......@@ -14,9 +14,6 @@ import (
// ExecLocal_Node method
func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
if len(node.GetPubKey()) == 0 {
return nil, errors.New("validator pubkey is empty")
}
......@@ -32,9 +29,6 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec
// ExecLocal_BlockInfo method
func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeBlockInfoHeightKey(val.GetHeight())
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: types.Encode(blockInfo)})
return set, nil
......
......@@ -68,3 +68,8 @@ func CalcValNodeUpdateHeightKey(height int64) []byte {
func CalcValNodeBlockInfoHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height))
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (val *ValNode) CheckReceiptExecOk() bool {
return true
}
......@@ -26,5 +26,4 @@ func version(cmd *cobra.Command, args []string) {
var res types.NodeVersion
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, &res)
ctx.Run()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment