-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from strixqlater/feat/implement-actionpoint-test
implement ActionPointTests
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters