Skip to content

Commit 91ed256

Browse files
authored
Merge pull request #646 from planetarium/lib9c-migration/1.30.0
Lib9c migration/1.30.0
2 parents 6f1fab8 + b0adabb commit 91ed256

23 files changed

Lines changed: 93 additions & 120 deletions

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Lib9cVersion>1.29.0-dev.fd558e739500c80e09fed936d1e5487016efb096</Lib9cVersion>
3+
<Lib9cVersion>1.30.0-dev.c4bd7f8a1650132222cb6170c35660cd86c93a12</Lib9cVersion>
44
<LibplanetVersion>5.5.0</LibplanetVersion>
55
</PropertyGroup>
66
</Project>

Mimir.Initializer/Migrators/ProductMigrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task RunAsync(CancellationToken stoppingToken)
6363

6464
int? crystal = null;
6565
int? crystalPerPrice = null;
66-
int? combatPoint = null;
66+
long? combatPoint = null;
6767
try
6868
{
6969
(crystal, crystalPerPrice) = await _itemProductCalculationService.CalculateCrystalMetricsAsync(itemProduct);

Mimir.MongoDB/Bson/AdventureCpDocument.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ namespace Mimir.MongoDB.Bson;
99
public record AdventureCpDocument(
1010
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] long StoredBlockIndex,
1111
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] Address Address,
12-
int Cp
13-
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(1, StoredBlockIndex)), ICpDocument;
12+
long Cp
13+
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(2, StoredBlockIndex)), ICpDocument;

Mimir.MongoDB/Bson/ArenaCpDocument.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ namespace Mimir.MongoDB.Bson;
99
public record ArenaCpDocument(
1010
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] long StoredBlockIndex,
1111
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] Address Address,
12-
int Cp
13-
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(1, StoredBlockIndex)), ICpDocument;
12+
long Cp
13+
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(2, StoredBlockIndex)), ICpDocument;

Mimir.MongoDB/Bson/ICpDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace Mimir.MongoDB.Bson;
44

55
public interface ICpDocument
66
{
7-
int Cp { get; }
7+
long Cp { get; }
88
}

Mimir.MongoDB/Bson/ProductDocument.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public record ProductDocument : MimirBsonDocument
1010
public Address AvatarAddress { get; init; }
1111
public Address ProductsStateAddress { get; init; }
1212
public Product Object { get; init; }
13-
public int? CombatPoint { get; init; }
13+
public long? CombatPoint { get; init; }
1414
public decimal? UnitPrice { get; init; }
1515
public int? Crystal { get; init; }
1616
public int? CrystalPerPrice { get; init; }
@@ -36,7 +36,7 @@ public ProductDocument(
3636
Address productsStateAddress,
3737
Product product,
3838
decimal unitPrice,
39-
int? combatPoint,
39+
long? combatPoint,
4040
int? crystal,
4141
int? crystalPerPrice
4242
)

Mimir.MongoDB/Bson/RaidCpDocument.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ namespace Mimir.MongoDB.Bson;
99
public record RaidCpDocument(
1010
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] long StoredBlockIndex,
1111
[property: BsonIgnore, JsonIgnore, GraphQLIgnore] Address Address,
12-
int Cp
13-
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(1, StoredBlockIndex)), ICpDocument;
12+
long Cp
13+
) : MimirBsonDocument(Address.ToHex(), new DocumentMetadata(2, StoredBlockIndex)), ICpDocument;

Mimir.Tests/QueryTests/AgentTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Libplanet.Crypto;
33
using Mimir.MongoDB.Bson;
44
using Mimir.MongoDB.Repositories;
5+
using Mimir.Services;
56
using Moq;
67
using Nekoyume;
78

Mimir.Tests/QueryTests/BalanceQueryTest.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,6 @@ public async Task GraphQL_Query_Balance_NCG_Returns_CorrectValue()
6161
await Verify(result);
6262
}
6363

64-
[Fact]
65-
public async Task GraphQL_Query_Balance_NCG_Enqueues_Recovery_When_Not_Found()
66-
{
67-
var mockAddress = new Address("0x0000000000000000000000000000000000000000");
68-
var mockRepo = new Mock<IBalanceRepository>();
69-
var mockStateRecoveryService = new Mock<IStateRecoveryService>();
70-
71-
mockRepo
72-
.Setup(repo => repo.GetByAddressAsync("NCG".ToCurrency(), mockAddress))
73-
.ThrowsAsync(new DocumentNotFoundInMongoCollectionException("balance_ncg", mockAddress.ToHex()));
74-
75-
var serviceProvider = TestServices.Builder
76-
.With(mockRepo.Object)
77-
.With(mockStateRecoveryService.Object)
78-
.Build();
79-
80-
var query = $$"""
81-
query {
82-
balance(currencyTicker: "NCG", address: "{{mockAddress}}")
83-
}
84-
""";
85-
86-
var result = await TestServices.ExecuteRequestAsync(serviceProvider, b => b.SetDocument(query));
87-
await Verify(result);
88-
}
89-
9064
[Fact]
9165
public async Task GraphQL_Query_Balance_Throws_When_No_Inputs_Provided()
9266
{

Mimir.Tests/TestServices.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System.Linq.Expressions;
12
using System.Numerics;
23
using System.Security.Cryptography;
4+
using Hangfire;
35
using HotChocolate;
46
using HotChocolate.Execution;
57
using Lib9c.GraphQL.Types;
@@ -10,6 +12,7 @@
1012
using Mimir.MongoDB.Bson;
1113
using Mimir.MongoDB.Repositories;
1214
using Mimir.MongoDB.Services;
15+
using Mimir.Services;
1316
using MongoDB.Driver;
1417
using Moq;
1518

@@ -32,9 +35,13 @@ public ServiceProviderBuilder()
3235
.BindRuntimeType(typeof(Address), typeof(AddressType))
3336
.BindRuntimeType(typeof(BigInteger), typeof(BigIntegerType))
3437
.BindRuntimeType(typeof(HashDigest<SHA256>), typeof(HashDigestSHA256Type));
38+
39+
var mockClient = new Mock<IBackgroundJobClient>();
40+
_serviceCollection.AddSingleton<IBackgroundJobClient>(mockClient.Object);
3541
}
3642

37-
public ServiceProviderBuilder With<T>(T service) where T : class
43+
public ServiceProviderBuilder With<T>(T service)
44+
where T : class
3845
{
3946
_serviceCollection.AddSingleton(service);
4047
return this;
@@ -58,7 +65,8 @@ public IServiceProvider Build()
5865
public static async Task<string> ExecuteRequestAsync(
5966
IServiceProvider serviceProvider,
6067
Action<OperationRequestBuilder> configureRequest,
61-
CancellationToken cancellationToken = default)
68+
CancellationToken cancellationToken = default
69+
)
6270
{
6371
await using var scope = serviceProvider.CreateAsyncScope();
6472

@@ -67,8 +75,8 @@ public static async Task<string> ExecuteRequestAsync(
6775
configureRequest(requestBuilder);
6876
var request = requestBuilder.Build();
6977

70-
var executor = await scope.ServiceProvider
71-
.GetRequiredService<IRequestExecutorResolver>()
78+
var executor = await scope
79+
.ServiceProvider.GetRequiredService<IRequestExecutorResolver>()
7280
.GetRequestExecutorAsync(cancellationToken: cancellationToken);
7381
await using var result = await executor.ExecuteAsync(request, cancellationToken);
7482
result.ExpectOperationResult();

0 commit comments

Comments
 (0)