Uploaded image for project: 'Fabric'
  1. Fabric
  2. FAB-5333

Inconsistent results between in real Fabric chaincode deployment and in unit test

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Medium
    • Resolution: Done
    • None
    • None
    • fabric-build
    • None

    Description

      If we use stub.PutState and stub.GetState in the same Invoke, we will get inconsistent results between in real Fabric chaincode and in unit test. Here gives a simple example:

      76 func (t *CC) Invoke(stub shim.ChaincodeStubInterface) peer.Response {
      77 var err error
      78 var byteArray []byte
      79
      80 err = stub.PutState("just-existing", []byte("just-data"))
      81 if err != nil {
      82 return shim.Error(err.Error())
      83 }
      84
      85 byteArray,err = stub.GetState("just-existing")
      86 if err != nil {
      87 return shim.Error(err.Error())
      88 }
      89 if byteArray == nil {
      90 fmt.Println("success but no data ")
      91 }
      92 fmt.Println(string(byteArray))
      93 }

      If we run this Invoke only one time in unit test, we will get "just-data".

      if we run this Invoke only one time in real Fabric deployment, we will get "success but no data".

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mochechan 謨澤 詹
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: