-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5867bf
commit 4f77c8a
Showing
4 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,14 @@ final class torus_utils_swiftTests: XCTestCase { | |
let nodePubKeys : Array<TorusNodePub> = [TorusNodePub(_X: "4086d123bd8b370db29e84604cd54fa9f1aeb544dba1cc9ff7c856f41b5bf269", _Y: "fde2ac475d8d2796aab2dea7426bc57571c26acad4f141463c036c9df3a8b8e8"),TorusNodePub(_X: "1d6ae1e674fdc1849e8d6dacf193daa97c5d484251aa9f82ff740f8277ee8b7d", _Y: "43095ae6101b2e04fa187e3a3eb7fbe1de706062157f9561b1ff07fe924a9528"),TorusNodePub(_X: "fd2af691fe4289ffbcb30885737a34d8f3f1113cbf71d48968da84cab7d0c262", _Y: "c37097edc6d6323142e0f310f0c2fb33766dbe10d07693d73d5d490c1891b8dc"),TorusNodePub(_X: "e078195f5fd6f58977531135317a0f8d3af6d3b893be9762f433686f782bec58", _Y: "843f87df076c26bf5d4d66120770a0aecf0f5667d38aa1ec518383d50fa0fb88"),TorusNodePub(_X: "a127de58df2e7a612fd256c42b57bb311ce41fd5d0ab58e6426fbf82c72e742f", _Y: "388842e57a4df814daef7dceb2065543dd5727f0ee7b40d527f36f905013fa96")] | ||
let verifierId = "[email protected]" | ||
let verifier = "google" | ||
let token = "eyJhbGciOiJSUzI1NiIsImtpZCI6Ijc0YmQ4NmZjNjFlNGM2Y2I0NTAxMjZmZjRlMzhiMDY5YjhmOGYzNWMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI4NzY3MzMxMDUxMTYtaTBoajNzNTNxaWlvNWs5NXBycGZtajBocDBnbWd0b3IuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI4NzY3MzMxMDUxMTYtaTBoajNzNTNxaWlvNWs5NXBycGZtajBocDBnbWd0b3IuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDk1ODQzNTA5MTA3Mjc0NzAzNDkiLCJoZCI6InRvci51cyIsImVtYWlsIjoic2h1YmhhbUB0b3IudXMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXRfaGFzaCI6ImxRN2taQXpMNnJOZzkxZXBtTXNWVWciLCJub25jZSI6ImR6eE9NazJMZ25CVnNLeEVjWW9XUFZWcmdsV1ViQiIsIm5hbWUiOiJTaHViaGFtIFJhdGhpIiwicGljdHVyZSI6Imh0dHBzOi8vbGg0Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tT19SUi1aYlQwZVUvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQUEvQUFLV0pKTmVleHhiRHozcjFVVnBrWjVGbzdsYTNhMXZRZy9zOTYtYy9waG90by5qcGciLCJnaXZlbl9uYW1lIjoiU2h1YmhhbSIsImZhbWlseV9uYW1lIjoiUmF0aGkiLCJsb2NhbGUiOiJlbiIsImlhdCI6MTU4ODU4Nzg0NCwiZXhwIjoxNTg4NTkxNDQ0LCJqdGkiOiI1Yzg3ZWI0NjA3YzY0OGI3NTkwYTFiMzRkNzAxNWRlMGVjYjJmYjgyIn0.TXVX01HdJnIERxvqmN3myIAjB0YVD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WjVGbzdsYTNhMXZRZy9zOTYtYy9waG90by5qcGciLCJnaXZlbl9uYW1lIjoiU2h1YmhhbSIsImZhbWlseV9uYW1lIjoiUmF0aGkiLCJsb2NhbGUiOiJlbiIsImlhdCI6MTU4ODY0ODgxNywiZXhwIjoxNTg4NjUyNDE3LCJqdGkiOiJiYzVjZjRiODUxY2RiMzFmMTMxZTVlMWE5ZWJmYWE1NzM4ZGRjNWY0In0.SZl_Pu48yniZseG21JKgLJzlgBbtZKsRE1XDPj1qRaYcrtxTb5VoKk4XVubXdswZdrpblZ3FwLPbiC1OeaQMs4bZeB6Z4URzoiew0P0LA4CpxpUyA9iNf_NTqDqo6w3PHM4aw7tIKaOZIJJH9Hq2_8qEtlQ9fL8WtUCmQrgnqRCOzuRQ9x42XD1s4UgtljQj17WVn_c5HYkOOfoY7F50O_vI2no2WOx6kvxuUc2utZco29rOSFu2DDzwlMdzoeqkRy6x-4v_buqSL9xu_eCurvIcqKZcrPsg-m41Eb7eXoNRJAOqx8rOnSRGa_2fYMjM82tpFC0jX0qwfQII8th8ew" | ||
|
||
override class func setUp() { | ||
super.setUp() | ||
let fnd = FetchNodeDetails() | ||
// self.nodeList = fnd.getNodeDetails().getTorusNodeEndpoints() | ||
let nodeDetails = fnd.getNodeDetails() | ||
let nodeEndpoints = nodeDetails.getTorusNodeEndpoints() | ||
let nodePubkeys = nodeDetails.getTorusNodePub() | ||
} | ||
|
||
func testKeyLookup() { | ||
|
@@ -42,6 +44,8 @@ final class torus_utils_swiftTests: XCTestCase { | |
exp1.fulfill() | ||
}.catch{err in | ||
print(err) | ||
XCTFail() | ||
exp1.fulfill() | ||
} | ||
|
||
let exp2 = XCTestExpectation(description: "Do keylookup with failure") | ||
|
@@ -50,7 +54,9 @@ final class torus_utils_swiftTests: XCTestCase { | |
XCTAssert(data["err"]=="keyLookupfailed", "error verified") | ||
exp2.fulfill() | ||
}.catch{err in | ||
print(err) | ||
print("keylookup failed", err) | ||
XCTFail() | ||
exp2.fulfill() | ||
} | ||
|
||
wait(for: [exp1, exp2], timeout: 5) | ||
|
@@ -61,10 +67,13 @@ final class torus_utils_swiftTests: XCTestCase { | |
let obj = TorusUtils() | ||
let keyAssign = obj.keyAssign(endpoints: self.nodeList, torusNodePubs: nodePubKeys, verifier: verifier, verifierId: self.verifierId) | ||
keyAssign.done{ data in | ||
// print(data) | ||
XCTAssertNotNil(data) | ||
exp1.fulfill() | ||
}.catch{ err in | ||
print("keyAssign failed", err) | ||
XCTFail() | ||
exp1.fulfill() | ||
} | ||
wait(for: [exp1], timeout: 5) | ||
} | ||
|
@@ -75,32 +84,38 @@ final class torus_utils_swiftTests: XCTestCase { | |
let getpublicaddress = obj.getPublicAddress(endpoints: self.nodeList, torusNodePubs: nodePubKeys, verifier: "google", verifierId: self.verifierId, isExtended: true) | ||
getpublicaddress.done{ data in | ||
print("data", data) | ||
// Specific to address of [email protected]. Change this to your public address for the above nodelist | ||
XCTAssert(data["address"]=="0x5533572d0b2b69Ae31bfDeA351B67B1C05F724Bc", "Address verified") | ||
exp1.fulfill() | ||
}.catch{ err in | ||
print("getpublicaddress failed", err) | ||
XCTFail() | ||
exp1.fulfill() | ||
} | ||
wait(for: [exp1], timeout: 10) | ||
} | ||
|
||
func testRetreiveShares(){ | ||
let exp1 = XCTestExpectation(description: "reterive privatekey") | ||
let obj = TorusUtils() | ||
let key = obj.retreiveShares(endpoints: self.nodeList, verifier: "google", verifierParams: ["verifier_id":"[email protected]"], idToken: token) | ||
let key = obj.retreiveShares(endpoints: self.nodeList, verifier: "google", verifierParams: ["verifier_id": verifierId], idToken: token) | ||
key.done{ data in | ||
print("data", data) | ||
XCTAssertEqual(64, data.count) | ||
exp1.fulfill() | ||
}.catch{err in | ||
print("Unit test, testRetreiveShares", err) | ||
print("testRetreiveShares failed", err) | ||
XCTFail() | ||
exp1.fulfill() | ||
} | ||
|
||
wait(for: [exp1], timeout: 20) | ||
wait(for: [exp1], timeout: 10) | ||
} | ||
|
||
var allTests = [ | ||
("testKeyLookup", testKeyLookup), | ||
("testKeyAssign", testKeyAssign), | ||
("testGetPublicAddress", testGetPublicAddress) | ||
("testGetPublicAddress", testGetPublicAddress), | ||
("testRetreiveShares", testRetreiveShares) | ||
] | ||
} |