-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from uma-universal-money-address/feat/trformat
Add travelRuleFormat field to the payerdata compliance
- Loading branch information
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,19 @@ package me.uma | |
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.fail | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.serialization.json.Json | ||
import me.uma.crypto.Secp256k1 | ||
import me.uma.protocol.KycStatus | ||
import me.uma.protocol.PayerDataOptions | ||
import me.uma.protocol.TravelRuleFormat | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
class UmaTests { | ||
val keys = Secp256k1.generateKeyPair() | ||
|
||
@Test | ||
fun `test serialize PayerDataOptions`() = runTest { | ||
val payerDataOptions = PayerDataOptions( | ||
|
@@ -22,4 +28,31 @@ class UmaTests { | |
Json.decodeFromString(PayerDataOptions.serializer(), json), | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalStdlibApi::class) | ||
@Test | ||
fun `test create and parse payreq`() = runTest { | ||
val travelRuleInfo = "travel rule info" | ||
val payreq = UmaProtocolHelper().getPayRequest( | ||
receiverEncryptionPubKey = keys.publicKey, | ||
sendingVaspPrivateKey = keys.privateKey, | ||
currencyCode = "USD", | ||
amount = 100, | ||
payerIdentifier = "[email protected]", | ||
payerKycStatus = KycStatus.VERIFIED, | ||
utxoCallback = "https://example.com/utxo", | ||
travelRuleInfo = "travel rule info", | ||
travelRuleFormat = TravelRuleFormat("someFormat", "1.0"), | ||
) | ||
val json = payreq.toJson() | ||
val decodedPayReq = UmaProtocolHelper().parseAsPayRequest(json) | ||
assertEquals(payreq, decodedPayReq) | ||
|
||
val encryptedTravelRuleInfo = | ||
decodedPayReq.payerData.compliance?.travelRuleInfo ?: fail("travel rule info not found") | ||
assertEquals( | ||
travelRuleInfo, | ||
String(Secp256k1.decryptEcies(encryptedTravelRuleInfo.hexToByteArray(), keys.privateKey)), | ||
) | ||
} | ||
} |