From 7ae48cf15cd94348fb013af207dc887fffa9efcd Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 29 Oct 2024 13:23:47 +0900 Subject: [PATCH 01/28] Added dotnet-libp2p as submodule --- .gitmodules | 3 +++ dotnet-libp2p | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 dotnet-libp2p diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..b6e88da19d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dotnet-libp2p"] + path = dotnet-libp2p + url = https://github.com/greymistcube/dotnet-libp2p diff --git a/dotnet-libp2p b/dotnet-libp2p new file mode 160000 index 0000000000..a8744645df --- /dev/null +++ b/dotnet-libp2p @@ -0,0 +1 @@ +Subproject commit a8744645dfbe6a41b85d8767e945486b86488af8 From c36b208f11004a559e12e3c42680c0d798c34fed Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 29 Oct 2024 14:04:19 +0900 Subject: [PATCH 02/28] Patched dotnet-libp2p --- dotnet-libp2p | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet-libp2p b/dotnet-libp2p index a8744645df..f863450e55 160000 --- a/dotnet-libp2p +++ b/dotnet-libp2p @@ -1 +1 @@ -Subproject commit a8744645dfbe6a41b85d8767e945486b86488af8 +Subproject commit f863450e55d526fc49cad21dc115a76a1161cb21 From c92a752b2179e40f94cfeb25f3eacbaf16cde1c7 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 29 Oct 2024 14:56:45 +0900 Subject: [PATCH 03/28] Removed Exception serialization --- .../InvalidConsensusMessageException.cs | 16 ----- .../InvalidHeightIncreasingException.cs | 18 ------ .../Consensus/InvalidMaj23Exception.cs | 26 -------- .../Consensus/InvalidProposalException.cs | 26 -------- .../Consensus/InvalidVoteException.cs | 26 -------- .../InvalidMessageContentException.cs | 20 ------- .../InvalidStateTargetException.cs | 6 -- src/Libplanet.Net/NoSwarmContextException.cs | 9 --- src/Libplanet.Net/PeerNotFoundException.cs | 9 --- .../Protocols/PeerDiscoveryException.cs | 9 --- .../Protocols/PingTimeoutException.cs | 22 ------- src/Libplanet.Net/SwarmException.cs | 9 --- .../Transports/CommunicationFailException.cs | 19 ------ .../DifferentAppProtocolVersionException.cs | 23 -------- .../Transports/InvalidCredentialException.cs | 19 ------ .../InvalidMessageSignatureException.cs | 23 -------- .../InvalidMessageTimestampException.cs | 21 ------- .../Transports/SendMessageFailException.cs | 14 ----- .../Transports/TransportException.cs | 9 --- ...rotocolVersionNotSupportedExceptionTest.cs | 26 -------- .../InsufficientBalanceExceptionTest.cs | 45 -------------- .../SupplyOverflowExceptionTest.cs | 38 ------------ ...expectedlyTerminatedActionExceptionTest.cs | 59 ------------------- .../CommunicationFailExceptionTest.cs | 59 ------------------- ...ifferentAppProtocolVersionExceptionTest.cs | 52 ---------------- .../InvalidCredentialExceptionTest.cs | 38 ------------ .../InvalidMessageSignatureExceptionTest.cs | 47 --------------- .../InvalidMessageTimestampExceptionTest.cs | 43 -------------- .../SendMessageFailExceptionTest.cs | 58 ------------------ .../Transports/TransportExceptionTest.cs | 28 --------- .../InvalidBlockBytesLengthExceptionTest.cs | 28 --------- ...alidBlockPreEvaluationHashExceptionTest.cs | 34 ----------- .../InvalidBlockTxCountExceptionTest.cs | 28 --------- ...validBlockTxCountPerSignerExceptionTest.cs | 35 ----------- .../Blocks/InvalidBlockTxHashExceptionTest.cs | 34 ----------- 35 files changed, 976 deletions(-) delete mode 100644 test/Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs delete mode 100644 test/Libplanet.Action.Tests/InsufficientBalanceExceptionTest.cs delete mode 100644 test/Libplanet.Action.Tests/SupplyOverflowExceptionTest.cs delete mode 100644 test/Libplanet.Action.Tests/UnexpectedlyTerminatedActionExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/CommunicationFailExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/DifferentAppProtocolVersionExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/InvalidCredentialExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/InvalidMessageSignatureExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/InvalidMessageTimestampExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/SendMessageFailExceptionTest.cs delete mode 100644 test/Libplanet.Net.Tests/Transports/TransportExceptionTest.cs delete mode 100644 test/Libplanet.Tests/Blocks/InvalidBlockBytesLengthExceptionTest.cs delete mode 100644 test/Libplanet.Tests/Blocks/InvalidBlockPreEvaluationHashExceptionTest.cs delete mode 100644 test/Libplanet.Tests/Blocks/InvalidBlockTxCountExceptionTest.cs delete mode 100644 test/Libplanet.Tests/Blocks/InvalidBlockTxCountPerSignerExceptionTest.cs delete mode 100644 test/Libplanet.Tests/Blocks/InvalidBlockTxHashExceptionTest.cs diff --git a/src/Libplanet.Net/Consensus/InvalidConsensusMessageException.cs b/src/Libplanet.Net/Consensus/InvalidConsensusMessageException.cs index 9e95251ac6..c99fb01cf5 100644 --- a/src/Libplanet.Net/Consensus/InvalidConsensusMessageException.cs +++ b/src/Libplanet.Net/Consensus/InvalidConsensusMessageException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net.Consensus @@ -40,20 +39,5 @@ public InvalidConsensusMessageException(string message, MessageContent receivedM : base(message, receivedMessage) { } - - /// - /// Initializes a new instance of the - /// class with serialized data. - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected InvalidConsensusMessageException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/Consensus/InvalidHeightIncreasingException.cs b/src/Libplanet.Net/Consensus/InvalidHeightIncreasingException.cs index b0b6a309cd..5883acb3b6 100644 --- a/src/Libplanet.Net/Consensus/InvalidHeightIncreasingException.cs +++ b/src/Libplanet.Net/Consensus/InvalidHeightIncreasingException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Blockchain; namespace Libplanet.Net.Consensus @@ -20,22 +19,5 @@ public InvalidHeightIncreasingException(string message) : base(message) { } - - /// - /// Initializes a new instance of the - /// class with serialized data. - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected InvalidHeightIncreasingException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/Consensus/InvalidMaj23Exception.cs b/src/Libplanet.Net/Consensus/InvalidMaj23Exception.cs index 5e570c893b..332f0c233a 100644 --- a/src/Libplanet.Net/Consensus/InvalidMaj23Exception.cs +++ b/src/Libplanet.Net/Consensus/InvalidMaj23Exception.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Consensus; namespace Libplanet.Net.Consensus @@ -43,31 +42,6 @@ public InvalidMaj23Exception(string message, Maj23 maj23) Maj23 = maj23; } - /// - /// Initializes a new instance of the - /// class with serialized data. - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected InvalidMaj23Exception(SerializationInfo info, StreamingContext context) - { - Maj23 = - info.GetValue(nameof(Maj23), typeof(Maj23)) as Maj23 ?? - throw new SerializationException( - $"{nameof(Maj23)} is expected to be a non-null {nameof(Maj23)}."); - } - public Maj23 Maj23 { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Maj23), Maj23); - } } } diff --git a/src/Libplanet.Net/Consensus/InvalidProposalException.cs b/src/Libplanet.Net/Consensus/InvalidProposalException.cs index 16b8b300f1..c76ad20633 100644 --- a/src/Libplanet.Net/Consensus/InvalidProposalException.cs +++ b/src/Libplanet.Net/Consensus/InvalidProposalException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Consensus; namespace Libplanet.Net.Consensus @@ -43,31 +42,6 @@ public InvalidProposalException(string message, Proposal proposal) Proposal = proposal; } - /// - /// Initializes a new instance of the - /// class with serialized data. - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected InvalidProposalException(SerializationInfo info, StreamingContext context) - { - Proposal = - info.GetValue(nameof(Proposal), typeof(Proposal)) as Proposal ?? - throw new SerializationException( - $"{nameof(Proposal)} is expected to be a non-null {nameof(Proposal)}."); - } - public Proposal Proposal { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Proposal), Proposal); - } } } diff --git a/src/Libplanet.Net/Consensus/InvalidVoteException.cs b/src/Libplanet.Net/Consensus/InvalidVoteException.cs index 5d3c9201e8..5a1d228300 100644 --- a/src/Libplanet.Net/Consensus/InvalidVoteException.cs +++ b/src/Libplanet.Net/Consensus/InvalidVoteException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Types.Consensus; namespace Libplanet.Net.Consensus @@ -43,31 +42,6 @@ public InvalidVoteException(string message, Vote vote) Vote = vote; } - /// - /// Initializes a new instance of the - /// class with serialized data. - /// - /// The - /// that holds the serialized object data about the exception being thrown. - /// - /// The - /// that contains contextual information about the source or destination. - /// - protected InvalidVoteException(SerializationInfo info, StreamingContext context) - { - Vote = - info.GetValue(nameof(Vote), typeof(Vote)) as Vote ?? - throw new SerializationException( - $"{nameof(Vote)} is expected to be a non-null {nameof(Vote)}."); - } - public Vote Vote { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Vote), Vote); - } } } diff --git a/src/Libplanet.Net/InvalidMessageContentException.cs b/src/Libplanet.Net/InvalidMessageContentException.cs index 830b235ffd..d3f40800f2 100644 --- a/src/Libplanet.Net/InvalidMessageContentException.cs +++ b/src/Libplanet.Net/InvalidMessageContentException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net @@ -23,25 +22,6 @@ internal InvalidMessageContentException(string message, MessageContent content) Content = content; } - protected InvalidMessageContentException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - Content = - info.GetValue(nameof(Content), typeof(MessageContent)) as MessageContent ?? - throw new SerializationException( - $"{nameof(Content)} is expected to be a non-null {nameof(Message)}."); - } - internal MessageContent Content { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Content), Content); - } } } diff --git a/src/Libplanet.Net/InvalidStateTargetException.cs b/src/Libplanet.Net/InvalidStateTargetException.cs index e216764a11..704a77d445 100644 --- a/src/Libplanet.Net/InvalidStateTargetException.cs +++ b/src/Libplanet.Net/InvalidStateTargetException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net { @@ -19,10 +18,5 @@ public InvalidStateTargetException(string message, Exception innerException) : base(message, innerException) { } - - protected InvalidStateTargetException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/NoSwarmContextException.cs b/src/Libplanet.Net/NoSwarmContextException.cs index df75c9168e..3d3ef4a621 100644 --- a/src/Libplanet.Net/NoSwarmContextException.cs +++ b/src/Libplanet.Net/NoSwarmContextException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net { @@ -19,13 +18,5 @@ public NoSwarmContextException(string message, Exception innerException) : base(message, innerException) { } - - protected NoSwarmContextException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/PeerNotFoundException.cs b/src/Libplanet.Net/PeerNotFoundException.cs index fd01d2e3d4..97cfe222a9 100644 --- a/src/Libplanet.Net/PeerNotFoundException.cs +++ b/src/Libplanet.Net/PeerNotFoundException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net { @@ -19,13 +18,5 @@ public PeerNotFoundException(string message, Exception innerException) : base(message, innerException) { } - - protected PeerNotFoundException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/Protocols/PeerDiscoveryException.cs b/src/Libplanet.Net/Protocols/PeerDiscoveryException.cs index 9e5fc27fe1..eda206ab31 100644 --- a/src/Libplanet.Net/Protocols/PeerDiscoveryException.cs +++ b/src/Libplanet.Net/Protocols/PeerDiscoveryException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net.Protocols { @@ -18,13 +17,5 @@ public PeerDiscoveryException(string message, Exception innerException) : base(message, innerException) { } - - protected PeerDiscoveryException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/Protocols/PingTimeoutException.cs b/src/Libplanet.Net/Protocols/PingTimeoutException.cs index ec40b608c4..37d8aa05f1 100644 --- a/src/Libplanet.Net/Protocols/PingTimeoutException.cs +++ b/src/Libplanet.Net/Protocols/PingTimeoutException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net.Protocols { @@ -24,27 +23,6 @@ public PingTimeoutException(string message, BoundPeer target, Exception innerExc Target = target; } - protected PingTimeoutException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Target = info.GetValue(nameof(Target), typeof(BoundPeer)) is BoundPeer target - ? target - : throw new SerializationException( - $"{nameof(Target)} is expected to be a non-null {nameof(BoundPeer)}."); - } - public BoundPeer Target { get; private set; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - if (info is null) - { - throw new System.ArgumentNullException(nameof(info)); - } - - base.GetObjectData(info, context); - info.AddValue(nameof(Target), Target); - } } } diff --git a/src/Libplanet.Net/SwarmException.cs b/src/Libplanet.Net/SwarmException.cs index cb2d6e84b8..074a3a62b5 100644 --- a/src/Libplanet.Net/SwarmException.cs +++ b/src/Libplanet.Net/SwarmException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net { @@ -19,13 +18,5 @@ public SwarmException(string message, Exception innerException) : base(message, innerException) { } - - protected SwarmException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - } } } diff --git a/src/Libplanet.Net/Transports/CommunicationFailException.cs b/src/Libplanet.Net/Transports/CommunicationFailException.cs index 7743d916b2..890d788981 100644 --- a/src/Libplanet.Net/Transports/CommunicationFailException.cs +++ b/src/Libplanet.Net/Transports/CommunicationFailException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net.Transports @@ -34,25 +32,8 @@ public CommunicationFailException( MessageType = messageType; } - public CommunicationFailException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Peer = info.GetValue(nameof(Peer)); - MessageType = info.GetValue(nameof(MessageType), typeof(MessageContent.MessageType)) - is MessageContent.MessageType messageType - ? messageType - : throw new SerializationException($"{nameof(MessageType)} is of an invalid type."); - } - public BoundPeer Peer { get; } public MessageContent.MessageType MessageType { get; } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Peer), Peer); - info.AddValue(nameof(MessageType), MessageType, typeof(MessageContent.MessageType)); - } } } diff --git a/src/Libplanet.Net/Transports/DifferentAppProtocolVersionException.cs b/src/Libplanet.Net/Transports/DifferentAppProtocolVersionException.cs index 2eaaacc1f1..a613e9a2cf 100644 --- a/src/Libplanet.Net/Transports/DifferentAppProtocolVersionException.cs +++ b/src/Libplanet.Net/Transports/DifferentAppProtocolVersionException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net.Transports @@ -37,18 +35,6 @@ public DifferentAppProtocolVersionException( Trusted = trusted; } - protected DifferentAppProtocolVersionException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - ExpectedApv = AppProtocolVersion.FromToken( - info.GetValue(nameof(ExpectedApv))); - ActualApv = AppProtocolVersion.FromToken( - info.GetValue(nameof(ActualApv))); - Trusted = info.GetValue(nameof(Trusted)); - } - /// /// The protocol version of the current . /// @@ -64,14 +50,5 @@ protected DifferentAppProtocolVersionException( /// Whether is signed by a trusted signer. /// public bool Trusted { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(ExpectedApv), ExpectedApv.Token); - info.AddValue(nameof(ActualApv), ActualApv.Token); - info.AddValue(nameof(Trusted), Trusted); - } } } diff --git a/src/Libplanet.Net/Transports/InvalidCredentialException.cs b/src/Libplanet.Net/Transports/InvalidCredentialException.cs index d9c7fd1c1f..d7e48b7ae6 100644 --- a/src/Libplanet.Net/Transports/InvalidCredentialException.cs +++ b/src/Libplanet.Net/Transports/InvalidCredentialException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Crypto; using Libplanet.Net.Messages; @@ -23,25 +21,8 @@ internal InvalidCredentialException( Actual = actual; } - protected InvalidCredentialException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - Expected = new PublicKey(info.GetValue(nameof(Expected))); - Actual = new PublicKey(info.GetValue(nameof(Actual))); - } - public PublicKey Expected { get; private set; } public PublicKey Actual { get; private set; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Expected), Expected.Format(true)); - info.AddValue(nameof(Actual), Actual.Format(true)); - } } } diff --git a/src/Libplanet.Net/Transports/InvalidMessageSignatureException.cs b/src/Libplanet.Net/Transports/InvalidMessageSignatureException.cs index b90540468c..d24ed40d74 100644 --- a/src/Libplanet.Net/Transports/InvalidMessageSignatureException.cs +++ b/src/Libplanet.Net/Transports/InvalidMessageSignatureException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Crypto; using Libplanet.Net.Messages; @@ -27,17 +25,6 @@ internal InvalidMessageSignatureException( Signature = signature; } - protected InvalidMessageSignatureException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - Peer = info.GetValue(nameof(Peer)); - PublicKey = new PublicKey(info.GetValue(nameof(PublicKey))); - MessageToVerify = info.GetValue(nameof(MessageToVerify)); - Signature = info.GetValue(nameof(Signature)); - } - public BoundPeer Peer { get; } public PublicKey PublicKey { get; } @@ -45,15 +32,5 @@ protected InvalidMessageSignatureException( public byte[] MessageToVerify { get; } public byte[] Signature { get; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Peer), Peer); - info.AddValue(nameof(PublicKey), PublicKey.Format(true)); - info.AddValue(nameof(MessageToVerify), MessageToVerify); - info.AddValue(nameof(Signature), Signature); - } } } diff --git a/src/Libplanet.Net/Transports/InvalidMessageTimestampException.cs b/src/Libplanet.Net/Transports/InvalidMessageTimestampException.cs index 56fb2f2ad5..13e49f570d 100644 --- a/src/Libplanet.Net/Transports/InvalidMessageTimestampException.cs +++ b/src/Libplanet.Net/Transports/InvalidMessageTimestampException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net.Transports @@ -24,29 +22,10 @@ internal InvalidMessageTimestampException( CurrentOffset = currentOffset; } - protected InvalidMessageTimestampException( - SerializationInfo info, - StreamingContext context) - : base(info, context) - { - CreatedOffset = info.GetValue(nameof(CreatedOffset)); - Buffer = info.GetValue(nameof(Buffer)); - CurrentOffset = info.GetValue(nameof(CurrentOffset)); - } - internal DateTimeOffset CreatedOffset { get; private set; } internal TimeSpan? Buffer { get; private set; } internal DateTimeOffset CurrentOffset { get; private set; } - - public override void GetObjectData( - SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(CreatedOffset), CreatedOffset); - info.AddValue(nameof(Buffer), Buffer); - info.AddValue(nameof(CurrentOffset), CurrentOffset); - } } } diff --git a/src/Libplanet.Net/Transports/SendMessageFailException.cs b/src/Libplanet.Net/Transports/SendMessageFailException.cs index eb71c1bbd9..1b022cf5ff 100644 --- a/src/Libplanet.Net/Transports/SendMessageFailException.cs +++ b/src/Libplanet.Net/Transports/SendMessageFailException.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.Serialization; -using Libplanet.Common.Serialization; using Libplanet.Net.Messages; namespace Libplanet.Net.Transports @@ -23,18 +21,6 @@ internal SendMessageFailException(string message, BoundPeer peer, Exception inne Peer = peer; } - protected SendMessageFailException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Peer = info.GetValue(nameof(Peer)); - } - public BoundPeer Peer { get; } - - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue(nameof(Peer), Peer); - } } } diff --git a/src/Libplanet.Net/Transports/TransportException.cs b/src/Libplanet.Net/Transports/TransportException.cs index 3f7fced7f7..a70390f055 100644 --- a/src/Libplanet.Net/Transports/TransportException.cs +++ b/src/Libplanet.Net/Transports/TransportException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Libplanet.Net.Transports { @@ -19,13 +18,5 @@ public TransportException(string message, Exception innerException) : base(message, innerException) { } - - protected TransportException( - SerializationInfo info, - StreamingContext context - ) - : base(info, context) - { - } } } diff --git a/test/Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs b/test/Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs deleted file mode 100644 index 98a7862c3e..0000000000 --- a/test/Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Runtime.Serialization.Formatters.Binary; -using Xunit; - -namespace Libplanet.Action.Tests -{ - public class BlockProtocolVersionNotSupportedExceptionTest - { - [Fact] - public void Serializable() - { - var exc = new BlockProtocolVersionNotSupportedException("Foo", 5); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - - ms.Seek(0, SeekOrigin.Begin); - var deserialized = Assert.IsType( - formatter.Deserialize(ms)); - Assert.Equal("Foo", deserialized.Message); - Assert.Equal(5, deserialized.BlockProtocolVersion); - } - } - } -} diff --git a/test/Libplanet.Action.Tests/InsufficientBalanceExceptionTest.cs b/test/Libplanet.Action.Tests/InsufficientBalanceExceptionTest.cs deleted file mode 100644 index 2167364cbb..0000000000 --- a/test/Libplanet.Action.Tests/InsufficientBalanceExceptionTest.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Action.State; -using Libplanet.Crypto; -using Libplanet.Types.Assets; -using Xunit; - -namespace Libplanet.Action.Tests -{ - public class InsufficientBalanceExceptionTest - { - [Fact] - public void Serializable() - { - var minter = new Address(new byte[] - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - }); - var account = new Address(new byte[] - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - }); - - var currency = Currency.Uncapped("PLT", 0, minter); - var exc = new InsufficientBalanceException( - "for testing", - account, - FungibleAssetValue.FromRawValue(currency, 99) - ); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - - ms.Seek(0, SeekOrigin.Begin); - var deserialized = (InsufficientBalanceException)formatter.Deserialize(ms); - Assert.Equal("for testing", deserialized.Message); - Assert.Equal(account, deserialized.Address); - Assert.Equal(FungibleAssetValue.FromRawValue(currency, 99), deserialized.Balance); - } - } - } -} diff --git a/test/Libplanet.Action.Tests/SupplyOverflowExceptionTest.cs b/test/Libplanet.Action.Tests/SupplyOverflowExceptionTest.cs deleted file mode 100644 index 3254065d86..0000000000 --- a/test/Libplanet.Action.Tests/SupplyOverflowExceptionTest.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Action.State; -using Libplanet.Crypto; -using Libplanet.Types.Assets; -using Xunit; - -namespace Libplanet.Action.Tests -{ - public class SupplyOverflowExceptionTest - { - [Fact] - public void Serializable() - { - var minter = new Address(new byte[] - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - }); - - var currency = Currency.Uncapped("PLT", 0, minter); - var exc = new SupplyOverflowException( - "for testing", - FungibleAssetValue.FromRawValue(currency, 99) - ); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - - ms.Seek(0, SeekOrigin.Begin); - var deserialized = (SupplyOverflowException)formatter.Deserialize(ms); - Assert.Equal("for testing", deserialized.Message); - Assert.Equal(FungibleAssetValue.FromRawValue(currency, 99), deserialized.Amount); - } - } - } -} diff --git a/test/Libplanet.Action.Tests/UnexpectedlyTerminatedActionExceptionTest.cs b/test/Libplanet.Action.Tests/UnexpectedlyTerminatedActionExceptionTest.cs deleted file mode 100644 index ae07f5db5e..0000000000 --- a/test/Libplanet.Action.Tests/UnexpectedlyTerminatedActionExceptionTest.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Runtime.Serialization.Formatters.Binary; -using System.Security.Cryptography; -using Libplanet.Action.Tests.Common; -using Libplanet.Common; -using Libplanet.Types.Tx; -using Xunit; - -namespace Libplanet.Action.Tests -{ - public class UnexpectedlyTerminatedActionExceptionTest - { - [Fact] - public void Serializable() - { - var innerExc = new Exception("inner"); - HashDigest preEvaluationHash = - new HashDigest(TestUtils.GetRandomBytes(32)); - long blockIndex = 100; - var txId = new TxId(TestUtils.GetRandomBytes(TxId.Size)); - var previousStateRootHash = new HashDigest( - TestUtils.GetRandomBytes(HashDigest.Size) - ); - var action = new Sleep() - { - ZoneId = 1, - }; - - var exc = new UnexpectedlyTerminatedActionException( - "for testing", - preEvaluationHash, - blockIndex, - txId, - previousStateRootHash, - action, - innerExc - ); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - - ms.Seek(0, SeekOrigin.Begin); - var deserialized = (UnexpectedlyTerminatedActionException)formatter.Deserialize(ms); - Assert.Equal("for testing", deserialized.Message); - Assert.IsType(deserialized.InnerException); - Assert.Equal(innerExc.Message, deserialized.InnerException.Message); - - Assert.Equal(preEvaluationHash, deserialized.PreEvaluationHash); - Assert.Equal(blockIndex, deserialized.BlockIndex); - Assert.Equal(txId, deserialized.TxId); - Assert.Equal(previousStateRootHash, deserialized.PreviousStateRootHash); - - Assert.IsType(deserialized.Action); - Assert.Equal(action.PlainValue, deserialized.Action.PlainValue); - } - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/CommunicationFailExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/CommunicationFailExceptionTest.cs deleted file mode 100644 index 0c1f178f99..0000000000 --- a/test/Libplanet.Net.Tests/Transports/CommunicationFailExceptionTest.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Net.Messages; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class CommunicationFailExceptionTest - { - public static IEnumerable InnerExceptions => new List() - { - new object?[] { null }, - new object?[] { new Exception("An inner error message.") }, - }; - - [Theory] - [MemberData(nameof(InnerExceptions))] - public void Serialization(Exception? innerException) - { - MessageContent ping = new PingMsg(); - BoundPeer peer = new BoundPeer( - new PrivateKey().PublicKey, - new DnsEndPoint("0.0.0.0", 1234)); - - CommunicationFailException e; - if (innerException is { } i) - { - e = new CommunicationFailException("An error message", ping.Type, peer, i); - } - else - { - e = new CommunicationFailException("An error message", ping.Type, peer); - } - - var f = new BinaryFormatter(); - CommunicationFailException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (CommunicationFailException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - Assert.Equal(e.MessageType, e2.MessageType); - Assert.Equal(e.Peer, e2.Peer); - Assert.True( - ((e.InnerException is { } ie && e2.InnerException is { } ie2) && - ie.Message.Equals(ie2.Message)) || - (e.InnerException is null && e2.InnerException is null)); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/DifferentAppProtocolVersionExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/DifferentAppProtocolVersionExceptionTest.cs deleted file mode 100644 index 580965773b..0000000000 --- a/test/Libplanet.Net.Tests/Transports/DifferentAppProtocolVersionExceptionTest.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Immutable; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class DifferentAppProtocolVersionExceptionTest - { - [Fact] - public void Serialization() - { - var random = new Random(); - var publicKey = new PrivateKey().PublicKey; - var identity = new byte[8]; - var apv1 = new AppProtocolVersion( - 1, - new Bencodex.Types.Integer(0), - ImmutableArray.Empty, - default(Address)); - var apv2 = new AppProtocolVersion( - 2, - new Bencodex.Types.Integer(0), - ImmutableArray.Empty, - default(Address)); - random.NextBytes(identity); - - var e1 = new DifferentAppProtocolVersionException( - "An error message", - apv1, - apv2, - false); - var f = new BinaryFormatter(); - DifferentAppProtocolVersionException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e1); - s.Seek(0, SeekOrigin.Begin); - e2 = (DifferentAppProtocolVersionException)f.Deserialize(s); - } - - Assert.Equal(e1.Message, e2.Message); - Assert.Equal(e1.ExpectedApv, e2.ExpectedApv); - Assert.Equal(e1.ActualApv, e2.ActualApv); - Assert.Equal(e1.Trusted, e2.Trusted); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/InvalidCredentialExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/InvalidCredentialExceptionTest.cs deleted file mode 100644 index da2cecc09a..0000000000 --- a/test/Libplanet.Net.Tests/Transports/InvalidCredentialExceptionTest.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class InvalidCredentialExceptionTest - { - [Fact] - public void Serialization() - { - var random = new Random(); - var privateKey = new PrivateKey(); - var badPrivateKey = new PrivateKey(); - - var e1 = new InvalidCredentialException( - "An error message", - expected: privateKey.PublicKey, - actual: badPrivateKey.PublicKey); - var f = new BinaryFormatter(); - InvalidCredentialException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e1); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidCredentialException)f.Deserialize(s); - } - - Assert.Equal(e1.Message, e2.Message); - Assert.Equal(e1.Expected, e2.Expected); - Assert.Equal(e1.Actual, e2.Actual); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/InvalidMessageSignatureExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/InvalidMessageSignatureExceptionTest.cs deleted file mode 100644 index e8d0951691..0000000000 --- a/test/Libplanet.Net.Tests/Transports/InvalidMessageSignatureExceptionTest.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class InvalidMessageSignatureExceptionTest - { - [Fact] - public void Serialization() - { - var random = new Random(); - var publicKey = new PrivateKey().PublicKey; - var messageToVerify = new byte[8]; - var signature = new byte[8]; - random.NextBytes(messageToVerify); - random.NextBytes(signature); - - var e1 = new InvalidMessageSignatureException( - "An error message", - new BoundPeer(publicKey, new DnsEndPoint("0.0.0.0", 0)), - publicKey, - messageToVerify, - signature); - var f = new BinaryFormatter(); - InvalidMessageSignatureException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e1); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidMessageSignatureException)f.Deserialize(s); - } - - Assert.Equal(e1.Message, e2.Message); - Assert.Equal(e1.Peer, e2.Peer); - Assert.Equal(e1.PublicKey, e2.PublicKey); - Assert.True(e1.MessageToVerify.SequenceEqual(e2.MessageToVerify)); - Assert.True(e1.Signature.SequenceEqual(e2.Signature)); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/InvalidMessageTimestampExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/InvalidMessageTimestampExceptionTest.cs deleted file mode 100644 index 7d91fb246a..0000000000 --- a/test/Libplanet.Net.Tests/Transports/InvalidMessageTimestampExceptionTest.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class InvalidMessageTimestampExceptionTest - { - public static IEnumerable TestData => new List() - { - new object?[] { null }, - new object?[] { TimeSpan.FromSeconds(1) }, - }; - - [Theory] - [MemberData(nameof(TestData))] - public void Serialization(TimeSpan? buffer) - { - var e1 = new InvalidMessageTimestampException( - "An error message", - DateTimeOffset.UtcNow, - buffer, - DateTimeOffset.UtcNow + TimeSpan.FromSeconds(1)); - var f = new BinaryFormatter(); - InvalidMessageTimestampException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e1); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidMessageTimestampException)f.Deserialize(s); - } - - Assert.Equal(e1.Message, e2.Message); - Assert.Equal(e1.CreatedOffset, e2.CreatedOffset); - Assert.Equal(e1.Buffer, e2.Buffer); - Assert.Equal(e1.CurrentOffset, e2.CurrentOffset); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/SendMessageFailExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/SendMessageFailExceptionTest.cs deleted file mode 100644 index 4d45ff5a0e..0000000000 --- a/test/Libplanet.Net.Tests/Transports/SendMessageFailExceptionTest.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Net.Messages; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class SendMessageFailExceptionTest - { - public static IEnumerable InnerExceptions => new List() - { - new object?[] { null }, - new object?[] { new Exception("An inner error message.") }, - }; - - [Theory] - [MemberData(nameof(InnerExceptions))] - public void Serialization(Exception? innerException) - { - MessageContent ping = new PingMsg(); - BoundPeer peer = new BoundPeer( - new PrivateKey().PublicKey, - new DnsEndPoint("0.0.0.0", 1234)); - - SendMessageFailException e; - if (innerException is { } i) - { - e = new SendMessageFailException("An error message", peer, i); - } - else - { - e = new SendMessageFailException("An error message", peer); - } - - var f = new BinaryFormatter(); - SendMessageFailException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (SendMessageFailException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - Assert.Equal(e.Peer, e2.Peer); - Assert.True( - ((e.InnerException is { } ie && e2.InnerException is { } ie2) && - ie.Message.Equals(ie2.Message)) || - (e.InnerException is null && e2.InnerException is null)); - } - } -} diff --git a/test/Libplanet.Net.Tests/Transports/TransportExceptionTest.cs b/test/Libplanet.Net.Tests/Transports/TransportExceptionTest.cs deleted file mode 100644 index 10bf27b4ac..0000000000 --- a/test/Libplanet.Net.Tests/Transports/TransportExceptionTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -#nullable disable -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Net.Transports; -using Xunit; - -namespace Libplanet.Net.Tests.Transports -{ - public class TransportExceptionTest - { - [Fact] - public void Serializable() - { - var e = new TransportException("A message."); - var f = new BinaryFormatter(); - TransportException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (TransportException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - } - } -} diff --git a/test/Libplanet.Tests/Blocks/InvalidBlockBytesLengthExceptionTest.cs b/test/Libplanet.Tests/Blocks/InvalidBlockBytesLengthExceptionTest.cs deleted file mode 100644 index 8261257575..0000000000 --- a/test/Libplanet.Tests/Blocks/InvalidBlockBytesLengthExceptionTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Types.Blocks; -using Xunit; - -namespace Libplanet.Tests.Blocks -{ - public class InvalidBlockBytesLengthExceptionTest - { - [Fact] - public void Serialization() - { - var e = new InvalidBlockBytesLengthException("A message.", 10); - var f = new BinaryFormatter(); - InvalidBlockBytesLengthException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidBlockBytesLengthException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - Assert.Equal(e.BytesLength, e2.BytesLength); - } - } -} diff --git a/test/Libplanet.Tests/Blocks/InvalidBlockPreEvaluationHashExceptionTest.cs b/test/Libplanet.Tests/Blocks/InvalidBlockPreEvaluationHashExceptionTest.cs deleted file mode 100644 index 9df65b0030..0000000000 --- a/test/Libplanet.Tests/Blocks/InvalidBlockPreEvaluationHashExceptionTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Immutable; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Types.Blocks; -using Xunit; - -namespace Libplanet.Tests.Blocks -{ - public class InvalidBlockPreEvaluationHashExceptionTest - { - [Fact] - public void Serialize() - { - var actual = TestUtils.GetRandomBytes(BlockHash.Size).ToImmutableArray(); - var expected = TestUtils.GetRandomBytes(BlockHash.Size).ToImmutableArray(); - var exc = new InvalidBlockPreEvaluationHashException( - "TESTING", - actual, - expected - ); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - ms.Seek(0, SeekOrigin.Begin); - var deserialized = - (InvalidBlockPreEvaluationHashException)formatter.Deserialize(ms); - - Assert.Equal(deserialized, exc); - } - } - } -} diff --git a/test/Libplanet.Tests/Blocks/InvalidBlockTxCountExceptionTest.cs b/test/Libplanet.Tests/Blocks/InvalidBlockTxCountExceptionTest.cs deleted file mode 100644 index 1f8b32c87d..0000000000 --- a/test/Libplanet.Tests/Blocks/InvalidBlockTxCountExceptionTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Types.Blocks; -using Xunit; - -namespace Libplanet.Tests.Blocks -{ - public class InvalidBlockTxCountExceptionTest - { - [Fact] - public void Serialization() - { - var e = new InvalidBlockTxCountException("A message.", 10); - var f = new BinaryFormatter(); - InvalidBlockTxCountException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidBlockTxCountException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - Assert.Equal(e.TxCount, e2.TxCount); - } - } -} diff --git a/test/Libplanet.Tests/Blocks/InvalidBlockTxCountPerSignerExceptionTest.cs b/test/Libplanet.Tests/Blocks/InvalidBlockTxCountPerSignerExceptionTest.cs deleted file mode 100644 index 97671c59f8..0000000000 --- a/test/Libplanet.Tests/Blocks/InvalidBlockTxCountPerSignerExceptionTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using Libplanet.Crypto; -using Libplanet.Types.Blocks; -using Xunit; - -namespace Libplanet.Tests.Blocks -{ - public class InvalidBlockTxCountPerSignerExceptionTest - { - public InvalidBlockTxCountPerSignerExceptionTest() - { - } - - [Fact] - public void Serialization() - { - Address signer = new PrivateKey().Address; - var e = new InvalidBlockTxCountPerSignerException("A message.", signer, 10); - var f = new BinaryFormatter(); - InvalidBlockTxCountPerSignerException e2; - - using (var s = new MemoryStream()) - { - f.Serialize(s, e); - s.Seek(0, SeekOrigin.Begin); - e2 = (InvalidBlockTxCountPerSignerException)f.Deserialize(s); - } - - Assert.Equal(e.Message, e2.Message); - Assert.Equal(e.Signer, e2.Signer); - Assert.Equal(e.TxCount, e2.TxCount); - } - } -} diff --git a/test/Libplanet.Tests/Blocks/InvalidBlockTxHashExceptionTest.cs b/test/Libplanet.Tests/Blocks/InvalidBlockTxHashExceptionTest.cs deleted file mode 100644 index 56bbaf2a3b..0000000000 --- a/test/Libplanet.Tests/Blocks/InvalidBlockTxHashExceptionTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using System.Security.Cryptography; -using Libplanet.Common; -using Libplanet.Types.Blocks; -using Xunit; - -namespace Libplanet.Tests.Blocks -{ - public class InvalidBlockTxHashExceptionTest - { - [Fact] - public void Serialize() - { - var blockHash = new HashDigest( - TestUtils.GetRandomBytes(HashDigest.Size) - ); - var calculatedBlockHash = new HashDigest( - TestUtils.GetRandomBytes(HashDigest.Size) - ); - var exc = new InvalidBlockTxHashException("TESTING", blockHash, calculatedBlockHash); - - var formatter = new BinaryFormatter(); - using (var ms = new MemoryStream()) - { - formatter.Serialize(ms, exc); - ms.Seek(0, SeekOrigin.Begin); - var deserialized = (InvalidBlockTxHashException)formatter.Deserialize(ms); - - Assert.Equal(deserialized, exc); - } - } - } -} From 142d5a72baff157414139088602e242bfad69b68 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Tue, 29 Oct 2024 14:59:48 +0900 Subject: [PATCH 04/28] Build fix --- Directory.Build.props | 4 +- Libplanet.sln | 50 +++++++++++++++++++ global.json | 2 +- src/Libplanet.Net/Libplanet.Net.csproj | 1 + src/Libplanet/KeyStore/Web3KeyStore.cs | 2 + .../Libplanet.Extensions.Cocona.csproj | 2 +- 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 66304e3deb..e0e3ad59e3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - net6.0 - net6.0 + net8.0 + net8.0 10 5.3.2