diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..d61c238 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,26 @@ +name: On pull request + +on: + pull_request: + branches: + - 'main' + - 'refactor/swift-concurency' + +jobs: + unit-test: + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - name: Run tests + run: swift test --filter "OrcaSwapSwift" --enable-code-coverage + - name: Processing converage data + run: | + xcrun llvm-cov export -format="lcov" .build/debug/OrcaSwapSwift.xctest/Contents/MacOS/OrcaSwapSwift -instr-profile .build/debug/codecov/default.profdata > info.lcov + - uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: ./info.lcov # optional + flags: unittests # optional + name: codecov-umbrella # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) diff --git a/OrcaSwapSwift.podspec b/OrcaSwapSwift.podspec index 09b2d2d..ded45c7 100644 --- a/OrcaSwapSwift.podspec +++ b/OrcaSwapSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'OrcaSwapSwift' - s.version = '2.0.0' + s.version = '2.1.1' s.summary = 'A client for OrcaSwap written in Swift.' s.description = <<-DESC TODO: Add long description of the pod here. @@ -25,5 +25,5 @@ TODO: Add long description of the pod here. # s.public_header_files = 'Pod/Classes/**/*.h' # s.frameworks = 'UIKit', 'MapKit' - s.dependency 'SolanaSwift', '~> 2.0.0' + s.dependency 'SolanaSwift', '~> 2.1.1' end diff --git a/Package.resolved b/Package.resolved index 960e6ff..461390d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -23,9 +23,9 @@ "package": "SolanaSwift", "repositoryURL": "https://github.com/p2p-org/solana-swift.git", "state": { - "branch": "refactor/pwn-3297", - "revision": "2c3fc55c5c4efd68da680de10e1504140c2e54e7", - "version": null + "branch": null, + "revision": "7b1ef1cdb1a595d0dafc39bcb4c5603b7f56dd52", + "version": "2.1.1" } }, { @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/bigearsenal/task-retrying-swift.git", "state": { "branch": null, - "revision": "c93fef795874cf31b7b0f8f6e9c23f4f15188dec", - "version": "1.0.2" + "revision": "645eaaf207a6f39ab4b469558d916ae23df199b5", + "version": "1.0.3" } }, { diff --git a/Package.swift b/Package.swift index e1ab91b..f324a3b 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( targets: ["OrcaSwapSwift"]), ], dependencies: [ - .package(url: "https://github.com/p2p-org/solana-swift.git", branch: "refactor/pwn-3297") + .package(url: "https://github.com/p2p-org/solana-swift.git", from: "2.1.1") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/OrcaSwapSwift/OrcaSwap/OrcaSwap.swift b/Sources/OrcaSwapSwift/OrcaSwap/OrcaSwap.swift index 6a4e0d9..30c99a9 100644 --- a/Sources/OrcaSwapSwift/OrcaSwap/OrcaSwap.swift +++ b/Sources/OrcaSwapSwift/OrcaSwap/OrcaSwap.swift @@ -108,10 +108,12 @@ public class OrcaSwap: OrcaSwapType { // retrieve all routes var poolsPairs = [PoolsPair]() + try Task.checkCancellation() try await withThrowingTaskGroup(of: [Pool]?.self) {group in for route in currentRoutes where route.count <= 2 { group.addTask { [weak self] in guard let self = self else {return nil} + try Task.checkCancellation() return try await self.getPools( forRoute: route, fromTokenName: fromTokenName, @@ -121,6 +123,7 @@ public class OrcaSwap: OrcaSwapType { } for try await pools in group { + try Task.checkCancellation() guard let pools = pools else {continue} poolsPairs.append(pools) } diff --git a/Tests/IntegrationTests/SwapIntegrationTests.swift b/Tests/IntegrationTests/SwapIntegrationTests.swift index 9ba27ea..0218999 100644 --- a/Tests/IntegrationTests/SwapIntegrationTests.swift +++ b/Tests/IntegrationTests/SwapIntegrationTests.swift @@ -170,7 +170,7 @@ private extension OrcaSwapSwift.Pool { private struct MockAccountStorage: SolanaAccountStorage { let _account: Account var account: Account? { - get throws { + get { _account } } diff --git a/Tests/UnitTests/OrcaSwap/OrcaSwapPreparationTests.swift b/Tests/UnitTests/OrcaSwap/OrcaSwapPreparationTests.swift index aaf7e35..4effcd1 100644 --- a/Tests/UnitTests/OrcaSwap/OrcaSwapPreparationTests.swift +++ b/Tests/UnitTests/OrcaSwap/OrcaSwapPreparationTests.swift @@ -20,7 +20,14 @@ class OrcaSwapPreparationTests: XCTestCase { apiClient: APIClient(configsProvider: MockConfigsProvider()), solanaClient: solanaAPIClient, blockchainClient: blockchainClient, - accountStorage: MockAccountStorage() + accountStorage: MockAccountStorage( + _account: try await Account( + phrase: "miracle pizza supply useful steak border same again youth silver access hundred" + .components(separatedBy: " "), + network: .mainnetBeta, + derivablePath: .init(type: .deprecated, walletIndex: 0) + ) + ) ) try await orcaSwap.load() } @@ -237,14 +244,10 @@ private class MockSolanaAPIClient: JSONRPCAPIClient { } private struct MockAccountStorage: SolanaAccountStorage { + let _account: Account var account: Account? { - get throws { - try? .init( - phrase: "miracle pizza supply useful steak border same again youth silver access hundred" - .components(separatedBy: " "), - network: .mainnetBeta, - derivablePath: .init(type: .deprecated, walletIndex: 0) - ) + get { + _account } } diff --git a/Tests/UnitTests/OrcaSwap/SwapTests.swift b/Tests/UnitTests/OrcaSwap/SwapTests.swift index bbfd51b..22f9992 100644 --- a/Tests/UnitTests/OrcaSwap/SwapTests.swift +++ b/Tests/UnitTests/OrcaSwap/SwapTests.swift @@ -138,7 +138,7 @@ private extension OrcaSwapSwift.Pool { private struct MockAccountStorage: SolanaAccountStorage { let _account: Account var account: Account? { - get throws { + get { _account } }