prysm-pulse/beacon-chain/operations/recent_att_multi_map_test.go
terence tsao 97905c3e79
Refactor operation service.go into smaller files (#3808)
* Different files

* Preston's feedback
2019-10-21 09:37:50 -07:00

47 lines
1.0 KiB
Go

package operations
import (
"fmt"
"testing"
"github.com/prysmaticlabs/go-bitfield"
)
func TestRecentAttestationMultiMap_Contains(t *testing.T) {
root := [32]byte{'F', 'O', 'O', 'B', 'A', 'R'}
tests := []struct {
inputs []bitfield.Bitlist
contains bitfield.Bitlist
want bool
}{
{
inputs: []bitfield.Bitlist{
bitfield.Bitlist{0b00000001, 0b1},
bitfield.Bitlist{0b00000010, 0b1},
},
contains: bitfield.Bitlist{0b00000001, 0b1},
want: true,
}, {
inputs: []bitfield.Bitlist{
bitfield.Bitlist{0b00111000, 0b1},
bitfield.Bitlist{0b00000011, 0b1},
},
contains: bitfield.Bitlist{0b00000100, 0b1},
want: false,
},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("case_%d", i), func(t *testing.T) {
mm := newRecentAttestationMultiMap()
for _, input := range tt.inputs {
mm.Insert(0, root, input)
}
if mm.Contains(root, tt.contains) != tt.want {
t.Errorf("mm.Contains(root, tt.contains) = %v, wanted %v", mm.Contains(root, tt.contains), tt.want)
}
})
}
}