MCPcopy Create free account
hub / github.com/evilsocket/sum / TestLoadOracles

Function TestLoadOracles

storage/oracles_test.go:84–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestLoadOracles(t *testing.T) {
85 setupOracles(t, true, false, false)
86 defer teardownOracles(t)
87
88 oracles, err := LoadOracles(testFolder)
89 if err != nil {
90 t.Fatal(err)
91 } else if oracles == nil {
92 t.Fatal("expected valid oracles storage")
93 } else if oracles.Size() != testOracles {
94 t.Fatalf("expected %d oracles, %d found", testOracles, oracles.Size())
95 }
96
97 oracles.ForEach(func(m proto.Message) error {
98 oracle := m.(*pb.Oracle)
99 // id was updated while saving the oracle
100 if oracle.Id = testOracle.Id; !sameOracle(*oracle, testOracle) {
101 t.Fatalf("oracles should be the same here")
102 }
103 return nil
104 })
105}
106
107func TestLoadOraclesWithCorruptedData(t *testing.T) {
108 setupOracles(t, true, true, false)

Callers

nothing calls this directly

Calls 6

setupOraclesFunction · 0.85
teardownOraclesFunction · 0.85
LoadOraclesFunction · 0.85
SizeMethod · 0.80
ForEachMethod · 0.80
sameOracleFunction · 0.70

Tested by

no test coverage detected