Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-716 handle CONFIRMATION_REQUEST pushes; add unit tests
- Loading branch information
Andrey Scherbovich
committed
Nov 25, 2020
1 parent
8c9350d
commit 051838b
Showing
11 changed files
with
122 additions
and
10 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
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
33 changes: 33 additions & 0 deletions
33
...gTests/Data/Services/Safe Transaction Service/RegisterNotificationTokenRequestTests.swift
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// RegisterNotificationTokenRequestTests.swift | ||
// MultisigTests | ||
// | ||
// Created by Andrey Scherbovich on 25.11.20. | ||
// Copyright © 2020 Gnosis Ltd. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import Multisig | ||
|
||
class RegisterNotificationTokenRequestTests: XCTestCase { | ||
let mockStore = MockSecureStore() | ||
|
||
override func setUpWithError() throws { | ||
App.shared.keychainService = mockStore | ||
try! mockStore.save(data: Data(hex: "0xe7979e5f2ceb1d4ef76019d1fdba88b50ceefe0575bbfdf94969837c50a5d895"), | ||
forKey: KeychainKey.ownerPrivateKey.rawValue) | ||
} | ||
|
||
|
||
func testRequestInitCalculatesProperSignature() throws { | ||
let request = try RegisterNotificationTokenRequest( | ||
deviceID: UUID(uuidString: "bb30cd3e-e0ad-4e9a-b726-44db67a0820b")!, | ||
safes: [Address("0xEefFcdEAB4AC6005E90566B08EAda3994A573C1E")], | ||
token: "erXBYb-CxU1jtSvwfZrxqW:APA91bH0IWkMWOGizlbNAwxV6OVjEmNR1feRs2WBT7BE6aVMm2C-x1COKqNYq19t5YNjIzVBKDyVVEqFojlkvEtiSaJA0lCZL0LfuEwfc8p9jfBuM6HG82pczVbnMev1J0gXlB3bIlAP", | ||
bundle: "io.gnosis.multisig.dev.rinkeby", | ||
version: "2.6.0", | ||
buildNumber: "1", | ||
timestamp: "1606319110027") | ||
XCTAssertEqual(request.signatures, ["460ab62322407376576be061a6bfaaaa78cd1be4e0421d88cd635d0568ff2d473280d0edfd898bf1fd73f3fea8206ef91d6fbf6d9dc63b5d7d1378b8e4059f691c"]) | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
NotificationServiceExtension/Notifications/ConfirmationRequestNotification.swift
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ConfirmationRequestNotification.swift | ||
// NotificationServiceExtension | ||
// | ||
// Created by Andrey Scherbovich on 25.11.20. | ||
// Copyright © 2020 Gnosis Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct ConfirmationRequestNotification: MultisigNotification { | ||
let address: PlainAddress | ||
|
||
init?(payload: NotificationPayload) { | ||
guard | ||
let rawType = payload.type, | ||
let type = NotificationType(rawValue: rawType), | ||
type == .confirmationRequest, | ||
let address = PlainAddress(payload.address) | ||
else { | ||
return nil | ||
} | ||
self.address = address | ||
} | ||
|
||
var localizedTitle: String { | ||
"Confirmation required" | ||
} | ||
|
||
var localizedBody: String { | ||
"\(address.truncatedInMiddle): A transaction requires your confirmation!" | ||
} | ||
} |
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