Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
1.5 kB · 23 lines
Go
at master
123456789101112131415161718192021222324package algorithms_test
import ( "testing"
"provenance/internal/domain" "provenance/internal/trust" "provenance/internal/trust/algorithms" "provenance/internal/trust/trusttest")
func TestSoftPaths(t *testing.T) { for _, algorithm := range []trust.Algorithm{algorithms.Optimistic{}, algorithms.ShortestPath{}} { t.Run(algorithm.Describe().Name, func(t *testing.T) { trusttest.Run(t, algorithm, []trusttest.Scenario{ {Name: "follow", Source: "alice", Target: "bob", Edges: []trusttest.Edge{{From: "alice", To: "bob", Score: domain.FollowScore, Source: domain.FollowCollection}}, Want: calculated(.5, "alice", "bob")}, {Name: "soft block is not a hard block", Source: "alice", Target: "bob", Edges: []trusttest.Edge{{From: "alice", To: "bob", Score: domain.SoftBlockScore, Source: domain.BlockCollection}}, Want: calculated(-.5, "alice", "bob")}, {Name: "follow chain", Source: "alice", Target: "bob", Edges: []trusttest.Edge{{From: "alice", To: "carol", Score: domain.FollowScore, Source: domain.FollowCollection}, {From: "carol", To: "bob", Score: domain.FollowScore, Source: domain.FollowCollection}}, Want: calculated(.4, "alice", "carol", "bob")}, {Name: "soft bottleneck", Source: "alice", Target: "bob", Edges: []trusttest.Edge{{From: "alice", To: "carol", Score: 2}, {From: "carol", To: "bob", Score: domain.SoftBlockScore, Source: domain.BlockCollection}}, Want: calculated(-.6, "alice", "carol", "bob")}, }) }) }}