Merge pull request #292 from meshplus/fix/add-judgment-that-transactionhash-is-null

fix(internal,tester): add the judgment of whether transactionhash is null
This commit is contained in:
Alexader 2020-12-21 15:05:36 +08:00 committed by GitHub
commit b1b8230353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)