Skip to content

Commit

Permalink
refactor tests package...
Browse files Browse the repository at this point in the history
  • Loading branch information
astinz committed May 14, 2024
1 parent 557b9ca commit 37f35ed
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package xyz.mcxross.kaptos.api
package xyz.mcxross.kaptos.e2e

import kotlin.test.Test
import kotlin.test.assertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

package xyz.mcxross.kaptos.api
package xyz.mcxross.kaptos.e2e

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlin.test.*
import xyz.mcxross.kaptos.Aptos
import xyz.mcxross.kaptos.model.AptosConfig
import xyz.mcxross.kaptos.model.AptosSettings
import xyz.mcxross.kaptos.model.Network
import xyz.mcxross.kaptos.model.Option
import xyz.mcxross.kaptos.model.*
import xyz.mcxross.kaptos.protocol.queryIndexer
import xyz.mcxross.kaptos.util.runBlocking

class GeneralTest {
Expand Down Expand Up @@ -80,6 +80,33 @@ class GeneralTest {
}
}

@Serializable
data class LedgerInfo(@SerialName("chain_id") val chainId: Int)

@Serializable
data class Data(@SerialName("ledger_infos") val ledgerInfos: List<LedgerInfo>)

@Serializable
data class MyQueryResponse(val data: Data)

@Test
fun testGraphqlQuery() {
runBlocking {
val aptos = Aptos(AptosConfig(AptosSettings(network = Network.TESTNET)))
val query =
GraphqlQuery(
query = "query MyQuery {\nledger_infos {\nchain_id\n}\n}"
)

when (val response = aptos.queryIndexer<MyQueryResponse>(query)) {
is Option.Some -> {
assertEquals(response.value.data.ledgerInfos[0].chainId, 2, "Chain ID should be 2")
}
is Option.None -> assertTrue(false)
}
}
}

@Test
fun testGetChainTopUserTransactions() {
runBlocking {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package xyz.mcxross.kaptos.api
package xyz.mcxross.kaptos.e2e

import kotlin.test.Test
import kotlin.test.assertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package xyz.mcxross.kaptos.api
package xyz.mcxross.kaptos.e2e

import kotlin.test.Test
import kotlin.test.assertTrue
Expand Down

0 comments on commit 37f35ed

Please sign in to comment.