Пример #1
0
func addKeyVersions(vb *common.VbKeyVersions, kvs []*common.KeyVersions, seqno uint64, nMuts int) uint64 {
	ln := len(kvs)
	for i := 0; i < nMuts; i++ {
		newkv := *kvs[i%ln]
		newkv.Seqno = seqno
		vb.AddKeyVersions(&newkv)
		seqno++
	}
	return seqno
}
Пример #2
0
func testKeyVersions(t *testing.T, vb *common.VbKeyVersions) {
	var data []byte
	var err error
	var payload interface{}

	vbsRef := []*common.VbKeyVersions{vb}
	if data, err = protobufEncode(vbsRef); err != nil {
		t.Fatal(err)
	}
	if payload, err = protobufDecode(data); err != nil {
		t.Fatal(err)
	}

	val, ok := payload.([]*protobuf.VbKeyVersions)
	if ok == false {
		t.Fatal("expected slice of reference to KeyVersions object")
	}
	vbs := protobuf2VbKeyVersions(val)
	for i, vb := range vbsRef {
		if vb.Equal(vbs[i]) == false {
			t.Fatal("failed protobuf encoding")
		}
	}
}