mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 17:22:18 +00:00
97905c3e79
* Different files * Preston's feedback
47 lines
1.0 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|