     blocks.data.PersistentBytes))
 
 
+(defn random-block
+  "Creates a new block with random content at most `max-size` bytes long."
+  [max-size]
+  (block/read!
+    (bytes/random-bytes (inc (rand-int max-size)))
+    (rand-nth (keys digest/functions))))
+
+
+(defn generate-blocks!
+  "Generates some test blocks and returns a map of the ids to the blocks."
+  [n max-size]
+  (->> (repeatedly #(random-block max-size))
+       (take n)
+       (map (juxt :id identity))
+       (into (sorted-map))))
+
+
+(defn populate-blocks!
+  "Generates random blocks and puts them into the given store. Returns a map
+  of multihash ids to blocks."
+  [store & {:keys [n max-size], :or {n 10, max-size 1024}}]
+  (let [blocks (generate-blocks! n max-size)]
+    (block/put-batch! store (vals blocks))
+    blocks))
+
+
+
 ;; ## Generators
 
 (defn random-blocks

  "Suite of tests to verify that a given block store implementation conforms to
  the spec."
  (:require
    [alphabase.core :as abc]
    [blocks.core :as block]
    [blocks.store.util :as util]
    [clojure.java.io :as io]

(defn test-batch-ops
  "Tests the batch functionality of a store."
  [store]
  (let [blocks (vals (generate-blocks! 10 512))]
    (testing "put-batch!"
      (let [block-batch (block/put-batch! store blocks)]
        (is (= (count blocks) (count block-batch)))
