@@ -979,17 +979,15 @@ async def do_download(set_state):
979979 raise fails .pop (0 )
980980 downloads .append (set_state )
981981 return (
982- # this data is CBOR for {"version": 1, "statements": []}
983- lambda : BytesIO (b"\xa2 gversion\x01 jstatements\x80 " ),
982+ lambda : BytesIO (statements_to_snapshot ([])),
984983 [], # no event-streams
985984 )
986985
987986 return do_download
988987
989988 clock = MemoryReactorClockResolver ()
990989 store = self .useFixture (TemporaryVoucherStore (aware_now , get_config )).store
991- recoverer = StatefulRecoverer ()
992- factory = RecoverFactory (store , get_sometimes_fail_downloader , recoverer )
990+ factory = RecoverFactory (store , get_sometimes_fail_downloader )
993991 pumper = create_pumper ()
994992 self .addCleanup (pumper .stop )
995993
@@ -1001,76 +999,63 @@ def create_proto():
1001999 agent = create_memory_agent (clock , pumper , create_proto )
10021000 pumper .start ()
10031001
1004- async def recover ():
1005- proto = await agent .open (
1006- "ws://127.0.0.1:1/storage-plugins/privatestorageio-zkapauthz-v2/recover" ,
1007- {"headers" : {"Authorization" : f"tahoe-lafs { api_auth_token } " }},
1008- )
1009- updates = []
1010- proto .on ("message" , lambda * args , ** kw : updates .append ((args , kw )))
1011- await proto .is_open
1012- proto .sendMessage (
1013- json .dumps ({"recovery-capability" : self .GOOD_CAPABILITY }).encode ("utf8" )
1014- )
1015- await proto .is_closed
1016- return updates
1017-
1018- # first recovery will fails
1019- d0 = Deferred .fromCoroutine (recover ())
1002+ # first recovery will fail
1003+ d0 = Deferred .fromCoroutine (recover (
1004+ agent ,
1005+ DecodedURL .from_text ("ws://127.0.0.1:1/" ),
1006+ api_auth_token ,
1007+ self .GOOD_CAPABILITY ,
1008+ ))
10201009 pumper ._flush ()
10211010
1022- # try again
1023- d1 = Deferred .fromCoroutine (recover ())
1011+ # try to recover again (this one should work, as we only fail
1012+ # once in the test-provided downloader)
1013+ d1 = Deferred .fromCoroutine (recover (
1014+ agent ,
1015+ DecodedURL .from_text ("ws://127.0.0.1:1/" ),
1016+ api_auth_token ,
1017+ self .GOOD_CAPABILITY ,
1018+ ))
10241019 pumper ._flush ()
10251020
10261021 self .assertThat (
10271022 d0 ,
10281023 succeeded (
1029- AfterPreprocessing (
1030- lambda messages : list (
1031- loads (args [0 ]) for (args , kwargs ) in messages
1032- ),
1033- Equals (
1034- [
1035- {
1036- "stage" : "started" ,
1037- "failure-reason" : None ,
1038- },
1039- # "our" downloader (above) doesn't set any downloading etc
1040- # state-updates
1041- {
1042- "stage" : "download_failed" ,
1043- "failure-reason" : "downloader fails" ,
1044- },
1045- ]
1046- ),
1024+ Equals (
1025+ [
1026+ {
1027+ "stage" : "started" ,
1028+ "failure-reason" : None ,
1029+ },
1030+ # "our" downloader (above) doesn't set any downloading etc
1031+ # state-updates
1032+ {
1033+ "stage" : "download_failed" ,
1034+ "failure-reason" : "downloader fails" ,
1035+ },
1036+ ]
10471037 )
1048- ),
1038+ )
10491039 )
1050- # second attempt should have succeeded
1040+ # second attempt should succeed
10511041 self .assertThat (
10521042 d1 ,
10531043 succeeded (
1054- AfterPreprocessing (
1055- lambda messages : list (
1056- loads (args [0 ]) for (args , kwargs ) in messages
1057- ),
1058- Equals (
1059- [
1060- {
1061- "stage" : "started" ,
1062- "failure-reason" : None ,
1063- },
1064- # "our" downloader (above) doesn't set any downloading etc
1065- # state-updates
1066- {
1067- "stage" : "succeeded" ,
1068- "failure-reason" : None ,
1069- },
1070- ]
1071- ),
1044+ Equals (
1045+ [
1046+ {
1047+ "stage" : "started" ,
1048+ "failure-reason" : None ,
1049+ },
1050+ # "our" downloader (above) doesn't set any downloading etc
1051+ # state-updates
1052+ {
1053+ "stage" : "succeeded" ,
1054+ "failure-reason" : None ,
1055+ },
1056+ ]
10721057 )
1073- ),
1058+ )
10741059 )
10751060
10761061
0 commit comments