fix(internal,tester): add the judgment of whether transactionhash is null
1. Add the judgment of whether transactionhash is null.
This commit is contained in:
parent
92666dd4a2
commit
f52360867c
|
@ -21,6 +21,14 @@ type BrokerAPI CoreAPI
|
|||
var _ api.BrokerAPI = (*BrokerAPI)(nil)
|
||||
|
||||
func (b *BrokerAPI) HandleTransaction(tx *pb.Transaction) error {
|
||||
if tx.TransactionHash == nil {
|
||||
if tx.Hash() != nil {
|
||||
tx.TransactionHash = tx.Hash()
|
||||
} else {
|
||||
return fmt.Errorf("transaction hash is nil")
|
||||
}
|
||||
}
|
||||
|
||||
b.logger.WithFields(logrus.Fields{
|
||||
"hash": tx.TransactionHash.String(),
|
||||
}).Debugf("Receive tx")
|
||||
|
@ -35,6 +43,14 @@ func (b *BrokerAPI) HandleTransaction(tx *pb.Transaction) error {
|
|||
}
|
||||
|
||||
func (b *BrokerAPI) HandleView(tx *pb.Transaction) (*pb.Receipt, error) {
|
||||
if tx.TransactionHash == nil {
|
||||
if tx.Hash() != nil {
|
||||
tx.TransactionHash = tx.Hash()
|
||||
} else {
|
||||
return nil, fmt.Errorf("transaction hash is nil")
|
||||
}
|
||||
}
|
||||
|
||||
b.logger.WithFields(logrus.Fields{
|
||||
"hash": tx.TransactionHash.String(),
|
||||
}).Debugf("Receive view")
|
||||
|
|
|
@ -72,6 +72,7 @@ func testSendView(suite *API) {
|
|||
suite.Equal(receipt.Status, pb.Receipt_SUCCESS)
|
||||
suite.Equal(value, string(receipt.Ret))
|
||||
}
|
||||
|
||||
//
|
||||
//func (suite *API) TestDelVPNode() {
|
||||
// err := suite.api.Broker().DelVPNode(1)
|
||||
|
|
Loading…
Reference in New Issue