Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
950 B · 29 lines
Go
at master
123456789101112131415161718192021222324252627282930package appview
import ( "context" "errors" "path/filepath" "provenance/internal/domain" "provenance/internal/storage" "provenance/internal/trust" "testing")
func TestCustomDepthCap(t *testing.T) { ctx := context.Background() store, err := storage.Open(filepath.Join(t.TempDir(), "depth.db")) if err != nil { t.Fatal(err) } defer store.Close() for _, result := range []trust.Result{{Path: make([]string, trust.MaxDepth+2)}, {PathScores: make([]trust.PathScore, trust.MaxDepth+2)}} { algorithm := testAlgorithm{calculate: func(context.Context, []domain.Vouch, string, string, trust.Limits) (trust.Result, error) { return result, nil }} service := NewWithAlgorithm(store, &repository{}, trust.Limits{States: 100, Edges: 100, Penalty: .1}, algorithm) if _, err := service.Reputation(ctx, alice, bob, "", domain.Default); !errors.Is(err, trust.ErrLimit) { t.Fatalf("custom algorithm bypassed depth cap: %v", err) } }}