2023-12-01 22:43:21 +03:00
|
|
|
import unittest
|
|
|
|
|
2024-07-17 13:46:43 +03:00
|
|
|
import app/modules/shared_modules/wallet_connect/helpers
|
|
|
|
|
2023-12-01 22:43:21 +03:00
|
|
|
suite "wallet connect":
|
|
|
|
|
2024-07-17 13:46:43 +03:00
|
|
|
test "hexToDec":
|
|
|
|
check(hexToDec("0x3") == "3")
|
|
|
|
check(hexToDec("f") == "15")
|
|
|
|
|
2024-09-16 19:19:36 +02:00
|
|
|
test "convertFloatFeesInfoToHex":
|
|
|
|
const feesInfoJson = "{\"maxFees\":24528.282681,\"maxFeePerGas\":1.168013461,\"maxPriorityFeePerGas\":0.036572351,\"gasPrice\":1.168013461}"
|
|
|
|
|
|
|
|
check(convertFeesInfoToHex(feesInfoJson) == """{"maxFeePerGas":"0x459E7895","maxPriorityFeePerGas":"0x22E0CBF"}""")
|
|
|
|
|
|
|
|
test "convertTextFeesInfoToHex":
|
|
|
|
const feesInfoJson = "{\"maxFees\":\"24528.282681\",\"maxFeePerGas\":\"1.168013461\",\"maxPriorityFeePerGas\":\"0.036572351\",\"gasPrice\":\"1.168013461\"}"
|
|
|
|
|
|
|
|
check(convertFeesInfoToHex(feesInfoJson) == """{"maxFeePerGas":"0x459E7895","maxPriorityFeePerGas":"0x22E0CBF"}""")
|
|
|
|
|
|
|
|
test "convertMixedTextAndFloatFeesInfoToHex":
|
|
|
|
const feesInfoJson = "{\"maxFees\":\"24528.282681\",\"maxFeePerGas\":1.168013461,\"maxPriorityFeePerGas\":\"0.036572351\",\"gasPrice\":\"1.168013461\"}"
|
2024-07-17 13:46:43 +03:00
|
|
|
|
|
|
|
check(convertFeesInfoToHex(feesInfoJson) == """{"maxFeePerGas":"0x459E7895","maxPriorityFeePerGas":"0x22E0CBF"}""")
|