func (b *Buy) Validate(s *ddtxn.Store, nitr int) bool { good := true zero_cnt := 0 for j := 0; j < b.nproducts; j++ { var x int32 k := ddtxn.ProductKey(j) v, err := s.Get(k) if err != nil { if b.validate[j] != 0 { fmt.Printf("Validating key %v failed; store: none should have: %v\n", k, b.validate[j]) good = false } continue } x = v.Value().(int32) if x != b.validate[j] { fmt.Printf("Validating key %v failed; store: %v should have: %v\n", k, x, b.validate[j]) good = false } if x == 0 { zero_cnt++ } } if zero_cnt == b.nproducts && nitr > 10 { fmt.Printf("Bad: all zeroes!\n") dlog.Printf("Bad: all zeroes!\n") good = false } return good }
func (b *Rubis) Validate(s *ddtxn.Store, nitr int) bool { good := true zero_cnt := 0 for k, rat := range b.ratings { key := ddtxn.RatingKey(k) v, err := s.Get(key) if err != nil { fmt.Printf("Validating key %v failed; store: doesn't have rating for user %v: %v\n", key, k, err) good = false continue } r := v.Value().(int32) if r != rat { fmt.Printf("Validating key %v failed; store: has different rating for user %v (%v vs. %v): %v\n", key, k, rat, r, err) good = false continue } } for i := 0; i < b.nproducts; i++ { j := b.products[i] var x int32 k := ddtxn.MaxBidKey(j) v, err := s.Get(k) if err != nil { if b.maxes[i] != 0 { fmt.Printf("Validating key %v failed; store: none should have: %v\n", k, b.maxes[i]) good = false } continue } x = v.Value().(int32) if x != b.maxes[i] { fmt.Printf("Validating key %v failed; store: %v should have: %v\n", k, x, b.maxes[i]) good = false } if x == 0 { dlog.Printf("Saying x is zero %v %v\n", x, zero_cnt) zero_cnt++ } k = ddtxn.NumBidsKey(j) v, err = s.Get(k) if err != nil { if b.maxes[i] != 0 { fmt.Printf("Validating key %v failed for max bid; store: none should have: %v\n", k, b.num_bids[i]) good = false } continue } x = v.Value().(int32) if x != b.num_bids[i] { fmt.Printf("Validating key %v failed for number of bids; store: %v should have: %v\n", k, x, b.num_bids[i]) good = false } if x == 0 { dlog.Printf("Saying x is zero %v %v\n", x, zero_cnt) zero_cnt++ } } if zero_cnt == 2*b.nproducts && nitr > 10 { fmt.Printf("Bad: all zeroes!\n") dlog.Printf("Bad: all zeroes!\n") good = false } if good { dlog.Printf("Validate succeeded\n") } return good }