Skip to content
Snippets Groups Projects
Commit 837c2289 authored by Jonathan Levi's avatar Jonathan Levi Committed by Gerrit Code Review
Browse files

Merge "event name can not be nil string"

parents 5bf0524c 1374d9ea
Branches
Tags
No related merge requests found
......@@ -904,6 +904,9 @@ func insertRowInternal(stub ChaincodeStubInterface, tableName string, row Row, u
// SetEvent saves the event to be sent when a transaction is made part of a block
func (stub *ChaincodeStub) SetEvent(name string, payload []byte) error {
if name == "" {
return errors.New("Event name can not be nil string.")
}
stub.chaincodeEvent = &pb.ChaincodeEvent{EventName: name, Payload: payload}
return nil
}
......
......@@ -134,3 +134,11 @@ func TestChaincodeLogging(t *testing.T) {
t.Errorf("'bar' should be enabled for LogCritical")
}
}
func TestNilEventName(t *testing.T) {
stub := ChaincodeStub{}
if err := stub.SetEvent("", []byte("event payload")); err == nil {
t.Error("Event name can not be nil string.")
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment