Cotton code
31 lines · 966 B · GoRaw
package mainimport (	"testing"	"go.mau.fi/whatsmeow/store"	waLog "go.mau.fi/whatsmeow/util/log")// RULE: a number that just paired is served by a fresh client over its stored// device, never by the client that paired it — that one lives on the pairing's// context, which ends with the pairing, and a session left on it goes quiet// until WhatsApp logs the device out (27 Oct 2026).func TestAPairedNumberIsServedByAFreshClient(t *testing.T) {	h := NewHub(nil, nil, waLog.Noop)	device := &store.Device{}	pairing := h.newClient(device)	linked := h.adopt("919800000000@s.whatsapp.net", device)	if linked == pairing {		t.Fatal("the pairing client was kept as the session")	}	h.mu.Lock()	s := h.sessions["919800000000@s.whatsapp.net"]	h.mu.Unlock()	if s == nil || s.cli != linked {		t.Fatal("the fresh client is not the number's session")	}	if s.state != "connecting" {		t.Fatalf("a just-adopted session is %q, not connecting", s.state)	}}