discovery_test.go raw

   1  package discovery
   2  
   3  import "testing"
   4  
   5  // TestTheSeedComesFirstAndNothingIsRepeated: the relay the caller knows works is tried first, and
   6  // an advertisement that names it again (with a different spelling) does not add a second copy.
   7  func TestTheSeedComesFirstAndNothingIsRepeated(t *testing.T) {
   8  	got := mergeRelays(
   9  		[]string{"wss://relay.one/", "wss://relay.two"},
  10  		[]string{"wss://relay.two/", "wss://relay.three", "wss://relay.one"},
  11  	)
  12  
  13  	want := []string{"wss://relay.one", "wss://relay.two", "wss://relay.three"}
  14  
  15  	if len(got) != len(want) {
  16  		t.Fatalf("relays = %v, want %v", got, want)
  17  	}
  18  
  19  	for i := range want {
  20  		if got[i] != want[i] {
  21  			t.Fatalf("relays = %v, want %v", got, want)
  22  		}
  23  	}
  24  }
  25