Skip to content

Commit

Permalink
Merge pull request #5 from input-output-hk/refactor
Browse files Browse the repository at this point in the history
Refactor: Update to new version of Apollo v1.6.0-alpha
  • Loading branch information
hamada147 committed Feb 22, 2023
2 parents 62a5bd9 + a1abdd3 commit a38df84
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 64 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
}
}

version = "1.0.0-alpha"
version = "1.0.1-alpha"
group = "io.iohk.atala.prism"

allprojects {
Expand Down
2 changes: 1 addition & 1 deletion didcomm/didcomm.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'didcomm'
spec.version = '1.0.0-alpha'
spec.version = '1.0.1-alpha'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = 'IOG'
Expand Down
5 changes: 4 additions & 1 deletion didpeer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.iohk.atala.prism:multibase:1.0.0-alpha")
implementation("io.iohk.atala.prism:multibase:1.6.0-alpha")
implementation("io.iohk.atala.prism:varint:1.6.0-alpha")
implementation("io.iohk.atala.prism:base64:1.6.0-alpha")
implementation("io.iohk.atala.prism:base58:1.6.0-alpha")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation("com.squareup.okio:okio:3.2.0")
}
Expand Down
2 changes: 1 addition & 1 deletion didpeer/didpeer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'didpeer'
spec.version = '1.0.0-alpha'
spec.version = '1.0.1-alpha'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = 'IOG'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.iohk.atala.prism.didcomm.didpeer.core

import io.iohk.atala.prism.apollo.varint.VarInt
import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAgreement
import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAuthentication
import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypePeerDID
Expand All @@ -13,15 +14,15 @@ enum class Codec(val prefix: Int) {
fun toMulticodec(value: ByteArray, keyType: VerificationMethodTypePeerDID): ByteArray {
val prefix = getCodec(keyType).prefix
val byteBuffer = Buffer()
VarInt.writeVarInt(prefix, byteBuffer)
VarInt.write(prefix, byteBuffer)
return byteBuffer.readByteArray().plus(value)
}

fun fromMulticodec(value: ByteArray): Pair<Codec, ByteArray> {
val prefix = VarInt.readVarInt(Buffer().write(value))
val prefix = VarInt.read(Buffer().write(value))
val codec = getCodec(prefix)
val byteBuffer = Buffer()
VarInt.writeVarInt(prefix, byteBuffer)
VarInt.write(prefix, byteBuffer)
return Pair(codec, value.drop(2).toByteArray())
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.iohk.atala.prism.didcomm.didpeer

import io.iohk.atala.prism.didcomm.didpeer.core.toJson
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
Expand Down Expand Up @@ -32,9 +31,7 @@ class TestCreateNumalgo0 {
}

@Test
@Ignore // to be removed once Base64 has been fixed
fun testCreateNumalgo0MalformedShortInceptionKey() {
// Issue with Base64
for (key in shortKeys) {
val ex = assertFails {
createPeerDIDNumalgo0(key)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
package io.iohk.atala.prism.didcomm.didpeer

import io.iohk.atala.prism.didcomm.didpeer.core.VarInt
import okio.Buffer
import kotlin.test.Test
import kotlin.test.assertEquals

class TestDemo {

@Test
fun moussaTest() {
val buffer = Buffer()
VarInt.writeVarInt(500, buffer)
val result = VarInt.readVarInt(buffer)
assertEquals(500, result)
}

@Test
fun testCreateResolvePeerDID() {
val encryptionKeys = listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
package io.iohk.atala.prism.didcomm.didpeer.core

import io.iohk.atala.prism.apollo.varint.VarInt
import okio.Buffer
import kotlin.test.Test
import kotlin.test.assertEquals

class VarIntTests {
@Test
fun testVarInt() {
val origin = 1234774
val byteBuffer = Buffer()
VarInt.writeVarInt(origin, byteBuffer)
val fin: Int = VarInt.readVarInt(byteBuffer)
assertEquals(origin, fin)
}

@Test
fun testVarIntX25519() {
val origin = Codec.X25519.prefix
val byteBuffer = Buffer()
VarInt.writeVarInt(origin, byteBuffer)
val fin: Int = VarInt.readVarInt(byteBuffer)
VarInt.write(origin, byteBuffer)
val fin: Int = VarInt.read(byteBuffer)
assertEquals(origin, fin)
}

@Test
fun testVarIntED25519() {
val origin = Codec.ED25519.prefix
val byteBuffer = Buffer()
VarInt.writeVarInt(origin, byteBuffer)
val fin: Int = VarInt.readVarInt(byteBuffer)
VarInt.write(origin, byteBuffer)
val fin: Int = VarInt.read(byteBuffer)
assertEquals(origin, fin)
}

Expand Down

0 comments on commit a38df84

Please sign in to comment.