Make erasure Encode and Decode atomic to avoid races

This commit is contained in:
Harshavardhana
2015-10-06 22:17:52 -07:00
parent e6d935731a
commit ab5ea997ab
3 changed files with 13 additions and 28 deletions

View File

@@ -42,7 +42,8 @@ func corruptChunks(chunks [][]byte, errorIndex []int) [][]byte {
}
func (s *MySuite) TestEncodeDecodeFailure(c *C) {
ep, _ := ValidateParams(k, m)
ep, err := ValidateParams(k, m)
c.Assert(err, IsNil)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
@@ -58,7 +59,8 @@ func (s *MySuite) TestEncodeDecodeFailure(c *C) {
}
func (s *MySuite) TestEncodeDecodeSuccess(c *C) {
ep, _ := ValidateParams(k, m)
ep, err := ValidateParams(k, m)
c.Assert(err, IsNil)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
@@ -76,29 +78,3 @@ func (s *MySuite) TestEncodeDecodeSuccess(c *C) {
c.Fatalf("Recovered data mismatches with original data")
}
}
/*
func (s *MySuite) TestEncodeDecodeSuccessBuffer(c *C) {
ep, _ := ValidateParams(k, m)
tmpBuffer := new(bytes.Buffer)
for i := 0; i < 1024*1024; i++ {
tmpBuffer.Write([]byte("Hello world, hello world"))
}
e := NewErasure(ep)
chunks, err := e.Encode(tmpBuffer.Bytes())
c.Assert(err, IsNil)
errorIndex := []int{0, 3, 5, 9, 13}
chunks = corruptChunks(chunks, errorIndex)
recoveredData, err := e.Decode(chunks, len(tmpBuffer.Bytes()))
c.Assert(err, IsNil)
if !bytes.Equal(tmpBuffer.Bytes(), recoveredData) {
c.Fatalf("Recovered data mismatches with original data")
}
}
*/