Skip to content

Commit

Permalink
Merge pull request #435 from strixqlater/feat/implement-actionpoint-test
Browse files Browse the repository at this point in the history
implement ActionPointTests
  • Loading branch information
Atralupus authored Oct 25, 2024
2 parents 5e2791e + 9de65ee commit 7022551
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Mimir.E2ETests/ActionPointTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Bencodex.Types;
using HeadlessGQL;
using Lib9c.Models.Extensions;
using Lib9c.Models.States;
using Libplanet.Crypto;
using Microsoft.Extensions.DependencyInjection;
using MimirGQL;
using Nekoyume;

namespace Mimir.E2ETests;

public class ActionPointTests : IClassFixture<GraphQLClientFixture>
{
private readonly IMimirClient mimirClient;
private readonly IHeadlessClient headlessClient;

public ActionPointTests(GraphQLClientFixture fixture)
{
mimirClient = fixture.ServiceProvider.GetRequiredService<IMimirClient>();
headlessClient = fixture.ServiceProvider.GetRequiredService<IHeadlessClient>();
}

[Theory]
[InlineData("9bFA9196e93E8186A22757c367b92c74F7B0BeA3")]
public async Task CompareActionPointData(string address)
{
var actionPointDataFromMimir = await GetMimirActionPointData(new Address(address));
var actionPointDataFromHeadless = await GetHeadlessActionPointData(new Address(address));

Assert.Equal(actionPointDataFromMimir, actionPointDataFromHeadless);
}

public async Task<int> GetMimirActionPointData(Address avatarAddress)
{
var actionPointResponse = await mimirClient.GetActionPoint.ExecuteAsync(avatarAddress.ToString());
var actionPointData = actionPointResponse.Data.ActionPoint;

return actionPointData;
}

public async Task<int> GetHeadlessActionPointData(Address avatarAddress)
{
var stateResponse = await headlessClient.GetState.ExecuteAsync(
Addresses.ActionPoint.ToString(),
avatarAddress.ToString()
);
var result = CodecUtil.DecodeState(stateResponse.Data.State);

if (result is not Integer value)
throw new Exception(
);

return value;
}
}
4 changes: 4 additions & 0 deletions Mimir.E2ETests/MimirGQL/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ query GetAgent($agentAddress: Address!) {
}
}
}

query GetActionPoint($avatarAddress: Address!) {
actionPoint(address: $avatarAddress)
}

0 comments on commit 7022551

Please sign in to comment.