Skip to content

Commit

Permalink
chore: review feedback improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jan 12, 2024
1 parent cd19c7e commit 12dbc57
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
3 changes: 0 additions & 3 deletions testutil/network/basenet/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ func (memnet *BaseInMemoryNetwork) FundAddress(
t.Helper()

signerAccountNumber := 0
// Validator's client context MUST be used for this CLI command because its keyring includes the validator's key
clientCtx := memnet.GetClientCtx(t)
// MUST NOT use memnet.GetClientCtx(t) as its keyring does not include the validator's account
// TODO_UPNEXT(@bryanchriswhite): Ensure validator key is always available via the in-memory network's keyring.
net := memnet.GetNetwork(t)
val := net.Validators[0]

Expand Down
14 changes: 8 additions & 6 deletions testutil/network/gatewaynet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ func (memnet *inMemoryNetworkWithGateways) Start(_ context.Context, t *testing.T
}

// configureGatewayModuleGenesisState generates and populates the in-memory network's
// application module's GenesisState object with the number of applications specified
// by the InMemoryConfig, each of which is staked for a unique service. It returns
// the genesis state object.
// gateway module's GenesisState object with the number of gateways specified by the
// InMemoryConfig.
func (memnet *inMemoryNetworkWithGateways) configureGatewayModuleGenesisState(t *testing.T) {
t.Helper()

Expand All @@ -140,7 +139,6 @@ func (memnet *inMemoryNetworkWithGateways) configureGatewayModuleGenesisState(t
stake := sdk.NewCoin("upokt", sdk.NewInt(10000))
preGeneratedAcct, ok := memnet.PreGeneratedAccountIterator.Next()
require.Truef(t, ok, "pre-generated accounts iterator exhausted")
require.Truef(t, ok, "pre-generated accounts iterator exhausted")

gateway := gatewaytypes.Gateway{
Address: preGeneratedAcct.Address.String(),
Expand All @@ -153,10 +151,14 @@ func (memnet *inMemoryNetworkWithGateways) configureGatewayModuleGenesisState(t
gatewayGenesisBuffer, err := memnet.GetCosmosNetworkConfig(t).Codec.MarshalJSON(gatewayGenesisState)
require.NoError(t, err)

// Add supplier module genesis supplierGenesisState to the network config.
// Add gateway module genesis state to the network config.
memnet.GetCosmosNetworkConfig(t).GenesisState[gatewaytypes.ModuleName] = gatewayGenesisBuffer
}

// configureAppModuleGenesisState generates and populates the in-memory network's
// application module's GenesisState object with the number of applications specified
// by the InMemoryConfig, each of which is staked for a unique service. It returns
// the genesis state object.
func (memnet *inMemoryNetworkWithGateways) configureAppModuleGenesisState(t *testing.T) {
t.Helper()

Expand All @@ -182,6 +184,6 @@ func (memnet *inMemoryNetworkWithGateways) configureAppModuleGenesisState(t *tes
appGenesisBuffer, err := memnet.Config.CosmosCfg.Codec.MarshalJSON(appGenesisState)
require.NoError(t, err)

// Add application module genesis appGenesisState to the network memnet cosmos config.
// Add application module genesis state to the network memnet cosmos config.
memnet.GetCosmosNetworkConfig(t).GenesisState[apptypes.ModuleName] = appGenesisBuffer
}
2 changes: 1 addition & 1 deletion testutil/network/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func GetGenesisState[T proto.Message](t *testing.T, moduleName string, memnet In

var genesisState T
// NB: As this function is generic, it MUST use reflect in order to unmarshal
// the genesis state as the codec requries a reference to a concrete type pointer.
// the genesis state as the codec requires a reference to a concrete type pointer.
genesisStateType := reflect.TypeOf(genesisState)
genesisStateValue := reflect.New(genesisStateType.Elem())
genesisStatePtr := genesisStateValue.Interface().(proto.Message)
Expand Down
11 changes: 5 additions & 6 deletions testutil/network/sessionnet/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,17 @@ func (memnet *inMemoryNetworkWithSessions) configureSupplierModuleGenesisState(t
supplierGenesisBuffer, err := memnet.GetCosmosNetworkConfig(t).Codec.MarshalJSON(supplierGenesisState)
require.NoError(t, err)

// Add supplier module genesis supplierGenesisState to the network config.
// Add supplier module genesis state to the network config.
memnet.GetCosmosNetworkConfig(t).GenesisState[suppliertypes.ModuleName] = supplierGenesisBuffer

return supplierGenesisState
}

// configureApplicationModuleGenesisState generates and populates the in-memory network's
// applicaion module's GenesisState object with a given number of applications,
// each of which is staked for a service such that
// memnet.Config.AppSupplierPairingRatio*NumSuppliers number of applications are staked
// for each genesis supplier's service (assumes that each supplier is staked for a unique
// service with no overlap).
// application module's GenesisState object with a given number of applications, each of
// which is staked for a service such that memnet.Config.AppSupplierPairingRatio*NumSuppliers
// number of applications are staked for each genesis supplier's service (assumes that each
// supplier is staked for a unique service with no overlap).
func (memnet *inMemoryNetworkWithSessions) configureAppModuleGenesisState(t *testing.T) *apptypes.GenesisState {
t.Helper()

Expand Down

0 comments on commit 12dbc57

Please sign in to comment.