-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy json schema and test vectors from tbdex submodule (#124)
* Copy json schema and test vectors from tbdex submodule * Update tbdex submodule to latest main * Use http git url for .gitmodules * WIP rewrite vector tests for new vector structure * Remove unused private methods * Translate external URIs to internal resource URIs * Lint * Flesh out tests and update README
- Loading branch information
Diane Huxley
authored
Jan 12, 2024
1 parent
bf5f0ae
commit fe212cb
Showing
25 changed files
with
344 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/json-schemas/reputation.schema.json" | ||
"$id": "https://tbdex.dev/reputation.schema.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 13 additions & 11 deletions
24
protocol/src/test/kotlin/tbdex/sdk/protocol/ResourceVectorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
package tbdex.sdk.protocol | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import tbdex.sdk.protocol.models.Offering | ||
import tbdex.sdk.protocol.models.Resource | ||
import tbdex.sdk.protocol.serialization.Json | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertIs | ||
import kotlin.test.assertNotNull | ||
|
||
class ResourceVectorTest { | ||
@Test | ||
fun `parse offering`() { | ||
val serializedOffering = TestVectors.offering() | ||
val offering = Resource.parse(serializedOffering) | ||
assertIs<Offering>(offering) | ||
fun `parse-offering json`() { | ||
val vector = TestVectors.getVector("parse-offering.json") | ||
assertNotNull(vector) | ||
testNonErrorTestVector<Offering>(vector) | ||
} | ||
|
||
@Test | ||
fun `serialized offering matches original`() { | ||
val serializedOffering = TestVectors.offering() | ||
val offering = Resource.parse(serializedOffering) | ||
val serializedOffering2 = Json.stringify(offering) | ||
private inline fun <reified T> testNonErrorTestVector(vector: JsonNode) { | ||
val input = vector["input"].textValue() | ||
assertNotNull(input) | ||
|
||
assertEquals(serializedOffering, serializedOffering2) | ||
} | ||
val tbDEXMessage = Resource.parse(input) | ||
assertIs<T>(tbDEXMessage) | ||
|
||
assertEquals(vector["output"], Json.jsonMapper.readTree(tbDEXMessage.toString())) | ||
} | ||
} |
Oops, something went wrong.