damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

Bech32Tests.swift (1514B)


      1 //
      2 //  Bech32Tests.swift
      3 //  damusTests
      4 //
      5 //  Created by William Casarin on 2022-05-22.
      6 //
      7 
      8 import XCTest
      9 @testable import damus
     10 
     11 class Bech32Tests: XCTestCase {
     12 
     13     override func setUpWithError() throws {
     14         // Put setup code here. This method is called before the invocation of each test method in the class.
     15     }
     16 
     17     override func tearDownWithError() throws {
     18         // Put teardown code here. This method is called after the invocation of each test method in the class.
     19     }
     20 
     21     func test_bech32_encode_decode() throws {
     22         // This is an example of a functional test case.
     23         // Use XCTAssert and related functions to verify your tests produce the correct results.
     24         // Any test you write for XCTest can be annotated as throws and async.
     25         // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
     26         // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
     27         
     28         let pubkey = Pubkey(hex: "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245")!
     29 
     30         guard let decoded = try? bech32_decode(pubkey.npub) else {
     31             XCTAssert(false)
     32             return
     33         }
     34 
     35         XCTAssertEqual(decoded.data, pubkey.id)
     36     }
     37 
     38     func testPerformanceExample() throws {
     39         // This is an example of a performance test case.
     40         self.measure {
     41             // Put the code you want to measure the time of here.
     42         }
     43     }
     44 
     45 }