Unverified Commit 90ac2354 authored by meskio's avatar meskio 🏔️
Browse files

internal: test bridges with PT are not vanilla

parent 66c7c534
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
package internal

import (
	"slices"
	"testing"

	"gitlab.torproject.org/tpo/anti-censorship/rdsys/pkg/core"
@@ -245,3 +246,26 @@ func TestIPVersion(t *testing.T) {
		t.Errorf("Not all IPv4 bridges have their IPv6 counterpart: %d %d", len(ipv4), len(ipv6))
	}
}

func TestBridgeWithPTnotAsVanilla(t *testing.T) {
	rcol := core.NewBackendResources(&collectionConfig)
	reloadBridgeDescriptors(&testCfg, rcol, nil)

	for distName := range testCfg.Backend.DistProportions {
		vanilla := rcol.Get(distName, "vanilla", core.IPAny)
		obfs4 := rcol.Get(distName, "obfs4", core.IPAny)
		for _, r := range obfs4.Working {
			transport, ok := r.(*resources.Transport)
			if !ok {
				t.Fatalf("obfs4 bridge is not Tranposrt: %s", r.String())
			}
			exist := slices.ContainsFunc(vanilla.Working, func(vr core.Resource) bool {
				bridge := vr.(*resources.Bridge)
				return transport.Fingerprint == bridge.Fingerprint
			})
			if exist {
				t.Errorf("%s obfs4 bridge exist also as vanilla", transport.Fingerprint)
			}
		}
	}
}