From 226af8b663694192d953d8cc85ccf5787f0ef2b1 Mon Sep 17 00:00:00 2001 From: jeremy lee Date: Fri, 31 May 2024 22:36:42 -0400 Subject: [PATCH] begin integration test --- .../router/skip/SkipProcessorTests.kt | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt index 0c98fa6a7..ff4d10edb 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/processor/router/skip/SkipProcessorTests.kt @@ -4,6 +4,7 @@ import exchange.dydx.abacus.output.input.TransferInputChainResource import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.state.internalstate.InternalTransferInputState import exchange.dydx.abacus.tests.payloads.SkipChainsMock +import exchange.dydx.abacus.tests.payloads.SkipRouteMock import exchange.dydx.abacus.tests.payloads.SkipTokensMock import exchange.dydx.abacus.utils.Parser import kotlinx.serialization.json.Json @@ -23,6 +24,7 @@ class SkipProcessorTests { internal val skipProcessor = SkipProcessor(parser = parser, internalState = internalState) internal val skipChainsMock = SkipChainsMock() internal val skipTokensMock = SkipTokensMock() + internal val skipRouteMock = SkipRouteMock() internal val selectedChainId = "osmosis-1" internal val selectedTokenAddress = "selectedTokenDenom" internal val selectedTokenSymbol = "selectedTokenSymbol" @@ -303,9 +305,34 @@ class SkipProcessorTests { assertEquals(expectedTokenResources, internalState.tokenResources) } -// @Test -// fun testReceivedRoute() { -// val payload = SkipRouteMock().payload -// -// } + @Test + fun testReceivedRoute() { + val payload = templateToJson(skipRouteMock.payload) + val result = skipProcessor.receivedRoute( + existing = mapOf(), + payload = payload, + requestId = null, + ) + val expected = mapOf( + "transfer" to mapOf( + "route" to mapOf( +// TODO: set up text properly so we get a decimals value + "toAmountUSD" to 11640000, + "toAmount" to 11.64, + "bridgeFees" to .36, + "slippage" to "1", + "requestPayload" to mapOf( + "targetAddress" to "0xBC8552339dA68EB65C8b88B414B5854E0E366cFc", + "data" to "d77d6ec00000000000000000000000000000000000000000000000000000000000b19cc000000000000000000000000000000000000000000000000000000000000000040000000000000000000000009dc5ce8a5722795f5723d32b921c53d3bb449348000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000057e40000000000000000000000000691cf4641d5608f085b2c1921172120bb603d074", + "value" to "0", + "fromChainId" to "1", + "fromAddress" to "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + "toChainId" to "noble-1", + "toAddress" to "uusdc", + ), + ), + ), + ) + assertEquals(expected.toString(), result.toString()) + } }