func (s *Server) MustCreateEvent(t *testing.T, room *ServerRoom, ev b.Event) *gomatrixserverlib.Event {
	t.Helper()
	content, err := json.Marshal(ev.Content)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to marshal event content %s - %+v", err, ev.Content)
	}
	var unsigned []byte
	if ev.Unsigned != nil {
		unsigned, err = json.Marshal(ev.Unsigned)
		if err != nil {
			t.Fatalf("MustCreateEvent: failed to marshal event unsigned: %s - %+v", err, ev.Unsigned)
		}
	}
	eb := gomatrixserverlib.EventBuilder{
		Sender:     ev.Sender,
		Depth:      int64(room.Depth + 1), // depth starts at 1
		Type:       ev.Type,
		StateKey:   ev.StateKey,
		Content:    content,
		RoomID:     room.RoomID,
		PrevEvents: room.ForwardExtremities,
		Unsigned:   unsigned,
	}
	stateNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(&eb)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to work out auth_events : %s", err)
	}
	eb.AuthEvents = room.AuthEvents(stateNeeded)
	signedEvent, err := eb.Build(time.Now(), gomatrixserverlib.ServerName(s.ServerName), s.KeyID, s.Priv, room.Version)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to sign event: %s", err)
	}
	return signedEvent
}
// MustCreateEvent will create and sign a new latest event for the given room.
// It does not insert this event into the room however. See ServerRoom.AddEvent for that.
MustCreateEvent will create and sign a new latest event for the given room.
It does not insert this event into the room however. See ServerRoom.AddEvent for that.
// MustCreateEvent will create and sign a new latest event for the given room . // It does not insert this event into the room however . See ServerRoom . AddEvent for that .
func (s *Server) MustCreateEvent(t *testing.T, room *ServerRoom, ev b.Event) *gomatrixserverlib.Event {
	t.Helper()
	content, err := json.Marshal(ev.Content)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to marshal event content %s - %+v", err, ev.Content)
	}
	var unsigned []byte
	if ev.Unsigned != nil {
		unsigned, err = json.Marshal(ev.Unsigned)
		if err != nil {
			t.Fatalf("MustCreateEvent: failed to marshal event unsigned: %s - %+v", err, ev.Unsigned)
		}
	}
	eb := gomatrixserverlib.EventBuilder{
		Sender:     ev.Sender,
		Depth:      int64(room.Depth + 1), 
		Type:       ev.Type,
		StateKey:   ev.StateKey,
		Content:    content,
		RoomID:     room.RoomID,
		PrevEvents: room.ForwardExtremities,
		Unsigned:   unsigned,
	}
	stateNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(&eb)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to work out auth_events : %s", err)
	}
	eb.AuthEvents = room.AuthEvents(stateNeeded)
	signedEvent, err := eb.Build(time.Now(), gomatrixserverlib.ServerName(s.ServerName), s.KeyID, s.Priv, room.Version)
	if err != nil {
		t.Fatalf("MustCreateEvent: failed to sign event: %s", err)
	}
	return signedEvent
}
func ( s * Server ) MustCreateEvent ( t * testing . T , room * ServerRoom , ev b . Event ) * gomatrixserverlib . Event { t . Helper ( ) content , err := json . Marshal ( ev . Content ) if err != nil { t . Fatalf ( " " , err , ev . Content ) } var unsigned [ ] byte if ev . Unsigned != nil { unsigned , err = json . Marshal ( ev . Unsigned ) if err != nil { t . Fatalf ( " " , err , ev . Unsigned ) } } eb := gomatrixserverlib . EventBuilder { Sender : ev . Sender , Depth : int64 ( room . Depth + 1 ) , Type : ev . Type , StateKey : ev . StateKey , Content : content , RoomID : room . RoomID , PrevEvents : room . ForwardExtremities , Unsigned : unsigned , } stateNeeded , err := gomatrixserverlib . StateNeededForEventBuilder ( & eb ) if err != nil { t . Fatalf ( " " , err ) } eb . AuthEvents = room . AuthEvents ( stateNeeded ) signedEvent , err := eb . Build ( time . Now ( ) , gomatrixserverlib . ServerName ( s . ServerName ) , s . KeyID , s . Priv , room . Version ) if err != nil { t . Fatalf ( " " , err ) } return signedEvent }
MustCreateEvent will create and sign a new latest event for the given room.
MustCreateEvent will create and sign a new latest event for the given room .
// depth starts at 1