2 #import "MockSynchronousEscrowServer.h"
4 @interface MockSynchronousEscrowServer ()
5 @property EscrowRequestServer* server;
8 @implementation MockSynchronousEscrowServer
10 - (instancetype)initWithServer:(EscrowRequestServer*)server
12 if((self = [super init])) {
18 - (void)cachePrerecord:(NSString*)uuid
19 serializedPrerecord:(nonnull NSData *)prerecord
20 reply:(nonnull void (^)(NSError * _Nullable))reply
22 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
24 [self.server cachePrerecord:uuid
25 serializedPrerecord:prerecord
26 reply:^(NSError * _Nullable error) {
28 dispatch_semaphore_signal(sema);
31 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
34 - (void)fetchPrerecord:(nonnull NSString *)prerecordUUID
35 reply:(nonnull void (^)(NSData * _Nullable, NSError * _Nullable))reply
38 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
40 [self.server fetchPrerecord:prerecordUUID
41 reply:^(NSData* contents, NSError * _Nullable error) {
42 reply(contents, error);
43 dispatch_semaphore_signal(sema);
46 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
49 - (void)fetchRequestWaitingOnPasscode:(nonnull void (^)(NSString * _Nullable, NSError * _Nullable))reply
51 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
53 [self.server fetchRequestWaitingOnPasscode:^(NSString* uuid, NSError * _Nullable error) {
55 dispatch_semaphore_signal(sema);
58 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
61 - (void)triggerEscrowUpdate:(nonnull NSString *)reason
62 reply:(nonnull void (^)(NSError * _Nullable))reply
64 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
66 [self.server triggerEscrowUpdate:reason reply:^(NSError * _Nullable error) {
68 dispatch_semaphore_signal(sema);
71 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
74 - (void)fetchRequestStatuses:(nonnull void (^)(NSDictionary<NSString *,NSString *> * _Nullable, NSError * _Nullable))reply {
75 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
77 [self.server fetchRequestStatuses:^(NSDictionary<NSString *,NSString *> * dict, NSError * _Nullable error) {
79 dispatch_semaphore_signal(sema);
82 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
85 - (void)resetAllRequests:(nonnull void (^)(NSError * _Nullable))reply {
86 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
88 [self.server resetAllRequests:^(NSError * _Nullable error) {
90 dispatch_semaphore_signal(sema);
93 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
96 - (void)storePrerecordsInEscrow:(nonnull void (^)(uint64_t, NSError * _Nullable))reply {
98 dispatch_semaphore_t sema = dispatch_semaphore_create(0);
100 [self.server storePrerecordsInEscrow:^(uint64_t x, NSError * _Nullable error) {
102 dispatch_semaphore_signal(sema);
105 dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);