mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-27 17:15:18 +00:00
32 lines
552 B
Go
32 lines
552 B
Go
|
package testing
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"errors"
|
||
|
)
|
||
|
|
||
|
type TestValidator struct{}
|
||
|
|
||
|
func (TestValidator) Select(_ string, bs [][]byte) (int, error) {
|
||
|
index := -1
|
||
|
for i, b := range bs {
|
||
|
if bytes.Equal(b, []byte("newer")) {
|
||
|
index = i
|
||
|
} else if bytes.Equal(b, []byte("valid")) {
|
||
|
if index == -1 {
|
||
|
index = i
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if index == -1 {
|
||
|
return -1, errors.New("no rec found")
|
||
|
}
|
||
|
return index, nil
|
||
|
}
|
||
|
func (TestValidator) Validate(_ string, b []byte) error {
|
||
|
if bytes.Equal(b, []byte("expired")) {
|
||
|
return errors.New("expired")
|
||
|
}
|
||
|
return nil
|
||
|
}
|