mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			25 lines
		
	
	
		
			888 B
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			25 lines
		
	
	
		
			888 B
		
	
	
	
		
			Swift
		
	
| 
											6 years ago
										 | import CryptoSwift | ||
| 
											6 years ago
										 | import PromiseKit | ||
| 
											6 years ago
										 | @testable import SignalServiceKit | ||
|  | import XCTest | ||
|  | 
 | ||
|  | class OnionRequestAPITests : XCTestCase { | ||
| 
											6 years ago
										 |     private let maxRetryCount: UInt = 2 // Be a bit more stringent when testing | ||
|  |     private let testPublicKey = "0501da4723331eb54aaa9a6753a0a59f762103de63f1dc40879cb65a5b5f508814" | ||
|  |      | ||
| 
											6 years ago
										 |     func testOnionRequestSending() { | ||
|  |         let semaphore = DispatchSemaphore(value: 0) | ||
| 
											6 years ago
										 |         var error: Error? = nil | ||
|  |         LokiAPI.useOnionRequests = true | ||
|  |         let _ = attempt(maxRetryCount: maxRetryCount, recoveringOn: LokiAPI.workQueue) { [testPublicKey = self.testPublicKey] in | ||
|  |             LokiAPI.getSwarm(for: testPublicKey) | ||
|  |         }.done(on: LokiAPI.workQueue) { _ in | ||
| 
											6 years ago
										 |             semaphore.signal() | ||
| 
											6 years ago
										 |         }.catch(on: LokiAPI.workQueue) { | ||
|  |             error = $0; semaphore.signal() | ||
| 
											6 years ago
										 |         } | ||
|  |         semaphore.wait() | ||
| 
											6 years ago
										 |         XCTAssert(error == nil) | ||
| 
											6 years ago
										 |     } | ||
| 
											6 years ago
										 | } |