Skip to content

Commit

Permalink
Fix kt manifest summary. Improve kt coverage (#253)
Browse files Browse the repository at this point in the history
* Fix kt manifest summary. Improve kt coverage

* Fix version
  • Loading branch information
sergiupuhalschi-rdx authored Nov 5, 2024
1 parent 15824be commit 4694350
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sargon-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon-uniffi"
# Don't forget to update version in crates/sargon/Cargo.toml
version = "1.1.44"
version = "1.1.45"
edition = "2021"
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion crates/sargon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sargon"
# Don't forget to update version in crates/sargon-uniffi/Cargo.toml
version = "1.1.44"
version = "1.1.45"
edition = "2021"
build = "build.rs"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ val TransactionManifest.involvedPoolAddresses: List<PoolAddress>
val TransactionManifest.involvedResourceAddresses: List<ResourceAddress>
get() = transactionManifestInvolvedResourceAddresses(manifest = this)

val TransactionManifest.summary: ManifestSummary?
val TransactionManifest.summary: ManifestSummary
get() = transactionManifestSummary(manifest = this)

fun TransactionManifest.Companion.accountLockerClaim(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.radixdlt.sargon.samples

import com.radixdlt.sargon.NetworkMethod
import com.radixdlt.sargon.annotation.UsesSampleValues
import com.radixdlt.sargon.newNetworkMethodSample
import com.radixdlt.sargon.newNetworkMethodSampleOther

@UsesSampleValues
val NetworkMethod.Companion.sample: Sample<NetworkMethod>
get() = object : Sample<NetworkMethod> {

override fun invoke(): NetworkMethod = newNetworkMethodSample()

override fun other(): NetworkMethod = newNetworkMethodSampleOther()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.radixdlt.sargon

import com.radixdlt.sargon.extensions.toHttpMethod
import com.radixdlt.sargon.samples.Sample
import com.radixdlt.sargon.samples.sample
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class NetworkMethodTest: SampleTestable<NetworkMethod> {

@Test
fun test() {
assertEquals(
"POST",
NetworkMethod.POST.toHttpMethod()
)
assertEquals(
"GET",
NetworkMethod.GET.toHttpMethod()
)
assertEquals(
"HEAD",
NetworkMethod.HEAD.toHttpMethod()
)
}

override val samples: List<Sample<NetworkMethod>>
get() = listOf(NetworkMethod.sample)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.radixdlt.sargon

import com.radixdlt.sargon.extensions.formatted
import com.radixdlt.sargon.extensions.init
import com.radixdlt.sargon.samples.Sample
import com.radixdlt.sargon.samples.sample
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class SubintentHashTest : SampleTestable<SubintentHash> {

override val samples: List<Sample<SubintentHash>>
get() = listOf(SubintentHash.sample)

@Test
fun test() {
val sut = SubintentHash.init("subtxid_rdx1frcm6zzyfd08z0deu9x24sh64eccxeux4j2dv3dsqeuh9qsz4y6sy6hgte")
val actual = sut.formatted()

assertEquals("subt...y6hgte", actual)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.radixdlt.sargon

import com.radixdlt.sargon.extensions.blobs
import com.radixdlt.sargon.extensions.init
import com.radixdlt.sargon.extensions.involvedPoolAddresses
import com.radixdlt.sargon.extensions.involvedResourceAddresses
import com.radixdlt.sargon.extensions.manifestString
import com.radixdlt.sargon.samples.Sample
import com.radixdlt.sargon.samples.sample
import com.radixdlt.sargon.samples.sampleMainnet
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class SubintentManifestTest : SampleTestable<SubintentManifest> {

override val samples: List<Sample<SubintentManifest>>
get() = listOf(SubintentManifest.sample)

@Test
fun test() {
val manifest = SubintentManifest.sample()

assertTrue(manifest.manifestString.contains("CALL_METHOD"))
assertEquals(Blobs.init(emptyList()), manifest.blobs)
assertEquals(emptyList<PoolAddress>(), manifest.involvedPoolAddresses)
assertEquals(listOf(ResourceAddress.sampleMainnet()), manifest.involvedResourceAddresses)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.radixdlt.sargon

import com.radixdlt.sargon.extensions.hash
import com.radixdlt.sargon.extensions.init
import com.radixdlt.sargon.samples.Sample
import com.radixdlt.sargon.samples.sample
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class SubintentTest : SampleTestable<Subintent> {

override val samples: List<Sample<Subintent>>
get() = listOf(Subintent.sample)

@Test
fun test() {
assertEquals(
SubintentHash.init("subtxid_rdx1xput628m2l7jjweefd70gnq3t3a5x2gjeljduwm7vwly94s8ullql92sa0"),
Subintent.sample().hash()
)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.radixdlt.sargon

import com.radixdlt.sargon.Blobs
import com.radixdlt.sargon.extensions.blobs
import com.radixdlt.sargon.extensions.manifestString
import com.radixdlt.sargon.extensions.involvedPoolAddresses
import com.radixdlt.sargon.extensions.involvedResourceAddresses
import com.radixdlt.sargon.extensions.networkId
import com.radixdlt.sargon.extensions.manifestString
import com.radixdlt.sargon.extensions.summary
import com.radixdlt.sargon.extensions.toList
import com.radixdlt.sargon.samples.Sample
import com.radixdlt.sargon.samples.sample
import com.radixdlt.sargon.samples.sampleMainnet
import com.radixdlt.sargon.samples.sampleStokenet
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
Expand Down

0 comments on commit 4694350

Please sign in to comment.