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:
dawn-to-dusk 2020-12-18 17:08:28 +08:00
parent 92666dd4a2
commit f52360867c
2 changed files with 17 additions and 0 deletions

View File

@ -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")

View File

@ -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)