From 69c9fb9d915ab1b4b17ee7e4e3719858da6e1dde Mon Sep 17 00:00:00 2001 From: s2quake Date: Wed, 28 Aug 2024 13:50:55 +0900 Subject: [PATCH] test: Fix failed tests --- sdk/node/Libplanet.Node.Tests/RandomPrivateKey.cs | 4 ++++ sdk/node/Libplanet.Node.Tests/Services/SeedTest.cs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/sdk/node/Libplanet.Node.Tests/RandomPrivateKey.cs b/sdk/node/Libplanet.Node.Tests/RandomPrivateKey.cs index f2c5fbb5290..4301644ae69 100644 --- a/sdk/node/Libplanet.Node.Tests/RandomPrivateKey.cs +++ b/sdk/node/Libplanet.Node.Tests/RandomPrivateKey.cs @@ -1,5 +1,6 @@ using Libplanet.Common; using Libplanet.Crypto; +using Libplanet.Net; namespace Libplanet.Node.Tests; @@ -15,4 +16,7 @@ public static implicit operator PrivateKey(RandomPrivateKey randomPrivateKey) => randomPrivateKey._privateKey; public override string ToString() => ByteUtil.Hex(_privateKey.ByteArray); + + public AppProtocolVersion ToAppProtocolVersion(int version) + => AppProtocolVersion.Sign(_privateKey, version); } diff --git a/sdk/node/Libplanet.Node.Tests/Services/SeedTest.cs b/sdk/node/Libplanet.Node.Tests/Services/SeedTest.cs index f9a1d3d3a13..680b9fb8c87 100644 --- a/sdk/node/Libplanet.Node.Tests/Services/SeedTest.cs +++ b/sdk/node/Libplanet.Node.Tests/Services/SeedTest.cs @@ -20,6 +20,7 @@ public void Base_Test() { PrivateKey = privateKey.ToString(), EndPoint = endPoint.ToString(), + AppProtocolVersion = privateKey.ToAppProtocolVersion(0).Token, }; var seed = new Seed(options); Assert.Equal(endPoint.Host, seed.BoundPeer.EndPoint.Host); @@ -38,6 +39,7 @@ public async Task StartAsync_TestAsync() { PrivateKey = privateKey.ToString(), EndPoint = endPoint.ToString(), + AppProtocolVersion = privateKey.ToAppProtocolVersion(0).Token, }; await using var seed = new Seed(options); await seed.StartAsync(cancellationToken: default); @@ -53,6 +55,7 @@ public async Task StartAsync_Twice_ThrowTestAsync() { PrivateKey = privateKey.ToString(), EndPoint = endPoint.ToString(), + AppProtocolVersion = privateKey.ToAppProtocolVersion(0).Token, }; await using var seed = new Seed(options); await seed.StartAsync(cancellationToken: default); @@ -71,6 +74,7 @@ public async Task StopAsync_TestAsync() { PrivateKey = privateKey.ToString(), EndPoint = endPoint.ToString(), + AppProtocolVersion = privateKey.ToAppProtocolVersion(0).Token, }; await using var seed = new Seed(options); await seed.StartAsync(cancellationToken: default); @@ -87,6 +91,7 @@ public async Task StopAsync_NotRunning_ThrowTestAsync() { PrivateKey = privateKey.ToString(), EndPoint = endPoint.ToString(), + AppProtocolVersion = privateKey.ToAppProtocolVersion(0).Token, }; await using var seed = new Seed(options); await Assert.ThrowsAsync(async () => @@ -118,6 +123,7 @@ public async Task MessageReceived_TestAsync() { PrivateKey = seedPrivateKey.ToString(), EndPoint = seedEndPoint.ToString(), + AppProtocolVersion = apv.Token, }; await using var seed = new Seed(options); await seed.StartAsync(cancellationToken: default); @@ -177,6 +183,7 @@ public async Task GetNeighborsMsg_TestAsync() { PrivateKey = seedPrivateKey.ToString(), EndPoint = seedEndPoint.ToString(), + AppProtocolVersion = apv.Token, }; await using var seed = new Seed(options); await seed.StartAsync(cancellationToken: default);