From d4c8df1879582a17bac52fc222f8c5c541ba1175 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 16 Nov 2022 14:42:18 -0800 Subject: [PATCH 1/7] Create debug_test.go --- testutil/e2e/debug_test.go | 156 +++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 testutil/e2e/debug_test.go diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go new file mode 100644 index 0000000000..c5068c8995 --- /dev/null +++ b/testutil/e2e/debug_test.go @@ -0,0 +1,156 @@ +// Contains native golang tests relevant to individual CCVTestSuite tests, +// enabling easier debugging of individual e2e tests in VSCode. +package e2e_test + +import ( + "os" + "reflect" + "strings" + "testing" + + appConsumer "github.com/cosmos/interchain-security/app/consumer" + appProvider "github.com/cosmos/interchain-security/app/provider" + "github.com/cosmos/interchain-security/tests/e2e" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" +) + +// runE2eTestByName runs a single e2e test by name, using a CCVTestSuite +// initialized with the dummy provider and consumer defined in this repo. +func runE2eTestByName(t *testing.T, testName string) { + + if strings.Contains(os.Args[0], "/_test/") { + t.Skip("Skipping e2e test in test binary") + } + + s := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( + icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter) + s.SetT(t) + + methodFinder := reflect.TypeOf(s) + method, found := methodFinder.MethodByName(testName) + if !found { + t.Errorf("Method %s is not defined for CCVTestSuite", testName) + } + + s.SetupTest() + method.Func.Call([]reflect.Value{reflect.ValueOf(s)}) +} + +// +// Channel init tests +// + +func TestConsumerGenesis(t *testing.T) { + runE2eTestByName(t, "TestConsumerGenesis") +} + +func TestInitTimeout(t *testing.T) { + runE2eTestByName(t, "TestInitTimeout") +} + +// +// Distribution tests +// + +func TestRewardsDistribution(t *testing.T) { + runE2eTestByName(t, "TestRewardsDistribution") +} + +// +// Normal operations tests +// +func TestHistoricalInfo(t *testing.T) { + runE2eTestByName(t, "TestHistoricalInfo") +} + +// +// Slashing tests +// + +func TestRelayAndApplySlashPacket(t *testing.T) { + runE2eTestByName(t, "TestRelayAndApplySlashPacket") +} + +func TestSlashPacketAcknowledgement(t *testing.T) { + runE2eTestByName(t, "TestSlashPacketAcknowledgement") +} + +func TestHandleSlashPacketDoubleSigning(t *testing.T) { + runE2eTestByName(t, "TestHandleSlashPacketDoubleSigning") +} + +func TestHandleSlashPacketErrors(t *testing.T) { + runE2eTestByName(t, "TestHandleSlashPacketErrors") +} + +func TestHandleSlashPacketDistribution(t *testing.T) { + runE2eTestByName(t, "TestHandleSlashPacketDistribution") +} + +func TestValidatorDowntime(t *testing.T) { + runE2eTestByName(t, "TestValidatorDowntime") +} + +func TestValidatorDoubleSigning(t *testing.T) { + runE2eTestByName(t, "TestValidatorDoubleSigning") +} + +func TestSendSlashPacket(t *testing.T) { + runE2eTestByName(t, "TestSendSlashPacket") +} + +// +// Stop consumer tests +// + +func TestStopConsumerChain(t *testing.T) { + runE2eTestByName(t, "TestStopConsumerChain") +} + +func TestStopConsumerOnChannelClosed(t *testing.T) { + runE2eTestByName(t, "TestStopConsumerOnChannelClosed") +} + +func TestProviderChannelClosed(t *testing.T) { + runE2eTestByName(t, "TestProviderChannelClosed") +} + +// +// Unbonding tests +// + +func TestUndelegationNormalOperation(t *testing.T) { + runE2eTestByName(t, "TestUndelegationNormalOperation") +} + +func TestUndelegationVscTimeout(t *testing.T) { + runE2eTestByName(t, "TestUndelegationVscTimeout") +} + +func TestUndelegationDuringInit(t *testing.T) { + runE2eTestByName(t, "TestUndelegationDuringInit") +} + +func TestUnbondingNoConsumer(t *testing.T) { + runE2eTestByName(t, "TestUnbondingNoConsumer") +} + +func TestRedelegationNoConsumer(t *testing.T) { + runE2eTestByName(t, "TestRedelegationNoConsumer") +} + +func TestRedelegationProviderFirst(t *testing.T) { + runE2eTestByName(t, "TestRedelegationProviderFirst") +} + +// +// Val set update tests +// + +func TestPacketRoundtrip(t *testing.T) { + runE2eTestByName(t, "TestPacketRoundtrip") +} + +func TestSendVSCMaturedPackets(t *testing.T) { + runE2eTestByName(t, "TestSendVSCMaturedPackets") +} From e89d605dbf011fae327b49b251af14170956397d Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 16 Nov 2022 18:06:17 -0800 Subject: [PATCH 2/7] democ --- testutil/e2e/debug_test.go | 102 +++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index c5068c8995..89a5d1e7c8 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -1,39 +1,51 @@ -// Contains native golang tests relevant to individual CCVTestSuite tests, +// Contains native golang tests relevant to individual e2e tests, // enabling easier debugging of individual e2e tests in VSCode. package e2e_test import ( - "os" "reflect" - "strings" "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" ) -// runE2eTestByName runs a single e2e test by name, using a CCVTestSuite +// runCCVTestByName runs a single CCV e2e test by name, using a CCVTestSuite // initialized with the dummy provider and consumer defined in this repo. -func runE2eTestByName(t *testing.T, testName string) { +func runCCVTestByName(t *testing.T, methodName string) { - if strings.Contains(os.Args[0], "/_test/") { - t.Skip("Skipping e2e test in test binary") - } - - s := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( + suite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter) - s.SetT(t) + 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) +} - methodFinder := reflect.TypeOf(s) - method, found := methodFinder.MethodByName(testName) +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", testName) + t.Errorf("Method %s is not defined for CCVTestSuite", methodName) } - s.SetupTest() - method.Func.Call([]reflect.Value{reflect.ValueOf(s)}) + method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) } // @@ -41,11 +53,23 @@ func runE2eTestByName(t *testing.T, testName string) { // func TestConsumerGenesis(t *testing.T) { - runE2eTestByName(t, "TestConsumerGenesis") + runCCVTestByName(t, "TestConsumerGenesis") } func TestInitTimeout(t *testing.T) { - runE2eTestByName(t, "TestInitTimeout") + runCCVTestByName(t, "TestInitTimeout") +} + +// +// Consumer democracy tests +// + +func TestDemocracyRewardsDistribution(t *testing.T) { + runConsumerDemocracyTestByName(t, "TestDemocracyRewardsDistribution") +} + +func TestDemocracyGovernanceWhitelisting(t *testing.T) { + runConsumerDemocracyTestByName(t, "TestDemocracyGovernanceWhitelisting") } // @@ -53,14 +77,14 @@ func TestInitTimeout(t *testing.T) { // func TestRewardsDistribution(t *testing.T) { - runE2eTestByName(t, "TestRewardsDistribution") + runCCVTestByName(t, "TestRewardsDistribution") } // // Normal operations tests // func TestHistoricalInfo(t *testing.T) { - runE2eTestByName(t, "TestHistoricalInfo") + runCCVTestByName(t, "TestHistoricalInfo") } // @@ -68,35 +92,35 @@ func TestHistoricalInfo(t *testing.T) { // func TestRelayAndApplySlashPacket(t *testing.T) { - runE2eTestByName(t, "TestRelayAndApplySlashPacket") + runCCVTestByName(t, "TestRelayAndApplySlashPacket") } func TestSlashPacketAcknowledgement(t *testing.T) { - runE2eTestByName(t, "TestSlashPacketAcknowledgement") + runCCVTestByName(t, "TestSlashPacketAcknowledgement") } func TestHandleSlashPacketDoubleSigning(t *testing.T) { - runE2eTestByName(t, "TestHandleSlashPacketDoubleSigning") + runCCVTestByName(t, "TestHandleSlashPacketDoubleSigning") } func TestHandleSlashPacketErrors(t *testing.T) { - runE2eTestByName(t, "TestHandleSlashPacketErrors") + runCCVTestByName(t, "TestHandleSlashPacketErrors") } func TestHandleSlashPacketDistribution(t *testing.T) { - runE2eTestByName(t, "TestHandleSlashPacketDistribution") + runCCVTestByName(t, "TestHandleSlashPacketDistribution") } func TestValidatorDowntime(t *testing.T) { - runE2eTestByName(t, "TestValidatorDowntime") + runCCVTestByName(t, "TestValidatorDowntime") } func TestValidatorDoubleSigning(t *testing.T) { - runE2eTestByName(t, "TestValidatorDoubleSigning") + runCCVTestByName(t, "TestValidatorDoubleSigning") } func TestSendSlashPacket(t *testing.T) { - runE2eTestByName(t, "TestSendSlashPacket") + runCCVTestByName(t, "TestSendSlashPacket") } // @@ -104,15 +128,15 @@ func TestSendSlashPacket(t *testing.T) { // func TestStopConsumerChain(t *testing.T) { - runE2eTestByName(t, "TestStopConsumerChain") + runCCVTestByName(t, "TestStopConsumerChain") } func TestStopConsumerOnChannelClosed(t *testing.T) { - runE2eTestByName(t, "TestStopConsumerOnChannelClosed") + runCCVTestByName(t, "TestStopConsumerOnChannelClosed") } func TestProviderChannelClosed(t *testing.T) { - runE2eTestByName(t, "TestProviderChannelClosed") + runCCVTestByName(t, "TestProviderChannelClosed") } // @@ -120,27 +144,27 @@ func TestProviderChannelClosed(t *testing.T) { // func TestUndelegationNormalOperation(t *testing.T) { - runE2eTestByName(t, "TestUndelegationNormalOperation") + runCCVTestByName(t, "TestUndelegationNormalOperation") } func TestUndelegationVscTimeout(t *testing.T) { - runE2eTestByName(t, "TestUndelegationVscTimeout") + runCCVTestByName(t, "TestUndelegationVscTimeout") } func TestUndelegationDuringInit(t *testing.T) { - runE2eTestByName(t, "TestUndelegationDuringInit") + runCCVTestByName(t, "TestUndelegationDuringInit") } func TestUnbondingNoConsumer(t *testing.T) { - runE2eTestByName(t, "TestUnbondingNoConsumer") + runCCVTestByName(t, "TestUnbondingNoConsumer") } func TestRedelegationNoConsumer(t *testing.T) { - runE2eTestByName(t, "TestRedelegationNoConsumer") + runCCVTestByName(t, "TestRedelegationNoConsumer") } func TestRedelegationProviderFirst(t *testing.T) { - runE2eTestByName(t, "TestRedelegationProviderFirst") + runCCVTestByName(t, "TestRedelegationProviderFirst") } // @@ -148,9 +172,9 @@ func TestRedelegationProviderFirst(t *testing.T) { // func TestPacketRoundtrip(t *testing.T) { - runE2eTestByName(t, "TestPacketRoundtrip") + runCCVTestByName(t, "TestPacketRoundtrip") } func TestSendVSCMaturedPackets(t *testing.T) { - runE2eTestByName(t, "TestSendVSCMaturedPackets") + runCCVTestByName(t, "TestSendVSCMaturedPackets") } From bcc911b714964eb56bfc16372c1901cbb2f69bf7 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 16 Nov 2022 18:19:20 -0800 Subject: [PATCH 3/7] Update debug_test.go --- testutil/e2e/debug_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index 89a5d1e7c8..a248be9dc9 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -42,7 +42,7 @@ 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) + t.Errorf("Method %s is not defined for suite type", methodName) } method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) From 3feffc364af2b2696831c3d9a8d07dd7188784bd Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 18 Nov 2022 09:11:35 -0800 Subject: [PATCH 4/7] bump to main --- testutil/e2e/debug_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index a248be9dc9..fd23d032a1 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -119,8 +119,8 @@ func TestValidatorDoubleSigning(t *testing.T) { runCCVTestByName(t, "TestValidatorDoubleSigning") } -func TestSendSlashPacket(t *testing.T) { - runCCVTestByName(t, "TestSendSlashPacket") +func TestQueueAndSendSlashPacket(t *testing.T) { + runCCVTestByName(t, "TestQueueAndSendSlashPacket") } // From 5820981b88c23a7d66209b6d306f1e713149e1bc Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 18 Nov 2022 09:21:55 -0800 Subject: [PATCH 5/7] another bump, missed one --- testutil/e2e/debug_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index fd23d032a1..1117a454a5 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -175,6 +175,6 @@ func TestPacketRoundtrip(t *testing.T) { runCCVTestByName(t, "TestPacketRoundtrip") } -func TestSendVSCMaturedPackets(t *testing.T) { - runCCVTestByName(t, "TestSendVSCMaturedPackets") +func TestQueueAndSendVSCMaturedPackets(t *testing.T) { + runCCVTestByName(t, "TestQueueAndSendVSCMaturedPackets") } From d78b599d8a440c4a3cbb6c590170776337a3a661 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 18 Nov 2022 10:54:07 -0800 Subject: [PATCH 6/7] fix after merge main --- testutil/e2e/debug_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index 1117a454a5..fe775ed0e6 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -18,7 +18,7 @@ import ( func runCCVTestByName(t *testing.T, methodName string) { suite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( - icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter) + icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter, []string{}) suite.SetT(t) suite.SetupTest() From 97eb82edcd8799842f8bbe5d81a35ae467418f85 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 18 Nov 2022 11:57:33 -0800 Subject: [PATCH 7/7] expired client tests --- testutil/e2e/debug_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testutil/e2e/debug_test.go b/testutil/e2e/debug_test.go index fe775ed0e6..b779082972 100644 --- a/testutil/e2e/debug_test.go +++ b/testutil/e2e/debug_test.go @@ -80,9 +80,22 @@ func TestRewardsDistribution(t *testing.T) { runCCVTestByName(t, "TestRewardsDistribution") } +// +// Expired client tests +// + +func TestVSCPacketSendExpiredClient(t *testing.T) { + runCCVTestByName(t, "TestVSCPacketSendExpiredClient") +} + +func TestConsumerPacketSendExpiredClient(t *testing.T) { + runCCVTestByName(t, "TestConsumerPacketSendExpiredClient") +} + // // Normal operations tests // + func TestHistoricalInfo(t *testing.T) { runCCVTestByName(t, "TestHistoricalInfo") }