Commit c0d55ff9 authored by QM's avatar QM

uodata

parent a16cf9ab
...@@ -363,6 +363,27 @@ func (a *action) supervisionNodeGroupApprove(config *pt.ParaNodeAddrConfig) (*ty ...@@ -363,6 +363,27 @@ func (a *action) supervisionNodeGroupApprove(config *pt.ParaNodeAddrConfig) (*ty
return a.supervisionNodeGroupApproveApply(config, id) return a.supervisionNodeGroupApproveApply(config, id)
} }
func makeParaSupervisionNodeGroupStatusReceipt(title string, addr string, prev, current *pt.ParaNodeGroupStatus) *types.Receipt {
key := calcParaSupervisionNodeGroupStatusKey(title)
log := &pt.ReceiptParaNodeGroupConfig{
Addr: addr,
Prev: prev,
Current: current,
}
return &types.Receipt{
Ty: types.ExecOk,
KV: []*types.KeyValue{
{Key: key, Value: types.Encode(current)},
},
Logs: []*types.ReceiptLog{
{
Ty: pt.TyLogParaSupervisionNodeGroupStatusUpdate,
Log: types.Encode(log),
},
},
}
}
func (a *action) supervisionNodeGroupApproveApply(config *pt.ParaNodeAddrConfig, apply *pt.ParaNodeGroupStatus) (*types.Receipt, error) { func (a *action) supervisionNodeGroupApproveApply(config *pt.ParaNodeAddrConfig, apply *pt.ParaNodeGroupStatus) (*types.Receipt, error) {
err := a.checkSupervisionNodeGroupExist(config.Title) err := a.checkSupervisionNodeGroupExist(config.Title)
if err != nil { if err != nil {
...@@ -383,14 +404,14 @@ func (a *action) supervisionNodeGroupApproveApply(config *pt.ParaNodeAddrConfig, ...@@ -383,14 +404,14 @@ func (a *action) supervisionNodeGroupApproveApply(config *pt.ParaNodeAddrConfig,
receipt.Logs = append(receipt.Logs, r.Logs...) receipt.Logs = append(receipt.Logs, r.Logs...)
copyStat := *apply copyStat := *apply
apply.Status = pt.ParacrossNodeGroupApprove apply.Status = pt.ParacrossSupervisionNodeApprove
apply.Height = a.height apply.Height = a.height
r = makeNodeGroupIDReceipt(a.fromaddr, &copyStat, apply) r = makeSupervisionNodeGroupIDReceipt(a.fromaddr, &copyStat, apply)
receipt.KV = append(receipt.KV, r.KV...) receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...) receipt.Logs = append(receipt.Logs, r.Logs...)
r = makeParaNodeGroupStatusReceipt(config.Title, a.fromaddr, nil, apply) r = makeParaSupervisionNodeGroupStatusReceipt(config.Title, a.fromaddr, nil, apply)
receipt.KV = append(receipt.KV, r.KV...) receipt.KV = append(receipt.KV, r.KV...)
receipt.Logs = append(receipt.Logs, r.Logs...) receipt.Logs = append(receipt.Logs, r.Logs...)
cfg := a.api.GetConfig() cfg := a.api.GetConfig()
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types" pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
) )
// createRawSupervisionNodeConfigTx create raw tx for node config // createRawSupervisionNodeConfigTx create raw tx for node config
...@@ -20,7 +21,7 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) (*types.Tra ...@@ -20,7 +21,7 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) (*types.Tra
} }
func (suite *NodeManageTestSuite) TestSupervisionExec() { func (suite *NodeManageTestSuite) TestSupervisionExec() {
//suite.testSupervisionNodeConfigQuit() suite.testSupervisionNodeConfigQuit()
suite.testSupervisionNodeConfigApprove() suite.testSupervisionNodeConfigApprove()
} }
...@@ -34,16 +35,8 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() { ...@@ -34,16 +35,8 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
suite.Nil(err) suite.Nil(err)
receipt := nodeCommit(suite, PrivKey14K, tx) receipt := nodeCommit(suite, PrivKey14K, tx)
fmt.Println(receipt) checkSupervisionGroupApplyReceipt(suite, receipt)
fmt.Println(receipt.Ty, int32(types.ExecOk))
fmt.Println(receipt.KV, 1)
fmt.Println(receipt.Logs, 1)
fmt.Println(int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
//assert.Equal(suite.T(), int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
//checkGroupApplyReceipt(suite, receipt)
//suite.Equal(int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
var g pt.ReceiptParaNodeGroupConfig var g pt.ReceiptParaNodeGroupConfig
err = types.Decode(receipt.Logs[0].Log, &g) err = types.Decode(receipt.Logs[0].Log, &g)
suite.Nil(err) suite.Nil(err)
...@@ -56,7 +49,9 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() { ...@@ -56,7 +49,9 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
tx, err = createRawSupervisionNodeConfigTx(config) tx, err = createRawSupervisionNodeConfigTx(config)
suite.Nil(err) suite.Nil(err)
nodeCommit(suite, PrivKey14K, tx) receipt = nodeCommit(suite, PrivKey14K, tx)
fmt.Println("***", receipt)
fmt.Println("***", receipt.Logs[0].Ty)
} }
func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() { func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() {
...@@ -69,16 +64,8 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() { ...@@ -69,16 +64,8 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() {
suite.Nil(err) suite.Nil(err)
receipt := nodeCommit(suite, PrivKey14K, tx) receipt := nodeCommit(suite, PrivKey14K, tx)
fmt.Println(receipt) checkSupervisionGroupApplyReceipt(suite, receipt)
fmt.Println(receipt.Ty, int32(types.ExecOk))
fmt.Println(receipt.KV, 1)
fmt.Println(receipt.Logs, 1)
fmt.Println(int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
//assert.Equal(suite.T(), int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
//checkGroupApplyReceipt(suite, receipt)
//suite.Equal(int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty)
var g pt.ReceiptParaNodeGroupConfig var g pt.ReceiptParaNodeGroupConfig
err = types.Decode(receipt.Logs[0].Log, &g) err = types.Decode(receipt.Logs[0].Log, &g)
suite.Nil(err) suite.Nil(err)
...@@ -91,13 +78,13 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() { ...@@ -91,13 +78,13 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigApprove() {
tx, err = createRawSupervisionNodeConfigTx(config) tx, err = createRawSupervisionNodeConfigTx(config)
suite.Nil(err) suite.Nil(err)
receipt = nodeCommit(suite, Account14K, tx) receipt = nodeCommit(suite, PrivKey14K, tx)
assert.Equal(suite.T(), receipt.Ty, int32(types.ExecOk))
fmt.Println(receipt) }
fmt.Println(receipt.Ty, int32(types.ExecOk))
fmt.Println(receipt.KV, 1)
fmt.Println(receipt.Logs, 1)
fmt.Println(int32(pt.TyLogParaNodeGroupConfig), receipt.Logs[0].Ty) func checkSupervisionGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
checkGroupApproveReceipt(suite, receipt) assert.Equal(suite.T(), receipt.Ty, int32(types.ExecOk))
assert.Len(suite.T(), receipt.KV, 1)
assert.Len(suite.T(), receipt.Logs, 1)
assert.Equal(suite.T(), int32(pt.TyLogParaSupervisionNodeGroupConfig), receipt.Logs[0].Ty)
} }
...@@ -55,6 +55,7 @@ const ( ...@@ -55,6 +55,7 @@ const (
TyLogParaSupervisionNodeConfig TyLogParaSupervisionNodeConfig
TyLogParaSupervisionNodeStatusUpdate TyLogParaSupervisionNodeStatusUpdate
TyLogParaStageSupervisionGroupUpdate TyLogParaStageSupervisionGroupUpdate
TyLogParaSupervisionNodeGroupStatusUpdate
) )
// action type // action type
......
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