Closed moreal closed 1 month ago
DevEx 테스트가 실패하는데 괜찮은건가요?
DevEx 테스트가 실패하는데 괜찮은건가요?
@ipdae 테스트 관련해서 깨지는 것이 아닌 Roslyn 컴파일러 쪽에서 발생하고 있습니다. 최근 계속 발생하고 있는데 원인을 파악하지 못 해 재시도(rerun) 하는 것으로 넘어가고 있습니다
Could you review this pull request, when you have time? @ipdae @U-lis
Motivation
This pull request adds the repository pattern. Specifically, it will abstract and incrementally improve the behavior of BlockChain so that BlockChain, TxPool, etc. can be accessed through a repository instead of directly.
This is because we found a problem while working on something else: right now we're using BlockChain directly, so it's hard to test "under what conditions" we want the headless to behave that way. This is because the only way to manipulate the state of BlockChain is to do transactions, create blocks, and expect them to change the state. That's well tested in the Libplanet project, but testing headless implies that as well. This will not only make writing tests difficult, but it will also make the tests take longer to run.
That's why we want to gradually refactor to the repository pattern. I'd appreciate your feedback.
Overview
Repositories
I introduce several new repositories in this pull request. The purpose of the repositories is to separate
BlockChain
logic (in general HTTP server,Database
) andGraphQL
representation (in general HTTP serverController
). This makes testing easier because the GraphQL layer only depends on repositories in some parts.Below are the new repository names and descriptions:
IBlockChainRepository
: A repository about blocks (BlockChain.Tip
,Block
)IWorldStateRepository
: A repository about states (IWorldState
)IStateTrieRepository
: A repository about state-trie (MerkleTrie
)ITransactionRepository
: A repository about transactions, transaction results, nonces.Testing with mocking
Since this pull request, you don't have to setup any
NineChroniclesNodeService
and anyBlockChain
to setup states that you want. You can just mockIWorldStateRepository
.You can manually mock like the below example code:
But if your test don't care any block data and care only states on tip, you can use
GraphQLTestBase.SetupStatesOnTip
: