Skip to content

Commit

Permalink
test: add nonce generator
Browse files Browse the repository at this point in the history
Signed-off-by: Allain Magyar <[email protected]>
  • Loading branch information
amagyar-iohk committed Mar 28, 2024
1 parent ff1e236 commit 44b24d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions E2E/e2eTests/Source/Abilities/OpenEnterpriseAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class OpenEnterpriseAPI: Ability {
)
]),
name: "proof_req_1",
nonce: "1103253414365527824079144",
nonce: Utils.generateNonce(length: 25),
version: "1.0"
)

Expand All @@ -447,7 +447,6 @@ class OpenEnterpriseAPI: Ability {
default:
throw Error.WrongResponse(response)
}

}

func getPresentation(_ presentationId: String) async throws -> Components.Schemas.PresentationStatus {
Expand Down
20 changes: 20 additions & 0 deletions E2E/e2eTests/Source/Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation
import XCTest

class Utils {
static func generateNonce(length: Int) -> String {
var result: String = ""

while (result.count < length) {
var randomByte: UInt8 = 0
_ = SecRandomCopyBytes(kSecRandomDefault, 1, &randomByte)
if (randomByte >= 250) {
continue
}
let randomDigit = randomByte % 10
result += String(randomDigit)
}
return result
}
}

0 comments on commit 44b24d3

Please sign in to comment.