func (s *XLSuite) doTestSHA(c *C, rng *xr.PRNG, whichSHA int) { var hash, fHash []byte var sHash string // name guaranteed to be unique length, pathToFile := rng.NextDataFile("tmp", 1024, 256) data, err := ioutil.ReadFile(pathToFile) c.Assert(err, IsNil) c.Assert(len(data), Equals, length) parts := strings.Split(pathToFile, "/") c.Assert(len(parts), Equals, 2) fileName := parts[1] switch whichSHA { case xu.USING_SHA1: sha := sha1.New() sha.Write(data) hash = sha.Sum(nil) fHash, err = SHA1File(pathToFile) case xu.USING_SHA2: sha := sha256.New() sha.Write(data) hash = sha.Sum(nil) fHash, err = SHA2File(pathToFile) case xu.USING_SHA3: sha := sha3.New256() sha.Write(data) hash = sha.Sum(nil) fHash, err = SHA3File(pathToFile) // XXX DEFAULT = ERROR } c.Assert(err, IsNil) c.Assert(bytes.Equal(hash, fHash), Equals, true) ml, err := CreateMerkleLeafFromFileSystem(pathToFile, fileName, whichSHA) c.Assert(err, IsNil) c.Assert(ml.Name(), Equals, fileName) c.Assert(bytes.Equal(ml.GetHash(), hash), Equals, true) c.Assert(ml.WhichSHA(), Equals, whichSHA) // TODO: test ToString _ = sHash // TODO }