From 939351df4da011a953f70f25c7879146d6d672e3 Mon Sep 17 00:00:00 2001 From: Erwin Kok Date: Thu, 27 Jul 2023 13:45:43 +0200 Subject: [PATCH] Updated dependencies. Small improvements --- README.md | 57 +++++++++--- build.gradle.kts | 2 +- gradle/libs.versions.toml | 6 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../multiformat/multiaddress/Multiaddress.kt | 3 - .../multistream/MultistreamMuxer.kt | 18 ++-- .../multiformat/multistream/ProtocolId.kt | 2 +- .../multiformat/multihash/MultihashTest.kt | 9 +- .../multistream/MultistreamMuxerTest.kt | 88 +++++++++---------- .../multiformat/multistream/ProtocolIdTest.kt | 10 +-- 10 files changed, 116 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index b20a679..ce1473c 100644 --- a/README.md +++ b/README.md @@ -40,35 +40,72 @@ Next to this, it also implements Cid: https://github.com/multiformats/cid This project is using the [result-monad](https://github.com/erwin-kok/result-monad) This means that (almost) all methods of this project return a `Result<...>`. The caller can check whether an error was generated, -or it can use the value. For example: +or it can use the value. + +## Usage + +A (very) brief description on how to use multiformats: + +...but please also look at the various tests. + +### multiaddr ```kotlin -val selected = MultistreamMuxer.selectOneOf(setOf("/a", "/b", "/c"), connection) +val addr1 = Multiaddress.fromString("/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234") .getOrElse { - log.error { "Error selecting protocol: ${errorMessage(it)}" } + log.error { "Could not parse Multiaddress: ${errorMessage(it)}" } return Err(it) } +val ip6Addr = Multiaddress.fromString("/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095").getOrThrow() +val tcpAddr = Multiaddress.fromString("/tcp/8000").getOrThrow() +val webAddr = Multiaddress.fromString("/ws").getOrThrow() +val actual1 = Multiaddress.fromString("/").expectNoErrors() + .encapsulate(ip6Addr).expectNoErrors() + .encapsulate(tcpAddr).expectNoErrors() + .encapsulate(webAddr).expectNoErrors() + .toString() ``` -In the examples below `OnFailure` is used as a convenience, but other methods can be used as well. +### multibase -If you would like to throw the Error instead, do: +```kotlin +val multibase = Multibase.encode("base16", "foobar".toByteArray()).getOrThrow() +val bytes = Multibase.decode("f666f6f626172").getOrThrow() +``` + +### multicodec +```kotlin +val codec = Multicodec.nameToType("cidv2") +``` +### multihash ```kotlin -val selected = MultistreamMuxer.selectOneOf(setOf("/a", "/b", "/c"), connection).getOrThrow() +val multihash = Multihash.fromBase58("QmPfjpVaf593UQJ9a5ECvdh2x17XuJYG5Yanv5UFnH3jPE") +``` + +### multistream-select + +```kotlin +val selected = MultistreamMuxer.selectOneOf(setOf("/a", "/b", "/c"), connection) + .getOrElse { + log.error { "Error selecting protocol: ${errorMessage(it)}" } + return Err(it) + } ``` -This will return the key pair when no error occurred, and throws an `Error` exception when an error occurred. ## Sub-modules -This project has three sub-modules: +This project has three submodules: +```shell git submodule add https://github.com/multiformats/multicodec src/main/kotlin/org/erwinkok/multiformat/spec/multicodec - git submodule add https://github.com/multiformats/multibase src/main/kotlin/org/erwinkok/multiformat/spec/multibase - git submodule add https://github.com/multiformats/multihash src/main/kotlin/org/erwinkok/multiformat/spec/multihash +``` + +These are the official specifications repositories, which are used here for auto-generation code and or verifying the +test results are according to spec. ## Contributing diff --git a/build.gradle.kts b/build.gradle.kts index 3724780..a0aaa68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,7 +30,7 @@ repositories { } group = "org.erwinkok.multiformat" -version = "1.0.0" +version = "1.1.0" java { withSourcesJar() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a7684bc..6d3c52a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] -kotlinx-coroutines = "1.7.2" +kotlinx-coroutines = "1.7.3" kotlinx-atomicfu = "0.21.0" kotlin-logging = "3.0.5" kotlinx-serialization = "1.5.1" -junit-jupiter = "5.9.3" +junit-jupiter = "5.10.0" slf4j-api = "2.0.7" kotlin = "1.9.0" @@ -17,7 +17,7 @@ protobuf-plugin = "0.9.3" ipaddress = "5.4.0" ktor = "2.3.2" -result-monad = "1.3.0" +result-monad = "1.4.0" [libraries] kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d..17a8ddc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/org/erwinkok/multiformat/multiaddress/Multiaddress.kt b/src/main/kotlin/org/erwinkok/multiformat/multiaddress/Multiaddress.kt index f1ef952..ef72286 100644 --- a/src/main/kotlin/org/erwinkok/multiformat/multiaddress/Multiaddress.kt +++ b/src/main/kotlin/org/erwinkok/multiformat/multiaddress/Multiaddress.kt @@ -1,7 +1,6 @@ // Copyright (c) 2022 Erwin Kok. BSD-3-Clause license. See LICENSE file for more details. package org.erwinkok.multiformat.multiaddress -import mu.KotlinLogging import org.erwinkok.multiformat.multiaddress.components.Component import org.erwinkok.multiformat.multibase.Multibase import org.erwinkok.multiformat.multihash.Multihash @@ -14,8 +13,6 @@ import org.erwinkok.result.getOrElse import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream -private val logger = KotlinLogging.logger {} - class Multiaddress private constructor(val components: List) { private val _string: String by lazy { constructString() } val bytes: ByteArray by lazy { constructBytes() } diff --git a/src/main/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxer.kt b/src/main/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxer.kt index 3dbeb3f..3135d11 100644 --- a/src/main/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxer.kt +++ b/src/main/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxer.kt @@ -5,9 +5,10 @@ import io.ktor.util.collections.ConcurrentSet import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch +import mu.KotlinLogging import org.erwinkok.result.Err import org.erwinkok.result.Error -import org.erwinkok.result.Errors +import org.erwinkok.result.Errors.EndOfStream import org.erwinkok.result.Ok import org.erwinkok.result.Result import org.erwinkok.result.getOrElse @@ -16,6 +17,8 @@ import org.erwinkok.result.onFailure import org.erwinkok.result.onSuccess import java.util.Random +private val logger = KotlinLogging.logger {} + class MultistreamMuxer { private val handlers = ConcurrentSet>() @@ -27,7 +30,7 @@ class MultistreamMuxer { val result = mutableListOf() val token = readNextToken(connection) .getOrElse { - if (it == Errors.EndOfStream) { + if (it == EndOfStream) { return Ok(result) } return Err(it) @@ -48,6 +51,9 @@ class MultistreamMuxer { while (true) { val nextToken = readNextToken(connection) .getOrElse { + if (it == EndOfStream) { + return Err(ErrEndNegotiating) + } return Err(it) } if (nextToken == LS) { @@ -57,6 +63,7 @@ class MultistreamMuxer { } else { val handler = findHandler(nextToken) if (handler == null) { + logger.debug { "MultistreamMuxer: We do not support requested protocol $nextToken" } connection.writeUtf8(NA) .onFailure { return Err(it) } } else { @@ -103,7 +110,7 @@ class MultistreamMuxer { } private fun findHandler(token: String): ProtocolHandlerInfo? { - val protocol = ProtocolId.from(token) + val protocol = ProtocolId.of(token) for (handler in handlers) { if (handler.match(protocol)) { return handler @@ -127,9 +134,10 @@ class MultistreamMuxer { private const val initiator = "initiator" private const val responder = "responder" + private val ErrIncorrectVersion = Error("client connected with incorrect version") private val ErrNoProtocols = Error("no protocols specified") private val ErrNotSupported = Error("Peer does not support any of the given protocols") - private val ErrIncorrectVersion = Error("client connected with incorrect version") + private val ErrEndNegotiating = Error("end negotiating: we do not support any of the requested protocols") suspend fun selectOneOf(protocols: Set, connection: Utf8Connection): Result { if (protocols.isEmpty()) { @@ -245,7 +253,7 @@ class MultistreamMuxer { while (true) { val nextToken = readNextToken(connection) .getOrElse { - if (it == Errors.EndOfStream) { + if (it == EndOfStream) { return Err(ErrNotSupported) } return Err(it) diff --git a/src/main/kotlin/org/erwinkok/multiformat/multistream/ProtocolId.kt b/src/main/kotlin/org/erwinkok/multiformat/multistream/ProtocolId.kt index d3c88cf..07dab1e 100644 --- a/src/main/kotlin/org/erwinkok/multiformat/multistream/ProtocolId.kt +++ b/src/main/kotlin/org/erwinkok/multiformat/multistream/ProtocolId.kt @@ -30,7 +30,7 @@ class ProtocolId private constructor(val id: String) { val Null = ProtocolId(UnknownProtocolId) - fun from(key: String?): ProtocolId { + fun of(key: String?): ProtocolId { if (key.isNullOrBlank() || key == UnknownProtocolId) { return Null } diff --git a/src/test/kotlin/org/erwinkok/multiformat/multihash/MultihashTest.kt b/src/test/kotlin/org/erwinkok/multiformat/multihash/MultihashTest.kt index 48a442e..407b0be 100644 --- a/src/test/kotlin/org/erwinkok/multiformat/multihash/MultihashTest.kt +++ b/src/test/kotlin/org/erwinkok/multiformat/multihash/MultihashTest.kt @@ -19,7 +19,7 @@ internal class MultihashTest { private val MaxVarintLen64 = 10 @Test - fun toB58String() { + fun base58String() { val src = "QmPfjpVaf593UQJ9a5ECvdh2x17XuJYG5Yanv5UFnH3jPE" val expected = Hex.decode("122013bf801597d74a660453412635edd8c34271e5998f801fac5d700c6ce8d8e461").expectNoErrors() val multihash = Multihash.fromBase58(src).expectNoErrors() @@ -27,13 +27,6 @@ internal class MultihashTest { assertEquals(src, multihash.base58()) } - @Test - fun fromB58String() { - val src = "QmPfjpVaf593UQJ9a5ECvdh2x17XuJYG5Yanv5UFnH3jPE" - val expected = Hex.decode("122013bf801597d74a660453412635edd8c34271e5998f801fac5d700c6ce8d8e461").expectNoErrors() - assertArrayEquals(Multihash.fromBase58(src).expectNoErrors().bytes(), expected) - } - @Test fun encodeName() { val digest = Hex.decode("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33").expectNoErrors() diff --git a/src/test/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxerTest.kt b/src/test/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxerTest.kt index f258706..f42344f 100644 --- a/src/test/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxerTest.kt +++ b/src/test/kotlin/org/erwinkok/multiformat/multistream/MultistreamMuxerTest.kt @@ -46,7 +46,7 @@ internal class MultistreamMuxerTest { "/proto1", ) - val selectOneResult = MultistreamMuxer.selectOneOf(setOf(ProtocolId.from("/proto1")), localConnection).expectNoErrors() + val selectOneResult = MultistreamMuxer.selectOneOf(setOf(ProtocolId.of("/proto1")), localConnection).expectNoErrors() assertEquals("/proto1", selectOneResult.id) remoteReceived( @@ -66,11 +66,11 @@ internal class MultistreamMuxerTest { val selectOneResult = MultistreamMuxer.selectOneOf( setOf( - ProtocolId.from("/proto1"), - ProtocolId.from("/proto2"), - ProtocolId.from("/proto3"), - ProtocolId.from("/proto4"), - ProtocolId.from("/proto5"), + ProtocolId.of("/proto1"), + ProtocolId.of("/proto2"), + ProtocolId.of("/proto3"), + ProtocolId.of("/proto4"), + ProtocolId.of("/proto5"), ), localConnection, ).expectNoErrors() @@ -91,7 +91,7 @@ internal class MultistreamMuxerTest { "na", ) - val selectOneResult = MultistreamMuxer.selectOneOf(setOf(ProtocolId.from("/proto2")), localConnection) + val selectOneResult = MultistreamMuxer.selectOneOf(setOf(ProtocolId.of("/proto2")), localConnection) assertEquals(Error("Peer does not support any of the given protocols"), selectOneResult.getError()) remoteReceived( @@ -107,7 +107,7 @@ internal class MultistreamMuxerTest { "/proto3", ) - muxer.addHandler(ProtocolId.from("/proto3")) + muxer.addHandler(ProtocolId.of("/proto3")) val negotiateResult = muxer.negotiate(localConnection).expectNoErrors() assertEquals("/proto3", negotiateResult.protocol.id) assertEquals(null, negotiateResult.handler) @@ -127,7 +127,7 @@ internal class MultistreamMuxerTest { ) var hit = false - muxer.addHandler(ProtocolId.from("/proto4")) { protocol, connection -> + muxer.addHandler(ProtocolId.of("/proto4")) { protocol, connection -> assertEquals("AProtocol", protocol.id) assertSame(remoteConnection, connection) hit = true @@ -136,7 +136,7 @@ internal class MultistreamMuxerTest { val negotiateResult = muxer.negotiate(localConnection).expectNoErrors() assertEquals("/proto4", negotiateResult.protocol.id) assertNotNull(negotiateResult.handler) - negotiateResult.handler?.invoke(ProtocolId.from("AProtocol"), remoteConnection) + negotiateResult.handler?.invoke(ProtocolId.of("AProtocol"), remoteConnection) assertTrue(hit) remoteReceived( @@ -167,31 +167,31 @@ internal class MultistreamMuxerTest { @Test fun protocolNegotiation() = runTest { val mux = MultistreamMuxer() - mux.addHandler(ProtocolId.from("/a")) - mux.addHandler(ProtocolId.from("/b")) - mux.addHandler(ProtocolId.from("/c")) + mux.addHandler(ProtocolId.of("/a")) + mux.addHandler(ProtocolId.of("/b")) + mux.addHandler(ProtocolId.of("/c")) val job = launch { val selected = mux.negotiate(localConnection).expectNoErrors() assertEquals("/a", selected.protocol.id, "incorrect protocol selected") } - MultistreamMuxer.selectProtoOrFail(ProtocolId.from("/a"), remoteConnection).expectNoErrors() + MultistreamMuxer.selectProtoOrFail(ProtocolId.of("/a"), remoteConnection).expectNoErrors() job.join() } @Test fun selectOne() = runTest { - muxer.addHandler(ProtocolId.from("/a")) - muxer.addHandler(ProtocolId.from("/b")) - muxer.addHandler(ProtocolId.from("/c")) + muxer.addHandler(ProtocolId.of("/a")) + muxer.addHandler(ProtocolId.of("/b")) + muxer.addHandler(ProtocolId.of("/c")) val job = launch { val selected = muxer.negotiate(localConnection).expectNoErrors() assertEquals("/c", selected.protocol.id, "incorrect protocol selected") } val selected = MultistreamMuxer.selectOneOf( setOf( - ProtocolId.from("/d"), - ProtocolId.from("/e"), - ProtocolId.from("/c"), + ProtocolId.of("/d"), + ProtocolId.of("/e"), + ProtocolId.of("/c"), ), remoteConnection, ).expectNoErrors() @@ -201,38 +201,38 @@ internal class MultistreamMuxerTest { @Test fun selectFails() = runTest { - muxer.addHandler(ProtocolId.from("/a")) - muxer.addHandler(ProtocolId.from("/b")) - muxer.addHandler(ProtocolId.from("/c")) + muxer.addHandler(ProtocolId.of("/a")) + muxer.addHandler(ProtocolId.of("/b")) + muxer.addHandler(ProtocolId.of("/c")) val job = launch { muxer.negotiate(localConnection) localConnection.close() } - coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectOneOf(setOf(ProtocolId.from("/d"), ProtocolId.from("/e")), remoteConnection) } + coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectOneOf(setOf(ProtocolId.of("/d"), ProtocolId.of("/e")), remoteConnection) } remoteConnection.close() job.join() } @Test fun removeProtocol() = runTest { - muxer.addHandler(ProtocolId.from("/a")) - muxer.addHandler(ProtocolId.from("/b")) - muxer.addHandler(ProtocolId.from("/c")) + muxer.addHandler(ProtocolId.of("/a")) + muxer.addHandler(ProtocolId.of("/b")) + muxer.addHandler(ProtocolId.of("/c")) assertEquals(listOf("/a", "/b", "/c"), muxer.protocols().map { it.id }.sorted()) - muxer.removeHandler(ProtocolId.from("/b")) + muxer.removeHandler(ProtocolId.of("/b")) assertEquals(listOf("/a", "/c"), muxer.protocols().map { it.id }.sorted()) } @Test fun handleFunc() = runTest { - muxer.addHandler(ProtocolId.from("/a")) - muxer.addHandler(ProtocolId.from("/b")) - muxer.addHandler(ProtocolId.from("/c")) { p, _ -> - assertEquals(ProtocolId.from("/c"), p, "incorrect protocol selected") + muxer.addHandler(ProtocolId.of("/a")) + muxer.addHandler(ProtocolId.of("/b")) + muxer.addHandler(ProtocolId.of("/c")) { p, _ -> + assertEquals(ProtocolId.of("/c"), p, "incorrect protocol selected") Ok(Unit) } val job = launch { - MultistreamMuxer.selectProtoOrFail(ProtocolId.from("/c"), localConnection).expectNoErrors() + MultistreamMuxer.selectProtoOrFail(ProtocolId.of("/c"), localConnection).expectNoErrors() } val job2 = muxer.handle(this, remoteConnection).expectNoErrors() job.join() @@ -241,12 +241,12 @@ internal class MultistreamMuxerTest { @Test fun simOpenClientServer() = runTest { - muxer.addHandler(ProtocolId.from("/a")) + muxer.addHandler(ProtocolId.of("/a")) val job = launch { val selected = muxer.negotiate(localConnection).expectNoErrors() assertEquals("/a", selected.protocol.id, "incorrect protocol selected") } - val simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/a")), remoteConnection).expectNoErrors() + val simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/a")), remoteConnection).expectNoErrors() assertEquals("/a", simOpenInfo.protocol.id, "incorrect protocol selected") assertFalse(simOpenInfo.server) job.join() @@ -254,11 +254,11 @@ internal class MultistreamMuxerTest { @Test fun simOpenClientServerFail() = runTest { - muxer.addHandler(ProtocolId.from("/a")) + muxer.addHandler(ProtocolId.of("/a")) launch { - coAssertErrorResult("EndOfStream") { muxer.negotiate(localConnection) } + coAssertErrorResult("end negotiating: we do not support any of the requested protocols") { muxer.negotiate(localConnection) } } - coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/b")), remoteConnection) } + coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/b")), remoteConnection) } remoteConnection.close() } @@ -266,10 +266,10 @@ internal class MultistreamMuxerTest { fun simOpenClientClient() = runTest { var simOpenInfo: SimOpenInfo? = null val job = launch { - simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/a")), remoteConnection).expectNoErrors() + simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/a")), remoteConnection).expectNoErrors() assertEquals("/a", simOpenInfo!!.protocol.id, "incorrect protocol selected") } - val simOpenInfo2 = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/a")), localConnection).expectNoErrors() + val simOpenInfo2 = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/a")), localConnection).expectNoErrors() assertEquals("/a", simOpenInfo2.protocol.id, "incorrect protocol selected") job.join() assertNotEquals(simOpenInfo!!.server, simOpenInfo2.server) @@ -279,10 +279,10 @@ internal class MultistreamMuxerTest { fun simOpenClientClient2() = runTest { var simOpenInfo: SimOpenInfo? = null val job = launch { - simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/a"), ProtocolId.from("/b")), remoteConnection).expectNoErrors() + simOpenInfo = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/a"), ProtocolId.of("/b")), remoteConnection).expectNoErrors() assertEquals("/b", simOpenInfo!!.protocol.id, "incorrect protocol selected") } - val simOpenInfo2 = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/b")), localConnection).expectNoErrors() + val simOpenInfo2 = MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/b")), localConnection).expectNoErrors() assertEquals("/b", simOpenInfo2.protocol.id, "incorrect protocol selected") job.join() assertNotEquals(simOpenInfo!!.server, simOpenInfo2.server) @@ -291,10 +291,10 @@ internal class MultistreamMuxerTest { @Test fun simOpenClientClientFail() = runTest { val job = launch { - coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/a")), remoteConnection) } + coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/a")), remoteConnection) } remoteConnection.close() } - coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.from("/b")), localConnection) } + coAssertErrorResult("Peer does not support any of the given protocols") { MultistreamMuxer.selectWithSimopenOrFail(setOf(ProtocolId.of("/b")), localConnection) } localConnection.close() job.join() } diff --git a/src/test/kotlin/org/erwinkok/multiformat/multistream/ProtocolIdTest.kt b/src/test/kotlin/org/erwinkok/multiformat/multistream/ProtocolIdTest.kt index 80c3e8b..a53d02e 100644 --- a/src/test/kotlin/org/erwinkok/multiformat/multistream/ProtocolIdTest.kt +++ b/src/test/kotlin/org/erwinkok/multiformat/multistream/ProtocolIdTest.kt @@ -12,19 +12,19 @@ import org.junit.jupiter.api.Test internal class ProtocolIdTest { @Test fun sameProtocol() { - assertSame(ProtocolId.from("/abc"), ProtocolId.from("/abc")) + assertSame(ProtocolId.of("/abc"), ProtocolId.of("/abc")) } @Test fun notTheSameProtocol() { - assertNotSame(ProtocolId.from("/abc"), ProtocolId.from("/def")) + assertNotSame(ProtocolId.of("/abc"), ProtocolId.of("/def")) } @Test fun nullProtocol() { - assertSame(ProtocolId.Null, ProtocolId.from("")) - assertSame(ProtocolId.Null, ProtocolId.from("")) - assertSame(ProtocolId.Null, ProtocolId.from(null)) + assertSame(ProtocolId.Null, ProtocolId.of("")) + assertSame(ProtocolId.Null, ProtocolId.of("")) + assertSame(ProtocolId.Null, ProtocolId.of(null)) assertEquals("", ProtocolId.Null.id) } }