anchor.diff:          ok = ?pending:register(pending())
       end),
       etorrent_utils:wait(Pid),
  -    ?assertMatch({ok, [{0, 0, 1}]}, ?chunkstate:request(progress(), Has, 1)),
  -    ?assertMatch({ok, [{0, 1, 1}]}, ?chunkstate:request(progress(), Has, 1)).
  +    ?assertMatch({ok, [{0, 0, 1}]}, ?chunkstate:request(1, Has, progress())),
  +    ?assertMatch({ok, [{0, 1, 1}]}, ?chunkstate:request(1, Has, progress())).
   
   marked_stored_not_dropped_case() ->
       Has = etorrent_pieceset:from_list([0], 3),
       Pid = spawn_link(fun() ->
  -        true = ?pending:register(pending()),
  -        {ok, [{0, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -        ok = ?progress:mark_stored(testid(), 0, 0, 1)
  +        ok = ?pending:register(pending()),
  +        {ok, [{0, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +        ok = ?chunkstate:stored(0, 0, 1, self(), progress())
       end),
       etorrent_utils:wait(Pid),
  -    ?assertMatch({ok, [{0, 1, 1}]}, ?chunkstate:request(progress(), Has, 1)).
  -
  -mark_fetched_noop_case() ->
  -    Has = etorrent_pieceset:from_list([0], 3),
  -    Pid = spawn_link(fun() ->
  -        true = ?pending:register(testid()),
  -        {ok, [{0, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -        {ok, true} = ?progress:mark_fetched(testid(), 0, 0, 1)
  -    end),
  -    etorrent_utils:wait(Pid),
  -    timer:sleep(1000),
  -    ?assertMatch({ok, [{0, 0, 1}]}, ?chunkstate:request(progress(), Has, 1)).
  -
  +    ?assertMatch({ok, [{0, 1, 1}]}, ?chunkstate:request(1, Has, progress())).
   
   mark_valid_not_stored_case() ->
  -    Ret = ?progress:mark_valid(testid(), 0),
  -    ?assertEqual({error, not_stored}, Ret).
  +    Ret = ?piecestate:valid(0, progress()),
  +    ?assertEqual(ok, Ret).
   
   mark_valid_stored_case() ->
       Has = etorrent_pieceset:from_list([0,1], 3),
  -    {ok, [{0, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{0, 1, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    ok  = ?progress:mark_stored(testid(), 0, 0, 1),
  -    ok  = ?progress:mark_stored(testid(), 0, 1, 1),
  -    ?assertEqual(ok, ?progress:mark_valid(testid(), 0)),
  -    ?assertEqual({error, valid}, ?progress:mark_valid(testid(), 0)).
  +    {ok, [{0, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{0, 1, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    ok  = ?chunkstate:stored(0, 0, 1, self(), progress()),
  +    ok  = ?chunkstate:stored(0, 1, 1, self(), progress()),
  +    ?assertEqual(ok, ?piecestate:valid(0, progress())),
  +    ?assertEqual(ok, ?piecestate:valid(0, progress())).
   
   all_stored_marks_stored_case() ->
       Has = etorrent_pieceset:from_list([0,1], 3),
  -    {ok, [{0, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{0, 1, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    ?assertMatch({ok, [{1, 0, 1}]}, ?chunkstate:request(progress(), Has, 1)),
  -    ?assertMatch({ok, [{1, 1, 1}]}, ?chunkstate:request(progress(), Has, 1)).
  +    {ok, [{0, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{0, 1, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    ?assertMatch({ok, [{1, 0, 1}]}, ?chunkstate:request(1, Has, progress())),
  +    ?assertMatch({ok, [{1, 1, 1}]}, ?chunkstate:request(1, Has, progress())).
   
   get_all_request_case() ->
       Has = etorrent_pieceset:from_list([0,1,2], 3),
  -    {ok, [{0, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{0, 1, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{1, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{1, 1, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{2, 0, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    {ok, [{2, 1, 1}]} = ?chunkstate:request(progress(), Has, 1),
  -    ?assertEqual({ok, assigned}, ?chunkstate:request(progress(), Has, 1)).
  +    {ok, [{0, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{0, 1, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{1, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{1, 1, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{2, 0, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    {ok, [{2, 1, 1}]} = ?chunkstate:request(1, Has, progress()),
  +    ?assertEqual({ok, assigned}, ?chunkstate:request(1, Has, progress())).
   
   unassigned_to_assigned_case() ->
       Has = etorrent_pieceset:from_list([0], 3),
  -    {ok, [{0,0,1}, {0,1,1}]} = ?chunkstate:request(progress(), Has, 2),
  -    ?assertEqual({ok, assigned}, ?chunkstate:request(progress(), Has, 1)).
  +    {ok, [{0,0,1}, {0,1,1}]} = ?chunkstate:request(2, Has, progress()),
  +    ?assertEqual({ok, assigned}, ?chunkstate:request(1, Has, progress())).
   
   -endif.
  
positive.code:      ?_test(drop_none_on_exit_case()),
       ?_test(drop_all_on_exit_case()),
       ?_test(marked_stored_not_dropped_case()),
       ?_test(mark_fetched_noop_case()),
       ?_test(mark_valid_not_stored_case()),
       ?_test(mark_valid_stored_case()),
       ?_test(all_stored_marks_stored_case()),
  
negative.code:     {ok, PPid} = ?pending:start_link(testid()),
      {ok, CPid} = ?progress:start_link(testid(), 1, Valid, [{0, 2}, {1, 2}, {2, 2}], self()),
      ok = ?pending:register(PPid),
      ok = ?pending:receiver(CPid, PPid),
      {Time, PPid, SPid, CPid}.
  
  scarcity() -> ?scarcity:lookup_server(testid()).
  