Skip to content

Commit

Permalink
test: Add test code for delegator state query
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Jan 6, 2025
1 parent db7c24f commit b956dc8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions NineChronicles.Headless.Tests/GraphTypes/DelegatorTypeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Numerics;
using System.Threading.Tasks;
using GraphQL.Execution;
using Lib9c;
using Libplanet.Types.Tx;
using Nekoyume.ValidatorDelegation;
using NineChronicles.Headless.GraphTypes;
using Xunit;
using Xunit.Abstractions;

namespace NineChronicles.Headless.Tests.GraphTypes
{
public class DelegatorTypeTest
{
[Fact]
public async Task ExecuteQuery()
{
var lastDistributeHeight = 1L;
var share = new BigInteger(1000000000000000000) * 10;
var fav = Currencies.GuildGold * 10;

var result = await GraphQLTestUtils.ExecuteQueryAsync<DelegatorType>(
"{ lastDistributeHeight share fav { currency quantity } }",
source: new DelegatorType
{
LastDistributeHeight = lastDistributeHeight,
Share = share,
Fav = fav,
}
);

// Then
var data = (Dictionary<string, object>)((ExecutionNode)result.Data!).ToValue()!;

Assert.Equal(lastDistributeHeight, data["lastDistributeHeight"]);
Assert.Equal(share.ToString("N0"), data["share"]);

var favResult = (Dictionary<string, object>)data["fav"];
Assert.Equal(fav.Currency.Ticker, favResult["currency"]);
Assert.Equal(fav.GetQuantityString(minorUnit: true), favResult["quantity"]);
}
}
}

0 comments on commit b956dc8

Please sign in to comment.