From d7f74a6529d4fbaa800d87f269a438142e92666c Mon Sep 17 00:00:00 2001 From: Matt Jones <885417+jonesmac@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:57:49 -0500 Subject: [PATCH] add method to hash payload and test it --- .../androidTest/java/network/xyo/client/XyoPayloadTest.kt | 6 ++++++ sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt b/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt index 1697988..e9e8c29 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt @@ -109,4 +109,10 @@ class XyoPayloadTest { assertNotNull(bwMirrored) } } + + @Test + fun testHashing() { + val payload = TestConstants.debugPayload + assertEquals(payload.hash(), TestConstants.debugPayloadHash) + } } \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt index feb9f61..7b7e399 100644 --- a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt +++ b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt @@ -20,4 +20,8 @@ open class XyoPayload(): Payload, XyoSerializable() { throw XyoInvalidSchemaException(schema) } } + + open fun hash(): String { + return sha256String(this) + } } \ No newline at end of file