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

Create e2e debug util file #488

Merged
merged 13 commits into from
Nov 21, 2022
180 changes: 180 additions & 0 deletions testutil/e2e/debug_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// Contains native golang tests relevant to individual e2e tests,
// enabling easier debugging of individual e2e tests in VSCode.
package e2e_test

import (
"reflect"
"testing"

appConsumer "github.com/cosmos/interchain-security/app/consumer"
appConsumerDemocracy "github.com/cosmos/interchain-security/app/consumer-democracy"
appProvider "github.com/cosmos/interchain-security/app/provider"
"github.com/cosmos/interchain-security/tests/e2e"
icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing"
)

// runCCVTestByName runs a single CCV e2e test by name, using a CCVTestSuite
// initialized with the dummy provider and consumer defined in this repo.
func runCCVTestByName(t *testing.T, methodName string) {

suite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App](
icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter)
suite.SetT(t)
suite.SetupTest()

findAndCallMethod(t, suite, methodName)
}

// runConsumerDemocracyTestByName runs a single consumer democracy e2e test by name,
// using a ConsumerDemocracyTestSuite initialized with the dummy
// democracy consumer defined in this repo.
func runConsumerDemocracyTestByName(t *testing.T, methodName string) {

suite := e2e.NewConsumerDemocracyTestSuite[*appConsumerDemocracy.App](
icstestingutils.DemocracyConsumerAppIniter)
suite.SetT(t)
suite.SetupTest()

findAndCallMethod(t, suite, methodName)
}

func findAndCallMethod(t *testing.T, suite any, methodName string) {
methodFinder := reflect.TypeOf(suite)
method, found := methodFinder.MethodByName(methodName)
if !found {
t.Errorf("Method %s is not defined for CCVTestSuite", methodName)
}

method.Func.Call([]reflect.Value{reflect.ValueOf(suite)})
}

//
// Channel init tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are ordered as they appear in the VSCode explorer

//

func TestConsumerGenesis(t *testing.T) {
runCCVTestByName(t, "TestConsumerGenesis")
}

func TestInitTimeout(t *testing.T) {
runCCVTestByName(t, "TestInitTimeout")
}

//
// Consumer democracy tests
//

func TestDemocracyRewardsDistribution(t *testing.T) {
runConsumerDemocracyTestByName(t, "TestDemocracyRewardsDistribution")
}

func TestDemocracyGovernanceWhitelisting(t *testing.T) {
runConsumerDemocracyTestByName(t, "TestDemocracyGovernanceWhitelisting")
}

//
// Distribution tests
//

func TestRewardsDistribution(t *testing.T) {
runCCVTestByName(t, "TestRewardsDistribution")
}

//
// Normal operations tests
//
func TestHistoricalInfo(t *testing.T) {
runCCVTestByName(t, "TestHistoricalInfo")
}

//
// Slashing tests
//

func TestRelayAndApplySlashPacket(t *testing.T) {
runCCVTestByName(t, "TestRelayAndApplySlashPacket")
}

func TestSlashPacketAcknowledgement(t *testing.T) {
runCCVTestByName(t, "TestSlashPacketAcknowledgement")
}

func TestHandleSlashPacketDoubleSigning(t *testing.T) {
runCCVTestByName(t, "TestHandleSlashPacketDoubleSigning")
}

func TestHandleSlashPacketErrors(t *testing.T) {
runCCVTestByName(t, "TestHandleSlashPacketErrors")
}

func TestHandleSlashPacketDistribution(t *testing.T) {
runCCVTestByName(t, "TestHandleSlashPacketDistribution")
}

func TestValidatorDowntime(t *testing.T) {
runCCVTestByName(t, "TestValidatorDowntime")
}

func TestValidatorDoubleSigning(t *testing.T) {
runCCVTestByName(t, "TestValidatorDoubleSigning")
}

func TestSendSlashPacket(t *testing.T) {
runCCVTestByName(t, "TestSendSlashPacket")
}

//
// Stop consumer tests
//

func TestStopConsumerChain(t *testing.T) {
runCCVTestByName(t, "TestStopConsumerChain")
}

func TestStopConsumerOnChannelClosed(t *testing.T) {
runCCVTestByName(t, "TestStopConsumerOnChannelClosed")
}

func TestProviderChannelClosed(t *testing.T) {
runCCVTestByName(t, "TestProviderChannelClosed")
}

//
// Unbonding tests
//

func TestUndelegationNormalOperation(t *testing.T) {
runCCVTestByName(t, "TestUndelegationNormalOperation")
}

func TestUndelegationVscTimeout(t *testing.T) {
runCCVTestByName(t, "TestUndelegationVscTimeout")
}

func TestUndelegationDuringInit(t *testing.T) {
runCCVTestByName(t, "TestUndelegationDuringInit")
}

func TestUnbondingNoConsumer(t *testing.T) {
runCCVTestByName(t, "TestUnbondingNoConsumer")
}

func TestRedelegationNoConsumer(t *testing.T) {
runCCVTestByName(t, "TestRedelegationNoConsumer")
}

func TestRedelegationProviderFirst(t *testing.T) {
runCCVTestByName(t, "TestRedelegationProviderFirst")
}

//
// Val set update tests
//

func TestPacketRoundtrip(t *testing.T) {
runCCVTestByName(t, "TestPacketRoundtrip")
}

func TestSendVSCMaturedPackets(t *testing.T) {
runCCVTestByName(t, "TestSendVSCMaturedPackets")
}