@@ -25,6 +25,33 @@ class NearClientUnitTests {
2525 return if (f.exists()) f.readText() else null
2626 }
2727
28+ @Test
29+ fun testExperimentalCallFunction () = runTest {
30+ val data = loadMockJson(" JsonRpcRequestForExperimentalCallFunction.json" )
31+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalCallFunction.json does not exist!" )
32+
33+
34+ val mockEngine = MockEngine { req ->
35+ when (req.url.fullPath) {
36+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
37+ }
38+ }
39+
40+ val client = HttpClient (mockEngine) {
41+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
42+ }
43+
44+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
45+
46+ try {
47+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalCallFunction .serializer(), data)
48+ val response = nearClient.experimentalCallFunction(requestObj.params)
49+ assertNotNull(response)
50+ } catch (e: Exception ) {
51+ fail(" Test for ExperimentalCallFunction failed: ${e.message} " )
52+ }
53+ }
54+
2855 @Test
2956 fun testExperimentalChanges () = runTest {
3057 val data = loadMockJson(" JsonRpcRequestForExperimentalChanges.json" )
@@ -349,6 +376,195 @@ class NearClientUnitTests {
349376 }
350377 }
351378
379+ @Test
380+ fun testExperimentalViewAccessKey () = runTest {
381+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewAccessKey.json" )
382+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewAccessKey.json does not exist!" )
383+
384+
385+ val mockEngine = MockEngine { req ->
386+ when (req.url.fullPath) {
387+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
388+ }
389+ }
390+
391+ val client = HttpClient (mockEngine) {
392+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
393+ }
394+
395+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
396+
397+ try {
398+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccessKey .serializer(), data)
399+ val response = nearClient.experimentalViewAccessKey(requestObj.params)
400+ assertNotNull(response)
401+ } catch (e: Exception ) {
402+ fail(" Test for ExperimentalViewAccessKey failed: ${e.message} " )
403+ }
404+ }
405+
406+ @Test
407+ fun testExperimentalViewAccessKeyList () = runTest {
408+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewAccessKeyList.json" )
409+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewAccessKeyList.json does not exist!" )
410+
411+
412+ val mockEngine = MockEngine { req ->
413+ when (req.url.fullPath) {
414+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
415+ }
416+ }
417+
418+ val client = HttpClient (mockEngine) {
419+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
420+ }
421+
422+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
423+
424+ try {
425+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccessKeyList .serializer(), data)
426+ val response = nearClient.experimentalViewAccessKeyList(requestObj.params)
427+ assertNotNull(response)
428+ } catch (e: Exception ) {
429+ fail(" Test for ExperimentalViewAccessKeyList failed: ${e.message} " )
430+ }
431+ }
432+
433+ @Test
434+ fun testExperimentalViewAccount () = runTest {
435+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewAccount.json" )
436+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewAccount.json does not exist!" )
437+
438+
439+ val mockEngine = MockEngine { req ->
440+ when (req.url.fullPath) {
441+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
442+ }
443+ }
444+
445+ val client = HttpClient (mockEngine) {
446+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
447+ }
448+
449+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
450+
451+ try {
452+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewAccount .serializer(), data)
453+ val response = nearClient.experimentalViewAccount(requestObj.params)
454+ assertNotNull(response)
455+ } catch (e: Exception ) {
456+ fail(" Test for ExperimentalViewAccount failed: ${e.message} " )
457+ }
458+ }
459+
460+ @Test
461+ fun testExperimentalViewCode () = runTest {
462+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewCode.json" )
463+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewCode.json does not exist!" )
464+
465+
466+ val mockEngine = MockEngine { req ->
467+ when (req.url.fullPath) {
468+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
469+ }
470+ }
471+
472+ val client = HttpClient (mockEngine) {
473+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
474+ }
475+
476+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
477+
478+ try {
479+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewCode .serializer(), data)
480+ val response = nearClient.experimentalViewCode(requestObj.params)
481+ assertNotNull(response)
482+ } catch (e: Exception ) {
483+ fail(" Test for ExperimentalViewCode failed: ${e.message} " )
484+ }
485+ }
486+
487+ @Test
488+ fun testExperimentalViewGasKey () = runTest {
489+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewGasKey.json" )
490+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewGasKey.json does not exist!" )
491+
492+
493+ val mockEngine = MockEngine { req ->
494+ when (req.url.fullPath) {
495+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
496+ }
497+ }
498+
499+ val client = HttpClient (mockEngine) {
500+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
501+ }
502+
503+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
504+
505+ try {
506+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewGasKey .serializer(), data)
507+ val response = nearClient.experimentalViewGasKey(requestObj.params)
508+ assertNotNull(response)
509+ } catch (e: Exception ) {
510+ fail(" Test for ExperimentalViewGasKey failed: ${e.message} " )
511+ }
512+ }
513+
514+ @Test
515+ fun testExperimentalViewGasKeyList () = runTest {
516+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewGasKeyList.json" )
517+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewGasKeyList.json does not exist!" )
518+
519+
520+ val mockEngine = MockEngine { req ->
521+ when (req.url.fullPath) {
522+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
523+ }
524+ }
525+
526+ val client = HttpClient (mockEngine) {
527+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
528+ }
529+
530+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
531+
532+ try {
533+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewGasKeyList .serializer(), data)
534+ val response = nearClient.experimentalViewGasKeyList(requestObj.params)
535+ assertNotNull(response)
536+ } catch (e: Exception ) {
537+ fail(" Test for ExperimentalViewGasKeyList failed: ${e.message} " )
538+ }
539+ }
540+
541+ @Test
542+ fun testExperimentalViewState () = runTest {
543+ val data = loadMockJson(" JsonRpcRequestForExperimentalViewState.json" )
544+ assertNotNull(data, " Mock file JsonRpcRequestForExperimentalViewState.json does not exist!" )
545+
546+
547+ val mockEngine = MockEngine { req ->
548+ when (req.url.fullPath) {
549+ else -> respond(data, headers = headersOf(" Content-Type" to listOf (ContentType .Application .Json .toString())))
550+ }
551+ }
552+
553+ val client = HttpClient (mockEngine) {
554+ install(ContentNegotiation ) { json(Json { ignoreUnknownKeys = true }) }
555+ }
556+
557+ val nearClient = io.github.hosseinkarami_dev.near.rpc.client.NearClient (client, " http://mock" , json)
558+
559+ try {
560+ val requestObj = json.decodeFromString(io.github.hosseinkarami_dev.near.rpc.models.JsonRpcRequestForExperimentalViewState .serializer(), data)
561+ val response = nearClient.experimentalViewState(requestObj.params)
562+ assertNotNull(response)
563+ } catch (e: Exception ) {
564+ fail(" Test for ExperimentalViewState failed: ${e.message} " )
565+ }
566+ }
567+
352568 @Test
353569 fun testBlock () = runTest {
354570 val data = loadMockJson(" JsonRpcRequestForBlock.json" )
0 commit comments