DJDNS / go-deje

Golang library for DEJE Next, a protocol/technology for decentralized document hosting and concurrent editing.
GNU Lesser General Public License v2.1
8 stars 0 forks source link

State test sometimes randomly fails #30

Closed MaddieM4 closed 10 years ago

MaddieM4 commented 10 years ago

The test function TestSliceContainer_RemoveChild sometimes fails as follows:

--- FAIL: TestSliceContainer_RemoveChild (0.00 seconds)
slice_test.go:129: Expected []interface {}{"crazy", "world"}, got []interface {}{"world"}

It doesn't do this consistently. In fact it's pretty infrequent. But there's clearly something sketchy going on in there.

MaddieM4 commented 10 years ago

Internally, SliceContainers are implemented as a map. When we delete an element N, we need to decrement the indexes of all elements > N. Currently we iterate over the map in an undefined order, which can result in clobbering.

The new test function TestSliceContainer_RemoveChild_Many should be very self-explanatory in how and why it works.