Skip to content

Commit

Permalink
Merge pull request asynkron#682 from anykno/fix-gossip-state
Browse files Browse the repository at this point in the history
fix: GossipState setKey did not save new value correctly
  • Loading branch information
rogeralsing authored Jun 16, 2022
2 parents f567b54 + 5c72086 commit afd2d97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cluster/gossip_state_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func setKey(state *GossipState, key string, value proto.Message, memberID string
sequenceNo++
entry.SequenceNumber = sequenceNo

a, _ := anypb.New(entry.Value)
a, _ := anypb.New(value)
entry.Value = a

return sequenceNo
Expand Down
28 changes: 24 additions & 4 deletions cluster/informer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ func TestInformer_GetState(t *testing.T) {
t.Error("not ok")
}

var s2 *MemberHeartbeat
_ = x.UnmarshalTo(s2)
var s2 MemberHeartbeat
err := x.UnmarshalTo(&s2)
if err != nil {
t.Error("unmarshal state error")
}
}

func TestInformer_ReceiveState(t *testing.T) {
Expand Down Expand Up @@ -84,18 +87,35 @@ func TestInformer_ReceiveState(t *testing.T) {

var ok bool

_, ok = m["member1"]
m1, ok := m["member1"]

if !ok {
t.Error("member1 is missing")
}

var s1 MemberHeartbeat

err := m1.UnmarshalTo(&s1)

if err != nil {
t.Error("unmarshal member1 state error")
}

// ensure we see member2 after receiving state
_, ok = m["member2"]
m2, ok := m["member2"]

if !ok {
t.Error("member2 is missing")
}

var s2 MemberHeartbeat

err = m2.UnmarshalTo(&s2)

if err != nil {
t.Error("unmarshal member2 state error")
}

}

func TestInformer_SendState(t *testing.T) {
Expand Down

0 comments on commit afd2d97

Please sign in to comment.