Skip to content

Commit 3e742db

Browse files
chore: added EIP4361 test for missing domain
1 parent 261ab36 commit 3e742db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Tests/web3swiftTests/localTests/EIP4361Test.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ class EIP4361Test: XCTestCase {
8484
XCTAssertNil(validationResponse.capturedFields[.resources])
8585
}
8686

87+
func testInvalidEIP4361MissingDomain() {
88+
let rawSiweMessage = "wants you to sign in with your Ethereum account:\n0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\n\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z"
89+
90+
let validationResponse = EIP4361.validate(rawSiweMessage)
91+
guard !validationResponse.isValid else {
92+
XCTFail("Failed to parse valid SIWE message.")
93+
return
94+
}
95+
96+
XCTAssertNil(validationResponse.eip4361)
97+
XCTAssertNil(validationResponse.capturedFields[.domain])
98+
}
99+
87100
func testInvalidEIP4361MissingAddress() {
88101
let rawSiweMessage = "service.invalid wants you to sign in with your Ethereum account:\nI accept the ServiceOrg Terms of Service: https://service.invalid/tos\n\nURI: https://service.invalid/login\nVersion: 1\nChain ID: 1\nNonce: 32891756\nIssued At: 2021-09-30T16:25:24.345Z\nExpiration Time: 2021-09-29T15:25:24.234Z\nNot Before: 2021-10-28T14:25:24.123Z\nRequest ID: random-0123456789abcdefrequest-id_STRING-._~:@!$&\'()*+,;=\nResources:\n- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/\n- https://example.com/my-web2-claim.json"
89102

0 commit comments

Comments
 (0)