8000 investigate how to unit test services/network · Issue #1863 · ignite/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

investigate how to unit test services/network #1863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ilgooz opened this issue Dec 1, 2021 · 2 comments
Closed

investigate how to unit test services/network #1863

ilgooz opened this issue Dec 1, 2021 · 2 comments

Comments

@ilgooz
Copy link
Member
ilgooz commented Dec 1, 2021

No description provided.

@ivanovpetr
Copy link
Contributor

I start with service/network package and will do research about service/network/networkchain in the separate issue

Suggestions

Rename the Network object. A network is a widely used term in computer since in the case of starport Network stands for object which is used for interacting with SPN. It could be NetworkClient since it sends requests to SPN but it also modifies files on the computer and do some other things. So I would designate this object as a Service object for interaction with starport network shortened it to StarportNetworkService or SPNService. The alternative version is NetworkService assuming that this code already exists in the starport domain and if the network title was not specified explicitly it means it is the starport network. Wdyt?

Many methods rely upon launchtypes.NewQueryClient it returns new instance of a network client which is performing a request sending.

I don't see a reason for creating a new queryClient every time performing a query to the network. For example herehere and here or even here (two clients created within one method). Query client(s) could just be initialised in the network constructor As I see they reuse the same connection from Network.cosmos. Code organised this way will be easy to test.

Network Methods:

  • Join
  • sendAccountRequest Mock network.account. Create temp dir and write genesis file there, provide path to the method. hasAccount behaviour is defined via mocked queryClient.GenesisAccount.
  • sendValidatorRequest mock cosmos.BroadcastTx and queryClient.GenesisValidator
  • hasValidator mock queryClient.GenesisValidator and try different results
  • hasAccount mock queryClient.GenesisAccount and queryClient.VestingAccount and try different results
  • LaunchParams mock queryClient.Params and try different return results
  • TriggerLaunch mock queryClient.Params and try different params. Mock cosmos.BroadcastTx and try failed broadcast and invalid response scenarios
  • Publish chain methods can be mocked. queryClients for campaign, profile and launch can be mocked. A lot of cases for tests in this method.
  • ChainLaunch mock queryClient.Chain and try different results
  • ChainLaunches mock queryClient.ChainAll and try different results
  • GenesisInformation results of GenesisAccounts , VestingAccounts and GenesisValidators depend on mocked queryClient
  • VestingAccounts mock queryClient.VestingAccountAll and try different results and an invalid validator
  • GenesisValidators mock queryClient.GenesisValidatorAll and try different results
  • GenesisAccounts mock queryClient.GenesisAccountsAll and try different results
  • Requests mock queryClient.RequestAll and try different results ( i would suggest moving this function to queries.go)
  • Request mock queryClient.Request and try different results( i would suggest moving this function to queries.go)
  • SubmitRequest mock cosmos.BroadcastTx and try failed broadcast and invalid response scenarios
  • VerifyRequests mock queryClient.Request and try different types of invalid requests

@ilgooz ilgooz added this to the T1 milestone Feb 10, 2022
@ilgooz
Copy link
Member Author
ilgooz commented Apr 19, 2022

closed by #2235.

@ilgooz ilgooz closed this as completed Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0