package swiss.qpq.gajumobile.data.models

import org.junit.Assert.assertEquals
import org.junit.Test

class GridsModelsTest {

    @Test
    fun testMapToGridsSignRequest() {
        val rawMap = mapOf(
            "type" to "message",
            "payload" to "Hello world",
            "public_id" to "ak_123",
            "network_id" to "groot.mainnet",
            "grids" to "v1",
            "chain" to "groot"
        )

        val request = rawMap.toGridsSignRequest()

        assertEquals(GridsSignType.MESSAGE, request.type)
        assertEquals("Hello world", request.payload)
        assertEquals("ak_123", request.publicId)
        assertEquals("groot.mainnet", request.networkId)
        assertEquals("v1", request.grids)
        assertEquals("groot", request.chain)
    }

    @Test
    fun testMapWithUnknownType() {
        val rawMap = mapOf(
            "type" to "something_new",
            "payload" to "secret"
        )

        val request = rawMap.toGridsSignRequest()

        assertEquals(GridsSignType.UNKNOWN, request.type)
        assertEquals("secret", request.payload)
    }

    @Test
    fun testToProtocolString() {
        assertEquals("message", GridsSignType.MESSAGE.toProtocolString())
        assertEquals("binary", GridsSignType.BINARY.toProtocolString())
        assertEquals("tx", GridsSignType.TX.toProtocolString())
        assertEquals("unknown", GridsSignType.UNKNOWN.toProtocolString())
    }
}
