MCPcopy Create free account
hub / github.com/DOSNetwork/core / TestRecoverPriPoly

Function TestRecoverPriPoly

share/poly_test.go:274–295  ·  view source on GitHub ↗
(test *testing.T)

Source from the content-addressed store, hash-verified

272}
273
274func TestRecoverPriPoly(test *testing.T) {
275 n := 10
276 t := n/2 + 1
277 a := NewPriPoly(suite, t, nil, suite.RandomStream())
278
279 shares := a.Shares(n)
280 reverses := make([]*PriShare, len(shares))
281 l := len(shares) - 1
282 for i := range shares {
283 reverses[l-i] = shares[i]
284 }
285 recovered, err := RecoverPriPoly(suite, shares, t, n)
286 assert.Nil(test, err)
287
288 reverseRecovered, err := RecoverPriPoly(suite, reverses, t, n)
289 assert.Nil(test, err)
290
291 for i := 0; i < t; i++ {
292 assert.Equal(test, recovered.Eval(i).V.String(), a.Eval(i).V.String())
293 assert.Equal(test, reverseRecovered.Eval(i).V.String(), a.Eval(i).V.String())
294 }
295}
296
297func TestPriPolyCoefficients(test *testing.T) {
298 n := 10

Callers

nothing calls this directly

Calls 7

SharesMethod · 0.95
EvalMethod · 0.95
NewPriPolyFunction · 0.85
RecoverPriPolyFunction · 0.85
RandomStreamMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected