11//
2- // File.swift
2+ // GraphQLProviderTest.swift
3+ // SuiKit
34//
5+ // Copyright (c) 2023 OpenDive
46//
5- // Created by Marcus Arnett on 1/11/24.
7+ // Permission is hereby granted, free of charge, to any person obtaining a copy
8+ // of this software and associated documentation files (the "Software"), to deal
9+ // in the Software without restriction, including without limitation the rights
10+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+ // copies of the Software, and to permit persons to whom the Software is
12+ // furnished to do so, subject to the following conditions:
13+ //
14+ // The above copyright notice and this permission notice shall be included in
15+ // all copies or substantial portions of the Software.
16+ //
17+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+ // THE SOFTWARE.
624//
725
826import Foundation
@@ -18,7 +36,7 @@ final class GraphQLProviderTest: XCTestCase {
1836 override func setUp( ) async throws {
1937 self . toolBox = try await TestToolbox ( true )
2038 }
21-
39+
2240 private func setUpWithPackage( ) async throws {
2341 self . packageId = try await self . fetchToolBox ( ) . publishPackage ( " dynamic-fields " ) . packageId
2442
@@ -49,6 +67,7 @@ final class GraphQLProviderTest: XCTestCase {
4967 signer: toolBox. account
5068 )
5169 let _ = try await self . fetchToolBox ( ) . client. waitForTransaction ( tx: result. digest)
70+ // TODO: Remove once the GraphQL endpoint becomes default with the example validator.
5271 try await Task . sleep ( nanoseconds: 10_000_000_000 ) // Buffer for waiting on the Sui Indexer to catch up with the RPC Node
5372 }
5473
@@ -68,14 +87,6 @@ final class GraphQLProviderTest: XCTestCase {
6887 return packageId
6988 }
7089
71- private func fetchParentObjectId( ) throws -> String {
72- guard let parentObjectId = self . parentObjectId else {
73- XCTFail ( " Failed to get Parent Object ID " )
74- throw NSError ( domain: " Failed to get Parent Object ID " , code: - 1 )
75- }
76- return parentObjectId
77- }
78-
7990 func testThatGettingCoinsWorksAsIntendedFromGraphQL( ) async throws {
8091 try await self . setUpWithTransaction ( )
8192 let toolBox = try self . fetchToolBox ( )
@@ -217,7 +228,7 @@ final class GraphQLProviderTest: XCTestCase {
217228
218229 let rpcObject = try await toolBox. client. getObject ( objectId: gasCoin. data [ 0 ] . coinObjectId, options: objectOptions)
219230 let graphQLObject = try await toolBox. graphQLProvider. getObject ( objectId: gasCoin. data [ 0 ] . coinObjectId, options: objectOptions)
220-
231+
221232 XCTAssertEqual ( rpcObject? . data? . objectId, graphQLObject? . data? . objectId)
222233 XCTAssertEqual ( rpcObject? . data? . digest, graphQLObject? . data? . digest)
223234 XCTAssertEqual ( rpcObject? . data? . previousTransaction, graphQLObject? . data? . previousTransaction)
@@ -295,7 +306,7 @@ final class GraphQLProviderTest: XCTestCase {
295306
296307 let rpcObject = try await toolBox. client. getMultiObjects ( ids: [ gasCoin. data [ 0 ] . coinObjectId] , options: objectOptions)
297308 let graphQLObject = try await toolBox. graphQLProvider. getMultiObjects ( ids: [ gasCoin. data [ 0 ] . coinObjectId] , options: objectOptions)
298-
309+
299310 XCTAssertEqual ( rpcObject [ 0 ] . data? . objectId, graphQLObject [ 0 ] . data? . objectId)
300311 XCTAssertEqual ( rpcObject [ 0 ] . data? . digest, graphQLObject [ 0 ] . data? . digest)
301312 XCTAssertEqual ( rpcObject [ 0 ] . data? . previousTransaction, graphQLObject [ 0 ] . data? . previousTransaction)
0 commit comments