Example #1
0
func NewPopulatedMVCCMetadata(r randyMvcc, easy bool) *MVCCMetadata {
	this := &MVCCMetadata{}
	if r.Intn(10) != 0 {
		this.Txn = cockroach_roachpb1.NewPopulatedTxnMeta(r, easy)
	}
	v1 := cockroach_roachpb1.NewPopulatedTimestamp(r, easy)
	this.Timestamp = *v1
	this.Deleted = bool(bool(r.Intn(2) == 0))
	this.KeyBytes = int64(r.Int63())
	if r.Intn(2) == 0 {
		this.KeyBytes *= -1
	}
	this.ValBytes = int64(r.Int63())
	if r.Intn(2) == 0 {
		this.ValBytes *= -1
	}
	if r.Intn(10) != 0 {
		v2 := r.Intn(100)
		this.RawBytes = make([]byte, v2)
		for i := 0; i < v2; i++ {
			this.RawBytes[i] = byte(r.Intn(256))
		}
	}
	if r.Intn(10) != 0 {
		this.MergeTimestamp = cockroach_roachpb1.NewPopulatedTimestamp(r, easy)
	}
	if !easy && r.Intn(10) != 0 {
	}
	return this
}
		populatedConstructor: func(r *rand.Rand) proto.Message { return roachpb.NewPopulatedAbortCacheEntry(r, false) },
		emptySum:             11932598136014321867,
		populatedSum:         5118321872981034391,
	},
	reflect.TypeOf(&roachpb.Lease{}): {
		populatedConstructor: func(r *rand.Rand) proto.Message { return roachpb.NewPopulatedLease(r, false) },
		emptySum:             10006158318270644799,
		populatedSum:         717371977055084394,
	},
	reflect.TypeOf(&roachpb.RaftTruncatedState{}): {
		populatedConstructor: func(r *rand.Rand) proto.Message { return roachpb.NewPopulatedRaftTruncatedState(r, false) },
		emptySum:             5531676819244041709,
		populatedSum:         14781226418259198098,
	},
	reflect.TypeOf(&roachpb.Timestamp{}): {
		populatedConstructor: func(r *rand.Rand) proto.Message { return roachpb.NewPopulatedTimestamp(r, false) },
		emptySum:             5531676819244041709,
		populatedSum:         10735653246768912584,
	},
	reflect.TypeOf(&roachpb.Transaction{}): {
		populatedConstructor: func(r *rand.Rand) proto.Message { return roachpb.NewPopulatedTransaction(r, false) },
		emptySum:             1224176153607079475,
		populatedSum:         154941000985571253,
	},
}

func TestBelowRaftProtos(t *testing.T) {
	defer leaktest.AfterTest(t)()

	// Enable the additional checks in TestMain. NB: running this test by itself
	// will fail those extra checks - such failures are safe to ignore, so long