Skip to content
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

Test network fails to initialize for some cli tests #312

Closed
lumtis opened this issue Sep 24, 2021 · 5 comments · Fixed by #310
Closed

Test network fails to initialize for some cli tests #312

lumtis opened this issue Sep 24, 2021 · 5 comments · Fixed by #310
Assignees

Comments

@lumtis
Copy link
Contributor

lumtis commented Sep 24, 2021

From migration to 0.44.0: #310

Test network initialization fails for some CLI tests:

campaign/client/cli/query_mainnet_account_test.go
campaign/client/cli/query_mainnet_vesting_account_test.go
launch/client/cli/query_request_test.go

The genesis initialization of the distribution module fails with the error:

panic: distribution module balance does not match the module holdings: 1000000000node0token,500000000stake <->  [recovered]
	panic: distribution module balance does not match the module holdings: 1000000000node0token,500000000stake <-> 

The problem is the distribution module balance should be empty at the genesis initialization but here the module balance is 1000000000node0token,500000000stake

The tests are passing when tested individually, the error only occurs when the whole package is tested.

Also the error is actually related to the specific type to test because when removing the types to test from the genesis, the test network initialization is successful:
For example with Request

func networkWithRequestObjects(t *testing.T, n int) (*network.Network, []types.Request) {
	t.Helper()
	cfg := network.DefaultConfig()
	state := types.GenesisState{}
	require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))

        // Fails when those requests are added to the genesis
	//for i := 0; i < n; i++ {
	//	request := sample.Request(0)
	//	request.RequestID = uint64(i)
	//	state.RequestList = append(
	//		state.RequestList,
	//		request,
	//	)
	//}
	buf, err := cfg.Codec.MarshalJSON(&state)
	require.NoError(t, err)
	cfg.GenesisState[types.ModuleName] = buf
	return network.New(t, cfg), state.RequestList
}
@lumtis
Copy link
Contributor Author

lumtis commented Sep 24, 2021

Issue seems to occur when having sdk.AccAddress values in the genesis

@Pantani
Copy link
Collaborator

Pantani commented Sep 24, 2021

Maybe we can clean up the data after the test run

@lumtis lumtis self-assigned this Sep 24, 2021
@lumtis
Copy link
Contributor Author

lumtis commented Sep 24, 2021

I got it, we seal the config when calling sample.AccAddress in order to have the correct prefix spn, and apparently this is not good when we use network package.

Though the relationship with the actual error is very ambiguous

@lumtis
Copy link
Contributor Author

lumtis commented Sep 24, 2021

I will make the fix for #310 finally. I think we can merge #306

@lumtis
Copy link
Contributor Author

lumtis commented Sep 24, 2021

I just realize that we don't need to set the prefix at all for the tests. If not globally set, the whole testing environment will use the default prefix for valid address. We just need to ensure no hardcoded address are set with spn prefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants