Skip to content

Commit

Permalink
add v2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed May 20, 2024
1 parent eefc095 commit 8f2d9eb
Showing 1 changed file with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import exchange.dydx.abacus.app.manager.TestChain
import exchange.dydx.abacus.app.manager.TestRest
import exchange.dydx.abacus.app.manager.TestState
import exchange.dydx.abacus.app.manager.TestWebSocket
import exchange.dydx.abacus.output.ComplianceAction
import exchange.dydx.abacus.output.ComplianceStatus
import exchange.dydx.abacus.output.Restriction
import exchange.dydx.abacus.payload.BaseTests
import exchange.dydx.abacus.state.manager.setAddresses
Expand Down Expand Up @@ -94,6 +96,88 @@ class V4RestrictionsTests : NetworkTests() {
)
}

@Test
fun testGeoEndpointHandling() {
reset()

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(),
)
testRest?.setResponse(
"https://indexer.v4staging.dydx.exchange/v4/compliance/screen/$testCosmoAddress",
"""
{
"status": "CLOSE_ONLY",
"reason": null,
"updatedAt": "2024-05-14T20:40:00.415Z"
}
""".trimIndent(),
)

setStateMachineConnected(stateManager)
stateManager.setAddresses(null, testCosmoAddress)

testRest?.setResponse(
"https://indexer.v4staging.dydx.exchange/v4/compliance/screen/$testCosmoAddress",
"""
{
"status": "CLOSE_ONLY",
"reason": null,
"updatedAt": "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(),
)

stateManager.triggerCompliance(ComplianceAction.CONNECT) { successful, error, data ->
print("")
}

assertEquals(
ComplianceStatus.CLOSE_ONLY,
stateManager.adaptor?.stateMachine?.state?.compliance?.status,
"Expected CLOSE_ONLY restriction",
)

assertEquals(
"2024-05-14T20:40:00.415Z",
stateManager.adaptor?.stateMachine?.state?.compliance?.updatedAt,
"Expected different updatedAt",
)

// expires at is 7 days in advance
assertEquals(
"2024-05-21T20:40:00.415Z",
stateManager.adaptor?.stateMachine?.state?.compliance?.expiresAt,
"Expected different expires at",
)
}

// @Test
// fun whenUserRestricted() {
// reset()
Expand Down

0 comments on commit 8f2d9eb

Please sign in to comment.