Skip to content

Commit

Permalink
make readable
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jul 18, 2023
1 parent 2f62e7d commit d30e444
Showing 1 changed file with 83 additions and 2 deletions.
85 changes: 83 additions & 2 deletions x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,91 @@ func TestMakeConsumerGenesis(t *testing.T) {
actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, &prop)
require.NoError(t, err)

jsonString := `{"params":{"enabled":true, "blocks_per_distribution_transmission":1000, "ccv_timeout_period":2419200000000000, "transfer_timeout_period": 3600000000000, "consumer_redistribution_fraction":"0.75", "historical_entries":10000, "unbonding_period": 1728000000000000, "soft_opt_out_threshold": "0.05", "reward_denoms": [], "provider_reward_denoms": []},"new_chain":true,"provider_client_state":{"chain_id":"testchain1","trust_level":{"numerator":1,"denominator":3},"trusting_period":1197504000000000,"unbonding_period":1814400000000000,"max_clock_drift":10000000000,"frozen_height":{},"latest_height":{"revision_height":5},"proof_specs":[{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"hash":1}},{"leaf_spec":{"hash":1,"prehash_value":1,"length":1,"prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"hash":1}}],"upgrade_path":["upgrade","upgradedIBCState"],"allow_update_after_expiry":true,"allow_update_after_misbehaviour":true},"provider_consensus_state":{"timestamp":"2020-01-02T00:00:10Z","root":{"hash":"LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="},"next_validators_hash":"E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"},"unbonding_sequences":null,"initial_val_set":[{"pub_key":{"type":"tendermint/PubKeyEd25519","value":"dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="},"power":1}]}`
// JSON string with tabs, newlines and spaces for readability
jsonString := `{
"params": {
"enabled": true,
"blocks_per_distribution_transmission": 1000,
"ccv_timeout_period": 2419200000000000,
"transfer_timeout_period": 3600000000000,
"consumer_redistribution_fraction": "0.75",
"historical_entries": 10000,
"unbonding_period": 1728000000000000,
"soft_opt_out_threshold": "0.05",
"reward_denoms": [],
"provider_reward_denoms": []
},
"new_chain": true,
"provider_client_state": {
"chain_id": "testchain1",
"trust_level": {
"numerator": 1,
"denominator": 3
},
"trusting_period": 1197504000000000,
"unbonding_period": 1814400000000000,
"max_clock_drift": 10000000000,
"frozen_height": {},
"latest_height": {
"revision_height": 5
},
"proof_specs": [
{
"leaf_spec": {
"hash": 1,
"prehash_value": 1,
"length": 1,
"prefix": "AA=="
},
"inner_spec": {
"child_order": [0, 1],
"child_size": 33,
"min_prefix_length": 4,
"max_prefix_length": 12,
"hash": 1
}
},
{
"leaf_spec": {
"hash": 1,
"prehash_value": 1,
"length": 1,
"prefix": "AA=="
},
"inner_spec": {
"child_order": [0, 1],
"child_size": 32,
"min_prefix_length": 1,
"max_prefix_length": 1,
"hash": 1
}
}
],
"upgrade_path": ["upgrade", "upgradedIBCState"],
"allow_update_after_expiry": true,
"allow_update_after_misbehaviour": true
},
"provider_consensus_state": {
"timestamp": "2020-01-02T00:00:10Z",
"root": {
"hash": "LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA="
},
"next_validators_hash": "E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE"
},
"unbonding_sequences": null,
"initial_val_set": [
{
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro="
},
"power": 1
}
]
}`

var expectedGenesis consumertypes.GenesisState
err = json.Unmarshal([]byte(jsonString), &expectedGenesis)
err = json.Unmarshal([]byte(jsonString), &expectedGenesis) // ignores tabs, newlines and spaces
require.NoError(t, err)

// Zeroing out different fields that are challenging to mock
Expand Down

0 comments on commit d30e444

Please sign in to comment.