Skip to content

Commit

Permalink
Setup states simply
Browse files Browse the repository at this point in the history
  • Loading branch information
moreal committed Sep 5, 2024
1 parent 5f7952c commit 7050d70
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 149 deletions.
21 changes: 21 additions & 0 deletions NineChronicles.Headless.Tests/GraphTypes/GraphQLTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
using System.Threading;
using System.Threading.Tasks;
using Bencodex.Types;
using Libplanet.Action.State;
using Libplanet.Mocks;
using Libplanet.Types.Tx;
using Moq;
using NineChronicles.Headless.Executable.Tests.KeyStore;
Expand Down Expand Up @@ -201,6 +203,25 @@ protected async Task<Task> StartAsync(
return task;
}

protected void SetupStatesOnTip(Func<IWorld, IWorld> func)
{
var worldState = func(new World(MockUtil.MockModernWorldState));
var stateRootHash = worldState.Trie.Hash;
var tip = new Domain.Model.BlockChain.Block(
BlockHash.FromString("613dfa26e104465790625ae7bc03fc27a64947c02a9377565ec190405ef7154b"),
BlockHash.FromString("36456be15af9a5b9b13a02c7ce1e849ae9cba8781ec309010499cdb93e29237d"),
default(Address),
0,
Timestamp: DateTimeOffset.UtcNow,
StateRootHash: stateRootHash,
Transactions: ImmutableArray<Transaction>.Empty
);
BlockChainRepository.Setup(repository => repository.GetTip())
.Returns(tip);
WorldStateRepository.Setup(repository => repository.GetWorldState(stateRootHash))
.Returns(worldState);
}

protected LibplanetNodeService CreateLibplanetNodeService(
Block genesisBlock,
AppProtocolVersion appProtocolVersion,
Expand Down
169 changes: 20 additions & 149 deletions NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs

Large diffs are not rendered by default.

0 comments on commit 7050d70

Please sign in to comment.