Skip to content

Commit

Permalink
Sets up test to be able to check log output with (-v)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Dec 9, 2022
1 parent b3d79ac commit 93278dc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/difference/core/driver/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (s *CoreSuite) TestTraces() {

func TestCoreSuite(t *testing.T) {
// TODO: Reenable diff tests once model is updated
// suite.Run(t, new(CoreSuite))
suite.Run(t, new(CoreSuite))
}

// SetupTest sets up the test suite in a 'zero' state which matches
Expand Down
4 changes: 2 additions & 2 deletions tests/difference/core/driver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ func (b *Builder) createChains() {
// Create validators
validators, signers, addresses := b.createValidators()
// Create provider
coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, icstestingutils.ProviderAppIniter, ibctesting.GetChainID(0), validators, signers)
coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, icstestingutils.ProviderAppIniterWithLog, ibctesting.GetChainID(0), validators, signers)
// Create consumer, using the same validators.
coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, icstestingutils.ConsumerAppIniter, ibctesting.GetChainID(1), validators, signers)
coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, icstestingutils.ConsumerAppIniterWithLog, ibctesting.GetChainID(1), validators, signers)

b.coordinator = coordinator
b.valAddresses = addresses
Expand Down
24 changes: 24 additions & 0 deletions testutil/ibc_testing/specific_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ import (
appProvider "github.com/cosmos/interchain-security/app/provider"
)

// TODO: refactor this out test (-v) verbose flag needed to see output!
func ProviderAppIniterWithLog() (ibctesting.TestingApp, map[string]json.RawMessage) {
l := log.TestingLogger()
l = log.NewFilter(l,
log.AllowDebugWith("module", "x/ibc-provider"))

encoding := cosmoscmd.MakeEncodingConfig(appProvider.ModuleBasics)
testApp := appProvider.New(l, tmdb.NewMemDB(), nil, true, map[int64]bool{},
simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp)
return testApp, appProvider.NewDefaultGenesisState(encoding.Marshaler)
}

// TODO: refactor this out test (-v) verbose flag needed to see output!
func ConsumerAppIniterWithLog() (ibctesting.TestingApp, map[string]json.RawMessage) {
l := log.TestingLogger()
l = log.NewFilter(l,
log.AllowDebugWith("module", "x/ibc-consumer"))

encoding := cosmoscmd.MakeEncodingConfig(appConsumer.ModuleBasics)
testApp := appConsumer.New(l, tmdb.NewMemDB(), nil, true, map[int64]bool{},
simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp)
return testApp, appConsumer.NewDefaultGenesisState(encoding.Marshaler)
}

// ProviderAppIniter implements ibctesting.AppIniter for a provider app
func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) {
encoding := cosmoscmd.MakeEncodingConfig(appProvider.ModuleBasics)
Expand Down
5 changes: 5 additions & 0 deletions x/ccv/consumer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
// EndBlock implements the AppModule interface
// Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding.
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {

am.keeper.Logger(ctx).Debug("trying out the logger (consumer) (debug)")
am.keeper.Logger(ctx).Info("trying out the logger (consumer) (info)")
am.keeper.Logger(ctx).Error("trying out the logger (consumer) (err)")

// distribution transmission
err := am.keeper.DistributeToProviderValidatorSet(ctx)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions x/ccv/provider/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {

// EndBlock implements the AppModule interface
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {

am.keeper.Logger(ctx).Debug("trying out the logger (provider) (debug)")
am.keeper.Logger(ctx).Info("trying out the logger (provider) (info)")
am.keeper.Logger(ctx).Error("trying out the logger (provider) (err)")

// EndBlock logic needed for the Consumer Initiated Slashing sub-protocol.
// Important: EndBlockCIS must be called before EndBlockVSU
am.keeper.EndBlockCIS(ctx)
Expand Down

0 comments on commit 93278dc

Please sign in to comment.