diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/TestFactory.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/TestFactory.kt index 237f54ce1..b0a878b27 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/TestFactory.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/TestFactory.kt @@ -313,6 +313,7 @@ class TestChain : DYDXChainTransactionsProtocol { var cancelOrderResponse: String? = null var depositResponse: String? = null var withdrawResponse: String? = null + var signCompliancePayload: String? = null var transactionCallback: ((response: String?) -> Unit)? = null @@ -377,10 +378,22 @@ class TestChain : DYDXChainTransactionsProtocol { withdraw(paramsInJson!!, callback) } + TransactionType.SignCompliancePayload -> { + signCompliancePayload(paramsInJson!!, callback) + } + else -> {} } } + fun signCompliancePayload(json: String, callback: (response: String?) -> Unit) { + if (signCompliancePayload != null) { + callback(signCompliancePayload) + } else { + callback(dummyError) + } + } + fun getHeight(callback: (response: String?) -> Unit) { if (heightResponse != null) { callback(heightResponse) diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4RestrictionsTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4RestrictionsTests.kt index c3312c4fc..8f5333090 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4RestrictionsTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4RestrictionsTests.kt @@ -148,14 +148,36 @@ class V4RestrictionsTests { fun testGeoEndpointHandling() { reset() - val testAddress = "cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm" + testChain!!.signCompliancePayload = """ + { + "signedMessage": "1", + "publicKey": "1", + "timestamp": "2024-05-14T20:40:00.415Z" + } + """.trimIndent() + testRest?.setResponse( + "https://indexer.v4staging.dydx.exchange/v4/compliance/geoblock", + """ + { + "status": "CLOSE_ONLY", + "reason": null, + "updatedAt": "2024-05-14T20:40:00.415Z" + } + """.trimIndent(), + ) + + setStateMachineConnected(stateManager) + val testAddress = "cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm" + stateManager.setAddresses(null, testAddress) testRest?.setResponse( - "https://indexer.v4staging.dydx.exchange/v4/compliance/screen", + "https://indexer.v4staging.dydx.exchange/v4/compliance/screen/$testAddress", """ { - "restricted": false + "status": "CLOSE_ONLY", + "reason": null, + "updatedAt": "2024-05-14T20:40:00.415Z" } """.trimIndent(), ) @@ -171,9 +193,6 @@ class V4RestrictionsTests { """.trimIndent(), ) - setStateMachineConnected(stateManager) - stateManager.setAddresses(null, testAddress) - stateManager.triggerCompliance(ComplianceAction.CONNECT) { successful, error, data -> print("") } @@ -190,10 +209,11 @@ class V4RestrictionsTests { "Expected different updatedAt", ) + // expires at is 7 days in advance assertEquals( - "2024-05-27T20:40:00.415Z", + "2024-05-21T20:40:00.415Z", stateManager.adaptor?.stateMachine?.state?.compliance?.expiresAt, - "Expected different updatedAt", + "Expected different expires at", ) } }