-
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.
Merge branch 'main' into plew.fix-test-upload
* main: Copy json schema and test vectors from tbdex submodule (#124)
- Loading branch information
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
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())) | ||
} | ||
} |
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
Oops, something went wrong.