Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
1.9 kB · 26 lines
Go
at master
123456789101112131415161718192021222324252627package algorithms_test
import ( "testing"
"provenance/internal/domain" "provenance/internal/reputation/algorithms" "provenance/internal/reputation/reputationtest" "provenance/internal/trust" trustalg "provenance/internal/trust/algorithms" "provenance/internal/trust/trusttest")
func TestSoftReputation(t *testing.T) { for _, algorithm := range []trust.Algorithm{trustalg.Optimistic{}, trustalg.ShortestPath{}} { t.Run(algorithm.Describe().Name, func(t *testing.T) { reputationtest.Run(t, algorithms.DirectSum{}, algorithm, []reputationtest.Scenario{ {Name: "follow from source", Source: "alice", Target: "bob", Threshold: 1, Edges: []trusttest.Edge{{From: "alice", To: "bob", Score: domain.FollowScore, Source: domain.FollowCollection}}, Score: .5, MeanScore: .5}, {Name: "soft block contributes", Source: "alice", Target: "bob", Threshold: 1, Edges: []trusttest.Edge{{From: "alice", To: "bob", Score: domain.SoftBlockScore, Source: domain.BlockCollection}}, Score: -.5, MeanScore: -.5}, {Name: "soft authority qualifies at lower threshold", Source: "alice", Target: "bob", Threshold: .5, Edges: []trusttest.Edge{{From: "alice", To: "carol", Score: domain.FollowScore, Source: domain.FollowCollection}, {From: "carol", To: "bob", Score: 2}}, Score: 2, MeanScore: 2}, {Name: "soft authority fails default threshold", Source: "alice", Target: "bob", Threshold: 1, Edges: []trusttest.Edge{{From: "alice", To: "carol", Score: domain.FollowScore, Source: domain.FollowCollection}, {From: "carol", To: "bob", Score: 2}}}, {Name: "mixed fractional mean", Source: "alice", Target: "bob", Threshold: 1, Edges: []trusttest.Edge{{From: "alice", To: "carol", Score: 2}, {From: "carol", To: "bob", Score: domain.SoftBlockScore, Source: domain.BlockCollection}, {From: "alice", To: "bob", Score: domain.FollowScore, Source: domain.FollowCollection}}}, }) }) }}