Skip to content

Commit

Permalink
Merge pull request zingolabs#726 from dorianvp/tex_parsing_integratio…
Browse files Browse the repository at this point in the history
…n_tests

Add TEX parsing integration tests
  • Loading branch information
juanky201271 authored Oct 16, 2024
2 parents 44bc707 + e129254 commit aa732e6
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 98 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/android-ubuntu-integration-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ jobs:
"execute_sync_from_seed",
"execute_send_from_orchard",
"execute_currentprice_and_value_transfers_from_seed",
"execute_sapling_balance_from_seed"
"execute_sapling_balance_from_seed",
"execute_parse_addresses"
]
env:
CACHE-KEY: ${{ inputs.cache-key }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ data class ValueTransfers (
val value_transfers : List<ValueTransfer>,
)

data class ParseResult (
val status: String,
val chain_name: String?,
val address_kind: String?
)

@Category(OfflineTest::class)
class ExecuteAddressesFromSeed {
@Test
Expand Down Expand Up @@ -447,3 +453,88 @@ class ExecuteSaplingBalanceFromSeed {
assertThat(balance.transparent_balance).isEqualTo(0)
}
}

class ExecuteParseAddresses {

@Test
fun ExecuteParseAddressForTex() {
val mapper = jacksonObjectMapper()

val server = "http://10.0.2.2:20000"
val chainhint = "regtest"
val seed = Seeds.HOSPITAL
val birthday:ULong = 1u
val datadir = MainApplication.getAppContext()!!.filesDir.path
val monitorMempool = false

val setCrytoProvider = uniffi.zingo.setCryptoDefaultProviderToRing()
println(setCrytoProvider)

val initFromSeedJson: String = uniffi.zingo.initFromSeed(server, seed, birthday, datadir, chainhint, monitorMempool)
println("\nInit from seed:")
println(initFromSeedJson)
val initFromSeed: InitFromSeed = mapper.readValue(initFromSeedJson)

val seedResult = initFromSeed.seed
val birthdayResult = initFromSeed.birthday

assertThat(seedResult).isEqualTo(seed)
assertThat(birthdayResult).isEqualTo(1)

val resultJson: String = uniffi.zingo.executeCommand("parse_address", "texregtest1z754rp9kk9vdewx4wm7pstvm0u2rwlgy4zp82v")
val result: ParseResult = mapper.readValue(resultJson)
println("\nParsed Address:")
println(result)

assertThat(result).isNotNull()

val expectedResult = ParseResult(
status = "success",
chain_name = "regtest",
address_kind = "tex"
)

assertThat(result).isEqualTo(expectedResult)
}

@Test
fun ExecuteParseAddresInvalid() {
val mapper = jacksonObjectMapper()

val server = "http://10.0.2.2:20000"
val chainhint = "regtest"
val seed = Seeds.HOSPITAL
val birthday:ULong = 1u
val datadir = MainApplication.getAppContext()!!.filesDir.path
val monitorMempool = false

val setCrytoProvider = uniffi.zingo.setCryptoDefaultProviderToRing()
println(setCrytoProvider)

val initFromSeedJson: String = uniffi.zingo.initFromSeed(server, seed, birthday, datadir, chainhint, monitorMempool)
println("\nInit from seed:")
println(initFromSeedJson)
val initFromSeed: InitFromSeed = mapper.readValue(initFromSeedJson)

val seedResult = initFromSeed.seed
val birthdayResult = initFromSeed.birthday

assertThat(seedResult).isEqualTo(seed)
assertThat(birthdayResult).isEqualTo(1)

val wrongResultJson: String = uniffi.zingo.executeCommand("parse_address", "thiswontwork")
val wrongResult: ParseResult = mapper.readValue(wrongResultJson)
println("\nWrong Address:")
println(wrongResult)

assertThat(wrongResult).isNotNull()

val expectedWrongResult = ParseResult(
status = "Invalid address",
chain_name = null,
address_kind = null
)

assertThat(wrongResult).isEqualTo(expectedWrongResult)
}
}
Loading

0 comments on commit aa732e6

Please sign in to comment.