From 661e9079fc3922ff5facb174637117d89b71983e Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 09:22:42 +0200
Subject: [PATCH 01/88] Add script to summarize integration tests
---
scripts/test_doc/extract_docstrings.go | 98 ++++++++++++++++++++++++++
scripts/test_doc/test_documentation.md | 49 +++++++++++++
2 files changed, 147 insertions(+)
create mode 100644 scripts/test_doc/extract_docstrings.go
create mode 100644 scripts/test_doc/test_documentation.md
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
new file mode 100644
index 0000000000..6616b75c0b
--- /dev/null
+++ b/scripts/test_doc/extract_docstrings.go
@@ -0,0 +1,98 @@
+package main
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "io/ioutil"
+ "log"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+func main() {
+ // Define the directory to traverse and the output markdown file
+ dir := "../../tests/integration"
+ outputFile := "test_documentation.md"
+
+ // Open the output file
+ out, err := os.Create(outputFile)
+ if err != nil {
+ log.Fatalf("Error creating output file: %v\n", err)
+ }
+ defer out.Close()
+
+ // Write the header for the markdown file
+ fmt.Fprintf(out, "# Test Documentation\n\n")
+ fmt.Fprintf(out, "| File | Function | Short Description |\n")
+ fmt.Fprintf(out, "|------|----------|-------------------|\n")
+
+ // Walk through the directory
+ err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+
+ // Only process .go files
+ if !info.IsDir() && strings.HasSuffix(info.Name(), ".go") {
+ extractDocstrings(path, out)
+ }
+ return nil
+ })
+ if err != nil {
+ log.Fatalf("Error walking the path %q: %v\n", dir, err)
+ }
+
+ fmt.Printf("Documentation generated successfully in %s\n", outputFile)
+}
+
+func extractDocstrings(filePath string, out *os.File) {
+ // Read the Go source file
+ src, err := ioutil.ReadFile(filePath)
+ if err != nil {
+ log.Fatalf("Error reading file %s: %v\n", filePath, err)
+ }
+
+ // Create the AST for the source file
+ fset := token.NewFileSet()
+ node, err := parser.ParseFile(fset, filePath, src, parser.ParseComments)
+ if err != nil {
+ log.Fatalf("Error parsing file %s: %v\n", filePath, err)
+ }
+
+ // Traverse the AST
+ for _, f := range node.Decls {
+ if fn, isFn := f.(*ast.FuncDecl); isFn && strings.HasPrefix(fn.Name.Name, "Test") {
+ // Check if the function has a docstring
+ if fn.Doc != nil {
+ doc := fn.Doc.Text()
+ relativePath := strings.TrimPrefix(filePath, "../../tests/integration/")
+ link := fmt.Sprintf("[%s](%s#L%d)", relativePath, filePath, fset.Position(fn.Pos()).Line)
+
+ // Split the docstring based on the separator "========"
+ parts := strings.Split(doc, "\n========\n")
+ var shortDescription, longDescription string
+ if len(parts) > 1 {
+ shortDescription = strings.TrimSpace(parts[0])
+ longDescription = strings.TrimSpace(parts[1])
+ } else {
+ shortDescription = strings.TrimSpace(doc)
+ longDescription = ""
+ }
+
+ // Format the description
+ description := shortDescription
+ if longDescription != "" {
+ description += fmt.Sprintf("Details
%s ", longDescription)
+ }
+ // for formatting the description in markdown table,
+ // replace newlines with spaces
+ description = strings.ReplaceAll(description, "\n", " ")
+
+ fmt.Fprintf(out, "| %s | %s | %s |\n", link, fn.Name.Name, description)
+ }
+ }
+ }
+}
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
new file mode 100644
index 0000000000..235cb4b10c
--- /dev/null
+++ b/scripts/test_doc/test_documentation.md
@@ -0,0 +1,49 @@
+# Test Documentation
+
+| File | Function | Short Description |
+|------|----------|-------------------|
+| [channel_init.go](../../tests/integration/channel_init.go#L4) | TestInitTimeout | TestInitTimeout tests the init timeout |
+| [distribution.go](../../tests/integration/distribution.go#L24) | TestRewardsDistribution | This test is valid for minimal viable consumer chain |
+| [distribution.go](../../tests/integration/distribution.go#L187) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
+| [distribution.go](../../tests/integration/distribution.go#L263) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L383) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L525) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
+| [distribution.go](../../tests/integration/distribution.go#L707) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
+| [distribution.go](../../tests/integration/distribution.go#L971) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
+| [distribution.go](../../tests/integration/distribution.go#L1079) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
+| [double_vote.go](../../tests/integration/double_vote.go#L17) | TestHandleConsumerDoubleVoting | TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator |
+| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
+| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
+| [expired_client.go](../../tests/integration/expired_client.go#L87) | TestConsumerPacketSendExpiredClient | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired. While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded. |
+| [instance_test.go](../../tests/integration/instance_test.go#L22) | TestCCVTestSuite | Executes the standard group of ccv tests against a consumer and provider app.go implementation. |
+| [instance_test.go](../../tests/integration/instance_test.go#L35) | TestConsumerDemocracyCCVTestSuite | Executes a standard suite of tests, against a democracy consumer app.go implementation. |
+| [instance_test.go](../../tests/integration/instance_test.go#L51) | TestConsumerDemocracyTestSuite | Executes a specialized group of tests specific to a democracy consumer, against a democracy consumer app.go implementation. |
+| [misbehaviour.go](../../tests/integration/misbehaviour.go#L19) | TestHandleConsumerMisbehaviour | TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators |
+| [normal_operations.go](../../tests/integration/normal_operations.go#L13) | TestHistoricalInfo | Tests the tracking of historical info in the context of new blocks being committed |
+| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L19) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooksDetails
hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
+| [slashing.go](../../tests/integration/slashing.go#L39) | TestRelayAndApplyDowntimePacket | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider. Note: This method does not test the actual slash packet sending logic for downtime and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for those types of tests. |
+| [slashing.go](../../tests/integration/slashing.go#L177) | TestRelayAndApplyDoubleSignPacket | Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet. Note that double-sign slash packets should not affect the provider validator set. |
+| [slashing.go](../../tests/integration/slashing.go#L302) | TestHandleSlashPacketDowntime | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket. |
+| [slashing.go](../../tests/integration/slashing.go#L343) | TestOnRecvSlashPacketErrors | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting |
+| [slashing.go](../../tests/integration/slashing.go#L442) | TestValidatorDowntime | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module |
+| [slashing.go](../../tests/integration/slashing.go#L555) | TestValidatorDoubleSigning | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module |
+| [slashing.go](../../tests/integration/slashing.go#L642) | TestQueueAndSendSlashPacket | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock. |
+| [slashing.go](../../tests/integration/slashing.go#L722) | TestCISBeforeCCVEstablished | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after. |
+| [stop_consumer.go](../../tests/integration/stop_consumer.go#L14) | TestStopConsumerChain | Tests the functionality of stopping a consumer chain at a higher level than unit tests |
+| [stop_consumer.go](../../tests/integration/stop_consumer.go#L99) | TestStopConsumerOnChannelClosed | TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
+| [throttle.go](../../tests/integration/throttle.go#L24) | TestBasicSlashPacketThrottling | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario. |
+| [throttle.go](../../tests/integration/throttle.go#L197) | TestMultiConsumerSlashPacketThrottling | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around. |
+| [throttle.go](../../tests/integration/throttle.go#L319) | TestPacketSpam | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block. |
+| [throttle.go](../../tests/integration/throttle.go#L466) | TestSlashingSmallValidators | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner. |
+| [throttle.go](../../tests/integration/throttle.go#L541) | TestSlashMeterAllowanceChanges | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change. TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
+| [throttle.go](../../tests/integration/throttle.go#L567) | TestSlashAllValidators | Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, and in the first packets recv for that block. This edge case should not occur in practice, but is useful to validate that the slash meter can allow any number of slash packets to be handled in a single block when its allowance is set to "1.0". |
+| [throttle_retry.go](../../tests/integration/throttle_retry.go#L14) | TestSlashRetries | TestSlashRetries tests the throttling v2 retry logic at an integration level. |
+| [unbonding.go](../../tests/integration/unbonding.go#L16) | TestUndelegationNormalOperation | TestUndelegationNormalOperation tests that undelegations complete after the unbonding period elapses on both the consumer and provider, without VSC packets timing out. |
+| [unbonding.go](../../tests/integration/unbonding.go#L131) | TestUndelegationVscTimeout | TestUndelegationVscTimeout tests that an undelegation completes after vscTimeoutPeriod even if it does not reach maturity on the consumer chain. In this case, the consumer chain is removed. |
+| [unbonding.go](../../tests/integration/unbonding.go#L192) | TestUndelegationDuringInit | TestUndelegationDuringInit checks that before the CCV channel is established - no undelegations can complete, even if the provider unbonding period elapses - all the VSC packets are stored in state as pending - if the channel handshake times out, then the undelegation completes |
+| [unbonding.go](../../tests/integration/unbonding.go#L304) | TestUnbondingNoConsumer | Bond some tokens on provider Unbond them to create unbonding op Check unbonding ops on both sides Advance time so that provider's unbonding op completes Check that unbonding has completed in provider staking |
+| [unbonding.go](../../tests/integration/unbonding.go#L342) | TestRedelegationNoConsumer | TestRedelegationNoConsumer tests a redelegate transaction submitted on a provider chain with no consumers |
+| [unbonding.go](../../tests/integration/unbonding.go#L392) | TestRedelegationProviderFirst | TestRedelegationWithConsumer tests a redelegate transaction submitted on a provider chain when the unbonding period elapses first on the provider chain |
+| [unbonding.go](../../tests/integration/unbonding.go#L475) | TestTooManyLastValidators | This test reproduces a fixed bug when an inactive validator enters back into the active set. It used to cause a panic in the provider module hook called by AfterUnbondingInitiated during the staking module EndBlock. |
+| [valset_update.go](../../tests/integration/valset_update.go#L17) | TestPacketRoundtrip | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on provider |
+| [valset_update.go](../../tests/integration/valset_update.go#L41) | TestQueueAndSendVSCMaturedPackets | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call. |
From 30f0c57b109a0e1a7e456e91efc99a51c24ae876 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 09:46:25 +0200
Subject: [PATCH 02/88] Add error messages for missing docstrings
---
scripts/test_doc/extract_docstrings.go | 28 +++++++++++++++++++++++---
scripts/test_doc/test_documentation.md | 5 +----
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index 6616b75c0b..d89638f3cf 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -29,6 +29,8 @@ func main() {
fmt.Fprintf(out, "| File | Function | Short Description |\n")
fmt.Fprintf(out, "|------|----------|-------------------|\n")
+ errorStatusCode := false
+
// Walk through the directory
err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
@@ -36,8 +38,15 @@ func main() {
}
// Only process .go files
- if !info.IsDir() && strings.HasSuffix(info.Name(), ".go") {
- extractDocstrings(path, out)
+ if !info.IsDir() && strings.HasSuffix(info.Name(), ".go") && !strings.HasSuffix(info.Name(), "_test.go") {
+ functionsMissingDocStrings := extractDocstrings(path, out)
+ if len(functionsMissingDocStrings) > 0 {
+ fmt.Printf("The following test functions in %s are missing docstrings:\n", path)
+ for _, fn := range functionsMissingDocStrings {
+ fmt.Printf("\t%s\n", fn)
+ }
+ errorStatusCode = true
+ }
}
return nil
})
@@ -46,9 +55,16 @@ func main() {
}
fmt.Printf("Documentation generated successfully in %s\n", outputFile)
+
+ if errorStatusCode {
+ os.Exit(1)
+ }
}
-func extractDocstrings(filePath string, out *os.File) {
+// extractDocstrings extracts the docstrings from the Go source file and writes them to the output file
+// in a markdown table format.
+// It returns a list of test functions that are missing docstrings.
+func extractDocstrings(filePath string, out *os.File) []string {
// Read the Go source file
src, err := ioutil.ReadFile(filePath)
if err != nil {
@@ -62,6 +78,8 @@ func extractDocstrings(filePath string, out *os.File) {
log.Fatalf("Error parsing file %s: %v\n", filePath, err)
}
+ functionsMissingDocstrings := []string{}
+
// Traverse the AST
for _, f := range node.Decls {
if fn, isFn := f.(*ast.FuncDecl); isFn && strings.HasPrefix(fn.Name.Name, "Test") {
@@ -92,7 +110,11 @@ func extractDocstrings(filePath string, out *os.File) {
description = strings.ReplaceAll(description, "\n", " ")
fmt.Fprintf(out, "| %s | %s | %s |\n", link, fn.Name.Name, description)
+ } else {
+ functionsMissingDocstrings = append(functionsMissingDocstrings, fn.Name.Name)
}
}
}
+
+ return functionsMissingDocstrings
}
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 235cb4b10c..d26173ccf3 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -15,12 +15,9 @@
| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
| [expired_client.go](../../tests/integration/expired_client.go#L87) | TestConsumerPacketSendExpiredClient | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired. While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded. |
-| [instance_test.go](../../tests/integration/instance_test.go#L22) | TestCCVTestSuite | Executes the standard group of ccv tests against a consumer and provider app.go implementation. |
-| [instance_test.go](../../tests/integration/instance_test.go#L35) | TestConsumerDemocracyCCVTestSuite | Executes a standard suite of tests, against a democracy consumer app.go implementation. |
-| [instance_test.go](../../tests/integration/instance_test.go#L51) | TestConsumerDemocracyTestSuite | Executes a specialized group of tests specific to a democracy consumer, against a democracy consumer app.go implementation. |
| [misbehaviour.go](../../tests/integration/misbehaviour.go#L19) | TestHandleConsumerMisbehaviour | TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators |
| [normal_operations.go](../../tests/integration/normal_operations.go#L13) | TestHistoricalInfo | Tests the tracking of historical info in the context of new blocks being committed |
-| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L19) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooksDetails
hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
+| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L18) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
| [slashing.go](../../tests/integration/slashing.go#L39) | TestRelayAndApplyDowntimePacket | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider. Note: This method does not test the actual slash packet sending logic for downtime and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for those types of tests. |
| [slashing.go](../../tests/integration/slashing.go#L177) | TestRelayAndApplyDoubleSignPacket | Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet. Note that double-sign slash packets should not affect the provider validator set. |
| [slashing.go](../../tests/integration/slashing.go#L302) | TestHandleSlashPacketDowntime | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket. |
From a546d83f40d321596f311ebce81a21a2a52ce3c6 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 09:47:01 +0200
Subject: [PATCH 03/88] Use better separator
---
scripts/test_doc/extract_docstrings.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index d89638f3cf..e48594e01f 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -90,7 +90,7 @@ func extractDocstrings(filePath string, out *os.File) []string {
link := fmt.Sprintf("[%s](%s#L%d)", relativePath, filePath, fset.Position(fn.Pos()).Line)
// Split the docstring based on the separator "========"
- parts := strings.Split(doc, "\n========\n")
+ parts := strings.Split(doc, "\n@Long description@\n")
var shortDescription, longDescription string
if len(parts) > 1 {
shortDescription = strings.TrimSpace(parts[0])
From ae2f994a2dc746202c8d5fcd6b650915e3f0ec6d Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 09:53:12 +0200
Subject: [PATCH 04/88] Add docstring to test
---
scripts/test_doc/extract_docstrings.go | 2 +-
scripts/test_doc/test_documentation.md | 1 +
tests/integration/changeover.go | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index e48594e01f..c3c0c9db33 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -90,7 +90,7 @@ func extractDocstrings(filePath string, out *os.File) []string {
link := fmt.Sprintf("[%s](%s#L%d)", relativePath, filePath, fset.Position(fn.Pos()).Line)
// Split the docstring based on the separator "========"
- parts := strings.Split(doc, "\n@Long description@\n")
+ parts := strings.Split(doc, "\n@Long Description@\n")
var shortDescription, longDescription string
if len(parts) > 1 {
shortDescription = strings.TrimSpace(parts[0])
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index d26173ccf3..d5030522bd 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -2,6 +2,7 @@
| File | Function | Short Description |
|------|----------|-------------------|
+| [changeover.go](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case: * sets up a provider chain and a standalone chain * creates a connection between the two chains * creates a transfer channel between the two chains * transitions the standalone chain to a consumer chain * confirms that no extra transfer channel is created, and instead the existing channel is reused |
| [channel_init.go](../../tests/integration/channel_init.go#L4) | TestInitTimeout | TestInitTimeout tests the init timeout |
| [distribution.go](../../tests/integration/distribution.go#L24) | TestRewardsDistribution | This test is valid for minimal viable consumer chain |
| [distribution.go](../../tests/integration/distribution.go#L187) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index 3c258dfc24..b8bd1801db 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -5,6 +5,15 @@ import (
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
+// TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from
+// a standalone to a consumer chain.
+// @Long Description@
+// The test case:
+// * sets up a provider chain and a standalone chain
+// * creates a connection between the two chains
+// * creates a transfer channel between the two chains
+// * transitions the standalone chain to a consumer chain
+// * confirms that no extra transfer channel is created, and instead the existing channel is reused
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From 0a0d95fc5644fcd136a4cf414642a765d2b2284f Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 14:22:35 +0200
Subject: [PATCH 05/88] Add some docstrings and adjust formatting
---
scripts/test_doc/extract_docstrings.go | 10 ++-
scripts/test_doc/test_documentation.md | 37 ++++++-----
tests/integration/changeover.go | 2 +-
tests/integration/democracy.go | 24 ++++++-
tests/integration/distribution.go | 14 ++++-
tests/integration/key_assignment.go | 83 ++++++++++++++++++++++++-
tests/integration/misbehaviour.go | 32 ++++++++--
tests/integration/provider_gov_hooks.go | 11 +++-
tests/integration/slashing.go | 5 ++
tests/integration/throttle.go | 6 ++
testutil/keeper/unit_test_helpers.go | 2 +-
11 files changed, 197 insertions(+), 29 deletions(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index c3c0c9db33..98287277de 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -101,13 +101,17 @@ func extractDocstrings(filePath string, out *os.File) []string {
}
// Format the description
+
+ // avoid breaking the table format: newlines need to be replaced
+ // for the short description, use spaces
+ shortDescription = strings.ReplaceAll(shortDescription, "\n", " ")
+ // for the long description, use breaks
+ longDescription = strings.ReplaceAll(longDescription, "\n", "
")
+
description := shortDescription
if longDescription != "" {
description += fmt.Sprintf("Details
%s ", longDescription)
}
- // for formatting the description in markdown table,
- // replace newlines with spaces
- description = strings.ReplaceAll(description, "\n", " ")
fmt.Fprintf(out, "| %s | %s | %s |\n", link, fn.Name.Name, description)
} else {
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index d5030522bd..34856ad01e 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -2,31 +2,40 @@
| File | Function | Short Description |
|------|----------|-------------------|
-| [changeover.go](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case: * sets up a provider chain and a standalone chain * creates a connection between the two chains * creates a transfer channel between the two chains * transitions the standalone chain to a consumer chain * confirms that no extra transfer channel is created, and instead the existing channel is reused |
+| [changeover.go](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
| [channel_init.go](../../tests/integration/channel_init.go#L4) | TestInitTimeout | TestInitTimeout tests the init timeout |
+| [democracy.go](../../tests/integration/democracy.go#L79) | TestDemocracyRewardsDistribution | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
+| [democracy.go](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
+| [democracy.go](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
| [distribution.go](../../tests/integration/distribution.go#L24) | TestRewardsDistribution | This test is valid for minimal viable consumer chain |
-| [distribution.go](../../tests/integration/distribution.go#L187) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
-| [distribution.go](../../tests/integration/distribution.go#L263) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L383) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L525) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
-| [distribution.go](../../tests/integration/distribution.go#L707) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
-| [distribution.go](../../tests/integration/distribution.go#L971) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
-| [distribution.go](../../tests/integration/distribution.go#L1079) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
+| [distribution.go](../../tests/integration/distribution.go#L186) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
+| [distribution.go](../../tests/integration/distribution.go#L262) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L382) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L524) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
+| [distribution.go](../../tests/integration/distribution.go#L706) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
+| [distribution.go](../../tests/integration/distribution.go#L846) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
+| [distribution.go](../../tests/integration/distribution.go#L981) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
+| [distribution.go](../../tests/integration/distribution.go#L1089) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
| [double_vote.go](../../tests/integration/double_vote.go#L17) | TestHandleConsumerDoubleVoting | TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator |
| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
| [expired_client.go](../../tests/integration/expired_client.go#L87) | TestConsumerPacketSendExpiredClient | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired. While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded. |
+| [key_assignment.go](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queud
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
| [misbehaviour.go](../../tests/integration/misbehaviour.go#L19) | TestHandleConsumerMisbehaviour | TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators |
+| [misbehaviour.go](../../tests/integration/misbehaviour.go#L97) | TestGetByzantineValidators | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a header with a subset of the validators on the consumer chain,
then creates a second header (in a variety of different ways),
and checks which validators are considered Byzantine
by calling the GetByzantineValidators function.
The test scenarios are:
* when one of the headers is empty, the function should return an error
* when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
* when the signatures in one of the headers are corrupted, the function should return an error
* when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
* for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
+| [misbehaviour.go](../../tests/integration/misbehaviour.go#L394) | TestCheckMisbehaviour | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or or freezing the client. |
| [normal_operations.go](../../tests/integration/normal_operations.go#L13) | TestHistoricalInfo | Tests the tracking of historical info in the context of new blocks being committed |
| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L18) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
+| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L60) | TestGetConsumerAdditionLegacyPropFromProp | TestGetConsumerAdditionLegacyPropFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on various types of proposals to test the behavior of the hook.Details
The tes case created a provider chain,
then submits a Proposal with various different types of content.
Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook. |
| [slashing.go](../../tests/integration/slashing.go#L39) | TestRelayAndApplyDowntimePacket | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider. Note: This method does not test the actual slash packet sending logic for downtime and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for those types of tests. |
| [slashing.go](../../tests/integration/slashing.go#L177) | TestRelayAndApplyDoubleSignPacket | Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet. Note that double-sign slash packets should not affect the provider validator set. |
-| [slashing.go](../../tests/integration/slashing.go#L302) | TestHandleSlashPacketDowntime | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket. |
-| [slashing.go](../../tests/integration/slashing.go#L343) | TestOnRecvSlashPacketErrors | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting |
-| [slashing.go](../../tests/integration/slashing.go#L442) | TestValidatorDowntime | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module |
-| [slashing.go](../../tests/integration/slashing.go#L555) | TestValidatorDoubleSigning | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module |
-| [slashing.go](../../tests/integration/slashing.go#L642) | TestQueueAndSendSlashPacket | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock. |
-| [slashing.go](../../tests/integration/slashing.go#L722) | TestCISBeforeCCVEstablished | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after. |
+| [slashing.go](../../tests/integration/slashing.go#L263) | TestSlashPacketAcknowledgement | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
+| [slashing.go](../../tests/integration/slashing.go#L307) | TestHandleSlashPacketDowntime | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket. |
+| [slashing.go](../../tests/integration/slashing.go#L348) | TestOnRecvSlashPacketErrors | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting |
+| [slashing.go](../../tests/integration/slashing.go#L447) | TestValidatorDowntime | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module |
+| [slashing.go](../../tests/integration/slashing.go#L560) | TestValidatorDoubleSigning | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module |
+| [slashing.go](../../tests/integration/slashing.go#L647) | TestQueueAndSendSlashPacket | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock. |
+| [slashing.go](../../tests/integration/slashing.go#L727) | TestCISBeforeCCVEstablished | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after. |
| [stop_consumer.go](../../tests/integration/stop_consumer.go#L14) | TestStopConsumerChain | Tests the functionality of stopping a consumer chain at a higher level than unit tests |
| [stop_consumer.go](../../tests/integration/stop_consumer.go#L99) | TestStopConsumerOnChannelClosed | TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
| [throttle.go](../../tests/integration/throttle.go#L24) | TestBasicSlashPacketThrottling | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario. |
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b8bd1801db..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -13,7 +13,7 @@ import (
// * creates a connection between the two chains
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
-// * confirms that no extra transfer channel is created, and instead the existing channel is reused
+// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
diff --git a/tests/integration/democracy.go b/tests/integration/democracy.go
index 5fe7e9eb6d..baea36857b 100644
--- a/tests/integration/democracy.go
+++ b/tests/integration/democracy.go
@@ -71,6 +71,11 @@ func (suite *ConsumerDemocracyTestSuite) SetupTest() {
suite.consumerApp = suite.setupCallback(&suite.Suite)
}
+// TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.
+// @Long Description@
+// * Sets up a democracy consumer chain
+// * Creates a new block
+// * Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions
func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() {
s.consumerChain.NextBlock()
stakingKeeper := s.consumerApp.GetTestStakingKeeper()
@@ -154,7 +159,7 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() {
totalFees := nextConsumerRedistributeBalance.Add(providerDifference)
s.Require().Equal(totalFees.Mul(consumerRedistributionFraction), nextConsumerRedistributeBalance)
- // confirm begin blocker changes: democracy module distributes the fees from c onsumer redistribute address to representatives
+ // confirm begin blocker changes: democracy module distributes the fees from consumer redistribute address to representatives
// and community fee pool
// distribution module got tokens from previous consumer redistribute balance
s.Require().Equal(distrModuleDifference, previousConsumerRedistributeBalance)
@@ -176,6 +181,17 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() {
}
}
+// TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals
+// can be executed on democracy consumer chains.
+// @Long Description@
+// For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
+// * Sets up a democracy consumer chain
+// * Submits a proposal containing changes to the auth and mint module parameters
+// * Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
+// * Submits a proposal containing changes *only* to the mint module parameters
+// * Checks that the proposal is executed, since the change to the mint module is whitelisted.
+// * Submits a proposal containing changes *only* to the auth module parameters
+// * Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted.
func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() {
govKeeper := s.consumerApp.GetTestGovKeeper()
params, err := govKeeper.Params.Get(s.consumerCtx())
@@ -271,6 +287,11 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() {
s.Assert().Equal(votersOldBalances, getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts))
}
+// TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.
+// @Long Description@
+// * Sets up a democracy consumer chain
+// * Submits a proposal containing changes to the consumer module parameters
+// * Checks that the proposal is executed, and the parameters are updated
func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams() {
govKeeper := s.consumerApp.GetTestGovKeeper()
params, err := govKeeper.Params.Get(s.consumerCtx())
@@ -316,7 +337,6 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams() {
// deposit is refunded
s.Assert().Equal(votersOldBalances, getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts))
-
}
func submitProposalWithDepositAndVote(govKeeper govkeeper.Keeper, ctx sdk.Context, msgs []sdk.Msg,
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 2e5f2f0bbb..157a8cb205 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -138,8 +138,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() {
consuValsRewards := consumerValsOutstandingRewardsFunc(s.providerCtx())
// increase the block height so validators are eligible for consumer rewards (see `IsEligibleForConsumerRewards`)
- numberOfBlocksToStartReceivingRewards :=
- providerKeeper.GetNumberOfEpochsToStartReceivingRewards(s.providerCtx()) * providerKeeper.GetBlocksPerEpoch(s.providerCtx())
+ numberOfBlocksToStartReceivingRewards := providerKeeper.GetNumberOfEpochsToStartReceivingRewards(s.providerCtx()) * providerKeeper.GetBlocksPerEpoch(s.providerCtx())
for s.providerCtx().BlockHeight() <= numberOfBlocksToStartReceivingRewards {
s.providerChain.NextBlock()
@@ -833,6 +832,17 @@ func (s *CCVTestSuite) prepareRewardDist() {
s.coordinator.CommitNBlocks(s.consumerChain, uint64(blocksToGo))
}
+// TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.
+// @Long Description@
+// The test exclusively uses the provider chain.
+// It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
+// function to allocate a number of tokens to the validators.
+// The test then checks that the expected number of tokens were allocated to the validators.
+// The test covers the following scenarios:
+// - The tokens to be allocated are empty
+// - The consumer validator set is empty
+// - The tokens are allocated to a single validator
+// - The tokens are allocated to multiple validators
func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() {
providerKeeper := s.providerApp.GetProviderKeeper()
distributionKeeper := s.providerApp.GetTestDistributionKeeper()
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index c6478d98ba..9b31c9f9a5 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -10,9 +10,26 @@ import (
tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
+ "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
+// TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.
+// @Long Description@
+// Each test scenarios sets up a provider chain and then assigns a key for a validator.
+// However, the assignment comes at different times in the protocol lifecycle.
+// The test covers the following scenarios:
+// * successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queud
+// * successfully assign the key after the CCV channel initialization is complete
+// * successfully assign the key during an same epoch where the validator power changes
+// * get an error when assigning the same key twice in the same block by different validators
+// * get an error when assigning the same key twice in the same block by the same validator
+// * successfully assign two different keys in the same block by one validator
+// * get an error when assigning the same key twice in different blocks by different validators
+// * get an error when assigning the same key twice in different blocks by the same validator
+// For each scenario where the key assignment does not produce an error,
+// the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
+// the provider and consumer chain can be updated.
func (s *CCVTestSuite) TestKeyAssignment() {
testCases := []struct {
name string
@@ -29,6 +46,9 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
// check that a VSCPacket is queued
s.nextEpoch()
pendingPackets := pk.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID)
@@ -51,6 +71,10 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
return nil
@@ -73,6 +97,9 @@ func (s *CCVTestSuite) TestKeyAssignment() {
delAddr := s.providerChain.SenderAccount.GetAddress()
delegate(s, delAddr, bondAmt)
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
return nil
@@ -90,12 +117,25 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
// same key assignment, but different validator
validator2, _ := generateNewConsumerKey(s, 1)
err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator2, consumerKey)
+
+ // check that the key was not assigned to the second validator
+ valConsAddr2, getConsAddrErr := validator2.GetConsAddr() // make sure we don't override err, which we are saving for below
+ s.Require().NoError(getConsAddrErr)
+ actualConsumerKey2, found := pk.GetValidatorConsumerPubKey(s.providerCtx(), s.consumerChain.ChainID, types.NewProviderConsAddress(valConsAddr2))
+ s.Require().True(found)
+ // the key for the second validator should *not* be the one we just assigned to the first validator
+ s.Require().NotEqual(consumerKey, actualConsumerKey2)
+
if err != nil {
return err
}
+
s.nextEpoch()
return nil
@@ -113,7 +153,10 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // same key assignment, but different validator
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
+ // same key assignment, same validator
err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey)
if err != nil {
return err
@@ -135,12 +178,19 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
// same key assignment
validator, consumerKey = generateNewConsumerKey(s, 0)
err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey)
if err != nil {
return err
}
+
+ // check that the second key was also assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
return nil
@@ -157,6 +207,10 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
// same key assignment
@@ -165,6 +219,15 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
+ // check that the key was not assigned to the second validator
+ valConsAddr2, getConsAddrErr := validator2.GetConsAddr() // make sure we don't override err, which we are saving for below
+ s.Require().NoError(getConsAddrErr)
+ actualConsumerKey2, found := pk.GetValidatorConsumerPubKey(s.providerCtx(), s.consumerChain.ChainID, types.NewProviderConsAddress(valConsAddr2))
+ s.Require().True(found)
+ // the key for the second validator should *not* be the one we just assigned to the first validator
+ s.Require().NotEqual(consumerKey, actualConsumerKey2)
+
s.nextEpoch()
return nil
@@ -181,6 +244,10 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
// same key assignment
@@ -204,6 +271,10 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
+ // check that the key was assigned correctly
+ s.CheckKeyAssignment(validator, consumerKey)
+
s.nextEpoch()
// same key assignment
@@ -212,6 +283,7 @@ func (s *CCVTestSuite) TestKeyAssignment() {
if err != nil {
return err
}
+
s.nextEpoch()
return nil
@@ -286,6 +358,15 @@ func (s *CCVTestSuite) TestKeyAssignment() {
}
}
+// CheckKeyAssignmentCorrectly checks if the key was assigned correctly.
+func (s *CCVTestSuite) CheckKeyAssignment(validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey) {
+ valConsAddr, err := validator.GetConsAddr()
+ s.Require().NoError(err)
+ actualConsumerKey, found := s.providerApp.GetProviderKeeper().GetValidatorConsumerPubKey(s.providerCtx(), s.consumerChain.ChainID, types.NewProviderConsAddress(valConsAddr))
+ s.Require().True(found)
+ s.Require().Equal(consumerKey, actualConsumerKey)
+}
+
// generateNewConsumerKey generate new consumer key for the validator with valIndex
func generateNewConsumerKey(s *CCVTestSuite, valIndex int) (stakingtypes.Validator, tmprotocrypto.PublicKey) {
// get validator
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 5924c90df1..9677a52bc8 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -81,6 +81,19 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() {
}
}
+// TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.
+// @Long Description@
+// The test sets up a provider and consumer chain.
+// It creates a header with a subset of the validators on the consumer chain,
+// then creates a second header (in a variety of different ways),
+// and checks which validators are considered Byzantine
+// by calling the GetByzantineValidators function.
+// The test scenarios are:
+// * when one of the headers is empty, the function should return an error
+// * when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
+// * when the signatures in one of the headers are corrupted, the function should return an error
+// * when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
+// * for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine
func (s *CCVTestSuite) TestGetByzantineValidators() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -363,6 +376,21 @@ func (s *CCVTestSuite) TestGetByzantineValidators() {
}
}
+// TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.
+// @Long Description@
+// The test sets up a provider and consumer chain.
+// It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
+// It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
+// it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
+// The test scenarios are:
+// * both headers are identical (returns an error)
+// * the misbehaviour is not for the consumer chain (returns an error)
+// * passing an invalid client id (returns an error)
+// * passing a misbehaviour with different header height (returns an error)
+// * passing a misbehaviour older than the min equivocation evidence height (returns an error)
+// * one header of the misbehaviour has insufficient voting power (returns an error)
+// * passing a valid misbehaviour (no error)
+// It does not test actually submitting the misbehaviour to the chain or or freezing the client.
func (s *CCVTestSuite) TestCheckMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -548,10 +576,6 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() {
for _, tc := range testCases {
s.Run(tc.name, func() {
err := s.providerApp.GetProviderKeeper().CheckMisbehaviour(s.providerCtx(), *tc.misbehaviour)
- cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), s.path.EndpointA.ClientID)
- s.Require().True(ok)
- // verify that the client wasn't frozen
- s.Require().Zero(cs.(*ibctmtypes.ClientState).FrozenHeight)
if tc.expPass {
s.NoError(err)
} else {
diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go
index e3f9cc8ace..8f5ba95de7 100644
--- a/tests/integration/provider_gov_hooks.go
+++ b/tests/integration/provider_gov_hooks.go
@@ -48,6 +48,15 @@ func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() {
s.Require().Empty(providerKeeper.GetProposedConsumerChain(ctx, proposal.Id))
}
+// TestGetConsumerAdditionLegacyPropFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on
+// various types of proposals to test the behavior of the hook.
+// @Long Description@
+// The tes case created a provider chain,
+// then submits a Proposal with various different types of content.
+// Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
+// Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
+// a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
+// In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook.
func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() {
ctx := s.providerChain.GetContext()
proposer := s.providerChain.SenderAccount
@@ -121,7 +130,7 @@ func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() {
proposal, err = v1.NewProposal([]sdk.Msg{}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false)
s.Require().NoError(err)
} else {
- // cover variolus cases where proposal has messages but only some are consumer addition proposals
+ // cover various cases where proposal has messages but only some are consumer addition proposals
proposal, err = v1.NewProposal([]sdk.Msg{tc.propMsg}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false)
s.Require().NoError(err)
}
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 2e01c99fe7..254a8467a4 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -255,6 +255,11 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() {
s.Require().NoError(err)
}
+// TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.
+// @Long Description@
+// It sets up a provider and consumer chain, with channel initialization between them performed,
+// then sends a slash packet with randomized fields from the consumer to the provider.
+// The provider processes the packet
func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
providerKeeper := s.providerApp.GetProviderKeeper()
consumerKeeper := s.consumerApp.GetConsumerKeeper()
diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go
index f56228c56f..d9bfa1ed28 100644
--- a/tests/integration/throttle.go
+++ b/tests/integration/throttle.go
@@ -382,6 +382,12 @@ func (s *CCVTestSuite) TestPacketSpam() {
}
}
+// TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets
+// do not affect the throttling mechanism.
+// @Long Description@
+// This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
+// It then sends 500 double sign slash packets from a consumer to the provider in a single block.
+// The test confirms that the slash meter is not affected by this, and that no validators are jailed.
func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
// Setup ccv channels to all consumers
s.SetupAllCCVChannels()
diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go
index 0fd86f3c1c..d139552371 100644
--- a/testutil/keeper/unit_test_helpers.go
+++ b/testutil/keeper/unit_test_helpers.go
@@ -207,7 +207,7 @@ func GetNewSlashPacketData() types.SlashPacketData {
Power: int64(binary.BigEndian.Uint64(b1)),
},
ValsetUpdateId: binary.BigEndian.Uint64(b2),
- Infraction: stakingtypes.Infraction(binary.BigEndian.Uint64(b2) % 3),
+ Infraction: stakingtypes.Infraction(binary.BigEndian.Uint64(b3) % 3),
}
}
From ca5351a5785579c3c2f66a67f900264828052e6f Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:01:05 +0200
Subject: [PATCH 06/88] Add some more docstrings
---
scripts/test_doc/test_documentation.md | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 34856ad01e..f657111dc5 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -3,7 +3,7 @@
| File | Function | Short Description |
|------|----------|-------------------|
| [changeover.go](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
-| [channel_init.go](../../tests/integration/channel_init.go#L4) | TestInitTimeout | TestInitTimeout tests the init timeout |
+| [channel_init.go](../../tests/integration/channel_init.go#L10) | TestInitTimeout | TestInitTimeout tests that the init timeout is respected.Details
The test sets up a provider with a configured init timeout period.
It then creates a connection between the provider and consumer chains,
and then performs a handshake (stopping at various stages of the process to simulate a timeout).
It then increments the time by the init timeout period and checks that the chain was removed if the timeout was reached,
or that the chain was not removed if the handshake was indeed completed before the timeout. |
| [democracy.go](../../tests/integration/democracy.go#L79) | TestDemocracyRewardsDistribution | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
| [democracy.go](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
| [democracy.go](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
@@ -41,9 +41,10 @@
| [throttle.go](../../tests/integration/throttle.go#L24) | TestBasicSlashPacketThrottling | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario. |
| [throttle.go](../../tests/integration/throttle.go#L197) | TestMultiConsumerSlashPacketThrottling | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around. |
| [throttle.go](../../tests/integration/throttle.go#L319) | TestPacketSpam | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block. |
-| [throttle.go](../../tests/integration/throttle.go#L466) | TestSlashingSmallValidators | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner. |
-| [throttle.go](../../tests/integration/throttle.go#L541) | TestSlashMeterAllowanceChanges | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change. TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
-| [throttle.go](../../tests/integration/throttle.go#L567) | TestSlashAllValidators | Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, and in the first packets recv for that block. This edge case should not occur in practice, but is useful to validate that the slash meter can allow any number of slash packets to be handled in a single block when its allowance is set to "1.0". |
+| [throttle.go](../../tests/integration/throttle.go#L391) | TestDoubleSignDoesNotAffectThrottling | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
+| [throttle.go](../../tests/integration/throttle.go#L472) | TestSlashingSmallValidators | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner. |
+| [throttle.go](../../tests/integration/throttle.go#L547) | TestSlashMeterAllowanceChanges | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change. TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
+| [throttle.go](../../tests/integration/throttle.go#L573) | TestSlashAllValidators | Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, and in the first packets recv for that block. This edge case should not occur in practice, but is useful to validate that the slash meter can allow any number of slash packets to be handled in a single block when its allowance is set to "1.0". |
| [throttle_retry.go](../../tests/integration/throttle_retry.go#L14) | TestSlashRetries | TestSlashRetries tests the throttling v2 retry logic at an integration level. |
| [unbonding.go](../../tests/integration/unbonding.go#L16) | TestUndelegationNormalOperation | TestUndelegationNormalOperation tests that undelegations complete after the unbonding period elapses on both the consumer and provider, without VSC packets timing out. |
| [unbonding.go](../../tests/integration/unbonding.go#L131) | TestUndelegationVscTimeout | TestUndelegationVscTimeout tests that an undelegation completes after vscTimeoutPeriod even if it does not reach maturity on the consumer chain. In this case, the consumer chain is removed. |
From 1e51a5d972f3a9b7129b3f846105d643884b6ac9 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:28:36 +0200
Subject: [PATCH 07/88] Add makefile and git workflow
---
.github/workflows/testing-docs.yml | 64 ++++++++++++++++++++++++++
Makefile | 3 ++
TESTING.md | 11 +++++
scripts/test_doc/test_documentation.md | 18 ++++----
tests/integration/channel_init.go | 8 +++-
tests/integration/distribution.go | 10 +++-
6 files changed, 103 insertions(+), 11 deletions(-)
create mode 100644 .github/workflows/testing-docs.yml
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
new file mode 100644
index 0000000000..edf7ed52cb
--- /dev/null
+++ b/.github/workflows/testing-docs.yml
@@ -0,0 +1,64 @@
+name: Generate testing docs
+
+on:
+ workflow_call:
+ pull_request:
+ merge_group:
+ push:
+ branches:
+ - main
+ - release/v*
+ - feat/*
+
+permissions:
+ contents: read
+
+jobs:
+ testing-docs:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version: "1.22"
+ check-latest: true
+ cache: true
+ cache-dependency-path: go.sum
+ - uses: technote-space/get-diff-action@v6.1.2
+ id: git_diff
+ with:
+ PATTERNS: |
+ tests/integration/**/*.go
+ **/Makefile
+ Makefile
+
+ - name: Generate testing docs
+ run: make testing-docs
+
+ - name: Check for changes
+ id: check_changes
+ run: |
+ if ! diff -q scripts/test_doc/test_documentation.md <(git show HEAD:scripts/test_doc/test_documentation.md); then
+ echo "Documentation is out of date!"
+ echo "::set-output name=needs_commit::true"
+
+ - name: Configure Git
+ if: steps.check_changes.outputs.needs_commit == 'true'
+ run: |
+ git config --global user.name 'github-actions[bot]'
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
+
+ - name: Commit changes
+ if: steps.check_changes.outputs.needs_commit == 'true'
+ run: |
+ git add scripts/test_doc/test_documentation.md
+ git commit -m "Update documentation"
+
+ - name: Push changes
+ if: steps.check_changes.outputs.needs_commit == 'true'
+ uses: ad-m/github-push-action@v0.6.0
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index e68df6fd63..d4df5ff678 100644
--- a/Makefile
+++ b/Makefile
@@ -253,6 +253,9 @@ build-docs-deploy:
build-docs-local:
@cd docs && ./build_local.sh
+testing-docs:
+ @cd scripts/test_doc && go run extract_docstrings.go
+
###############################################################################
### Test Traces ###
###############################################################################
diff --git a/TESTING.md b/TESTING.md
index ef419ade00..122c49fbbd 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -14,6 +14,17 @@ Unit tests are useful for simple standalone functionality, and CRUD operations.
To run integration tests against your own consumer/provider implementations, use [instance_test.go](tests/integration/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](testutil/integration/interfaces.go), pattern match [specific_setup.go](testutil/ibc_testing/specific_setup.go), then pass in the appropriate types and parameters to the suite, as is done in `instance_test.go` for the dummy provider/consumer implementations.
+A list of test scenarios covered by integration tests can be found in [scripts/test_doc/test_documentation.md](scripts/test_doc/test_documentation.md).
+When adding an integration test, write a brief description as a docstring in the Golang code in this schema:
+```go
+// This is a test that tests foo and bar.
+// @Long Description@
+// Here is a detailed description
+// that goes into more detail and describes the scenario.
+```
+
+Then, run `make docs-test` to update the test documentation.
+
## Model-Based Tests (MBT)
[MBT](tests/mbt/) tests are similar to integration tests, but they compare the system state to an expected state generated from a formally verified specification written in Quint.
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index f657111dc5..795684db03 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -7,15 +7,15 @@
| [democracy.go](../../tests/integration/democracy.go#L79) | TestDemocracyRewardsDistribution | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
| [democracy.go](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
| [democracy.go](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
-| [distribution.go](../../tests/integration/distribution.go#L24) | TestRewardsDistribution | This test is valid for minimal viable consumer chain |
-| [distribution.go](../../tests/integration/distribution.go#L186) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
-| [distribution.go](../../tests/integration/distribution.go#L262) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L382) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L524) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
-| [distribution.go](../../tests/integration/distribution.go#L706) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
-| [distribution.go](../../tests/integration/distribution.go#L846) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
-| [distribution.go](../../tests/integration/distribution.go#L981) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
-| [distribution.go](../../tests/integration/distribution.go#L1089) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
+| [distribution.go](../../tests/integration/distribution.go#L32) | TestRewardsDistribution | TesRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
+| [distribution.go](../../tests/integration/distribution.go#L194) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
+| [distribution.go](../../tests/integration/distribution.go#L270) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L390) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L532) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
+| [distribution.go](../../tests/integration/distribution.go#L714) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
+| [distribution.go](../../tests/integration/distribution.go#L854) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
+| [distribution.go](../../tests/integration/distribution.go#L989) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
+| [distribution.go](../../tests/integration/distribution.go#L1097) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
| [double_vote.go](../../tests/integration/double_vote.go#L17) | TestHandleConsumerDoubleVoting | TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator |
| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
diff --git a/tests/integration/channel_init.go b/tests/integration/channel_init.go
index e9a41c66f5..bfc51dffb7 100644
--- a/tests/integration/channel_init.go
+++ b/tests/integration/channel_init.go
@@ -1,6 +1,12 @@
package integration
-// TestInitTimeout tests the init timeout
+// TestInitTimeout tests that the init timeout is respected.
+// @Long Description@
+// The test sets up a provider with a configured init timeout period.
+// It then creates a connection between the provider and consumer chains,
+// and then performs a handshake (stopping at various stages of the process to simulate a timeout).
+// It then increments the time by the init timeout period and checks that the chain was removed if the timeout was reached,
+// or that the chain was not removed if the handshake was indeed completed before the timeout.
func (suite *CCVTestSuite) TestInitTimeout() {
testCases := []struct {
name string
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 157a8cb205..bb460ab89c 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -20,7 +20,15 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// This test is valid for minimal viable consumer chain
+// TesRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.
+// @Long Description@
+// The test sets up a provider and consumer chain and completes the channel initialization.
+// Then, it sends tokens into the FeeCollector on the consumer chain,
+// and checks that these tokens distributed correctly across the provider and consumer chain.
+// It first checks that the tokens are distributed purely on the consumer chain,
+// then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
+// It does not whitelist the consumer denom, so the tokens are expected to stay in
+// the ConsumerRewardsPool on the provider chain.
func (s *CCVTestSuite) TestRewardsDistribution() {
// set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain
s.SetupCCVChannel(s.path)
From d13e029a198e2c40e9b85b12892a32c3473a77b7 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:29:50 +0200
Subject: [PATCH 08/88] Add else case
---
.github/workflows/testing-docs.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index edf7ed52cb..25dc0b633a 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -44,6 +44,8 @@ jobs:
if ! diff -q scripts/test_doc/test_documentation.md <(git show HEAD:scripts/test_doc/test_documentation.md); then
echo "Documentation is out of date!"
echo "::set-output name=needs_commit::true"
+ else
+ echo "::set-output name=needs_commit::false"
- name: Configure Git
if: steps.check_changes.outputs.needs_commit == 'true'
From 42cb5023251bcaed16fe2911e3c7b25955f9e756 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:32:09 +0200
Subject: [PATCH 09/88] Use temporary files instead of substitution
---
.github/workflows/testing-docs.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 25dc0b633a..8a4ee365d1 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -41,7 +41,9 @@ jobs:
- name: Check for changes
id: check_changes
run: |
- if ! diff -q scripts/test_doc/test_documentation.md <(git show HEAD:scripts/test_doc/test_documentation.md); then
+ git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
+ cp scripts/test_doc/test_documentation.md generated_file.md
+ if ! diff -q generated_file.md committed_file.md; then
echo "Documentation is out of date!"
echo "::set-output name=needs_commit::true"
else
From c6587bff838229489a956b0230e7bd4126fc0566 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:37:12 +0200
Subject: [PATCH 10/88] Add missing fi
---
.github/workflows/testing-docs.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 8a4ee365d1..9ae6508851 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -48,6 +48,7 @@ jobs:
echo "::set-output name=needs_commit::true"
else
echo "::set-output name=needs_commit::false"
+ fi
- name: Configure Git
if: steps.check_changes.outputs.needs_commit == 'true'
From 24012c1831383f07259e22cf82bffa99dc25a12a Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:41:10 +0200
Subject: [PATCH 11/88] Adding a docstring without regenerating the test docs
---
tests/integration/distribution.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index bb460ab89c..0aa872aecc 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -191,6 +191,13 @@ func (s *CCVTestSuite) TestRewardsDistribution() {
}
// TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks
+// @Long Description@
+// The test sets up a provider and consumer chain and completes the channel initialization.
+// It fills the fee pool on the consumer chain,
+// then corrupts the transmission channel and tries to send rewards to the provider chain,
+// which should fail.
+// The test then advances the block height to trigger a retry of the reward transmission,
+// and confirms that this time, the transmission is successful.
func (s *CCVTestSuite) TestSendRewardsRetries() {
// TODO: this setup can be consolidated with other tests in the file
From 1203d5c2caec7b91d75facb658fcaa0090730191 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:45:00 +0200
Subject: [PATCH 12/88] Give testing-docs workflow write permission
---
.github/workflows/testing-docs.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 9ae6508851..bc2e972816 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -11,7 +11,8 @@ on:
- feat/*
permissions:
- contents: read
+ contents: write
+ pull-requests: write # 'write' access to pull requests
jobs:
testing-docs:
From 87dbfa1d2c871b46fdcf02bbac3a6b7649b41a80 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:49:41 +0200
Subject: [PATCH 13/88] Specify branch to push to
---
.github/workflows/testing-docs.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index bc2e972816..241d2f10be 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -67,4 +67,5 @@ jobs:
if: steps.check_changes.outputs.needs_commit == 'true'
uses: ad-m/github-push-action@v0.6.0
with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ branch: ${{ github.ref }}
\ No newline at end of file
From 82f6dcbf2c3b046b0b9764b0eb49f04b2d675701 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:53:53 +0200
Subject: [PATCH 14/88] Just fail the test instead of pushing automatically
---
.github/workflows/testing-docs.yml | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 241d2f10be..b0a1e50a55 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -45,27 +45,8 @@ jobs:
git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
cp scripts/test_doc/test_documentation.md generated_file.md
if ! diff -q generated_file.md committed_file.md; then
- echo "Documentation is out of date!"
- echo "::set-output name=needs_commit::true"
+ echo "Documentation for integration tests is out of date. Please run `make testing-docs`!"
+ exit 1
else
- echo "::set-output name=needs_commit::false"
- fi
-
- - name: Configure Git
- if: steps.check_changes.outputs.needs_commit == 'true'
- run: |
- git config --global user.name 'github-actions[bot]'
- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
-
- - name: Commit changes
- if: steps.check_changes.outputs.needs_commit == 'true'
- run: |
- git add scripts/test_doc/test_documentation.md
- git commit -m "Update documentation"
-
- - name: Push changes
- if: steps.check_changes.outputs.needs_commit == 'true'
- uses: ad-m/github-push-action@v0.6.0
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- branch: ${{ github.ref }}
\ No newline at end of file
+ echo "Documentation is up to date."
+ fi
\ No newline at end of file
From e6e872ddfa59473e00d730b40020990acf6e9b33 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 15:56:24 +0200
Subject: [PATCH 15/88] Regenerate testing docs
---
scripts/test_doc/test_documentation.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 795684db03..8b6d0edccf 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -8,14 +8,14 @@
| [democracy.go](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
| [democracy.go](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
| [distribution.go](../../tests/integration/distribution.go#L32) | TestRewardsDistribution | TesRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
-| [distribution.go](../../tests/integration/distribution.go#L194) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks |
-| [distribution.go](../../tests/integration/distribution.go#L270) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L390) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L532) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
-| [distribution.go](../../tests/integration/distribution.go#L714) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
-| [distribution.go](../../tests/integration/distribution.go#L854) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
-| [distribution.go](../../tests/integration/distribution.go#L989) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
-| [distribution.go](../../tests/integration/distribution.go#L1097) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
+| [distribution.go](../../tests/integration/distribution.go#L201) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
+| [distribution.go](../../tests/integration/distribution.go#L277) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L397) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
+| [distribution.go](../../tests/integration/distribution.go#L539) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
+| [distribution.go](../../tests/integration/distribution.go#L721) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
+| [distribution.go](../../tests/integration/distribution.go#L861) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
+| [distribution.go](../../tests/integration/distribution.go#L996) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
+| [distribution.go](../../tests/integration/distribution.go#L1104) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
| [double_vote.go](../../tests/integration/double_vote.go#L17) | TestHandleConsumerDoubleVoting | TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator |
| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
From 72c62c5d58dedfacbccbdecc6baf12fc020a4126 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 16:01:43 +0200
Subject: [PATCH 16/88] Rename workflow
---
.github/workflows/testing-docs.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index b0a1e50a55..3b50c76d43 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -1,4 +1,4 @@
-name: Generate testing docs
+name: Check up-to-date testing docs
on:
workflow_call:
From 99ee1a24090e5bc7a2be6de4d006f7ea8793e93f Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 16:02:39 +0200
Subject: [PATCH 17/88] Unify type imports
---
x/ccv/provider/keeper/relay_test.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go
index b6487e8ec1..8f3730def5 100644
--- a/x/ccv/provider/keeper/relay_test.go
+++ b/x/ccv/provider/keeper/relay_test.go
@@ -23,7 +23,6 @@ import (
cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto"
testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
- "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
@@ -111,7 +110,7 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) {
// opt in validator A and set as a consumer validator
providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valAConsAddr))
- consumerValidatorA := types.ConsumerValidator{
+ consumerValidatorA := providertypes.ConsumerValidator{
ProviderConsAddr: valAConsAddr,
Power: 1,
ConsumerPublicKey: &valAPubKey,
From e2eed4eefd9907970929c061a462d80dbe4ebd5e Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 17:08:10 +0200
Subject: [PATCH 18/88] Add newline around fenced codeblock
---
TESTING.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/TESTING.md b/TESTING.md
index 122c49fbbd..1d15a56f3a 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -16,6 +16,7 @@ To run integration tests against your own consumer/provider implementations, use
A list of test scenarios covered by integration tests can be found in [scripts/test_doc/test_documentation.md](scripts/test_doc/test_documentation.md).
When adding an integration test, write a brief description as a docstring in the Golang code in this schema:
+
```go
// This is a test that tests foo and bar.
// @Long Description@
From dfa64ca7f0cc86a532068a4d195d8b9fa6cb09d5 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 17:12:33 +0200
Subject: [PATCH 19/88] Fix repeated 'or'
---
tests/integration/misbehaviour.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 9677a52bc8..8f760b1bd0 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -390,7 +390,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() {
// * passing a misbehaviour older than the min equivocation evidence height (returns an error)
// * one header of the misbehaviour has insufficient voting power (returns an error)
// * passing a valid misbehaviour (no error)
-// It does not test actually submitting the misbehaviour to the chain or or freezing the client.
+// It does not test actually submitting the misbehaviour to the chain or freezing the client.
func (s *CCVTestSuite) TestCheckMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
From 398aa442f8f9c645341aefeb3834c302417dfd4f Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 17:12:53 +0200
Subject: [PATCH 20/88] Regenerate testing doc
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 8b6d0edccf..beea538a38 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -23,7 +23,7 @@
| [key_assignment.go](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queud
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
| [misbehaviour.go](../../tests/integration/misbehaviour.go#L19) | TestHandleConsumerMisbehaviour | TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators |
| [misbehaviour.go](../../tests/integration/misbehaviour.go#L97) | TestGetByzantineValidators | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a header with a subset of the validators on the consumer chain,
then creates a second header (in a variety of different ways),
and checks which validators are considered Byzantine
by calling the GetByzantineValidators function.
The test scenarios are:
* when one of the headers is empty, the function should return an error
* when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
* when the signatures in one of the headers are corrupted, the function should return an error
* when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
* for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
-| [misbehaviour.go](../../tests/integration/misbehaviour.go#L394) | TestCheckMisbehaviour | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or or freezing the client. |
+| [misbehaviour.go](../../tests/integration/misbehaviour.go#L394) | TestCheckMisbehaviour | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or freezing the client. |
| [normal_operations.go](../../tests/integration/normal_operations.go#L13) | TestHistoricalInfo | Tests the tracking of historical info in the context of new blocks being committed |
| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L18) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L60) | TestGetConsumerAdditionLegacyPropFromProp | TestGetConsumerAdditionLegacyPropFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on various types of proposals to test the behavior of the hook.Details
The tes case created a provider chain,
then submits a Proposal with various different types of content.
Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook. |
From 0d54836808e2ea51369c50eb9a43698291e9d969 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 17:20:26 +0200
Subject: [PATCH 21/88] Expand docstring for TestAllocateTokens
---
tests/integration/distribution.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 0aa872aecc..8e4c2b9888 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -717,7 +717,12 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() {
}
// TestAllocateTokens is a happy-path test of the consumer rewards pool allocation
-// to opted-in validators and the community pool
+// to opted-in validators and the community pool.
+// @Long Description@
+// The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
+// It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
+// Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
+// and checks that the rewards are allocated as expected.
func (s *CCVTestSuite) TestAllocateTokens() {
// set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain
s.SetupAllCCVChannels()
From ff240424a001568af9cbd46430f14e46ae7530f9 Mon Sep 17 00:00:00 2001
From: Philip Offtermatt
Date: Tue, 23 Jul 2024 18:31:09 +0200
Subject: [PATCH 22/88] Adjust testing docs workflow
---
.github/workflows/testing-docs.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 3b50c76d43..1959d658bf 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -47,6 +47,4 @@ jobs:
if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Please run `make testing-docs`!"
exit 1
- else
- echo "Documentation is up to date."
fi
\ No newline at end of file
From c26b75cfb3ee30e8354e83076990166af2fd2550 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 23 Aug 2024 14:28:03 +0200
Subject: [PATCH 23/88] Improved some test descriptions
---
tests/integration/README.md | 2 ++
tests/integration/democracy.go | 2 ++
tests/integration/distribution.go | 45 ++++++++++++++++++++++-------
tests/integration/double_vote.go | 15 +++++++---
tests/integration/expired_client.go | 15 +++++++---
5 files changed, 60 insertions(+), 19 deletions(-)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index f826a9c2d7..b3e9b41b05 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -12,6 +12,8 @@ Integration tests are categorized into files as follows:
- `distribution.go` - integration tests for the _Reward Distribution_ sub-protocol
- `stop_consumer.go` - integration tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
+- `changeover.go` - integration tests for testing reuse of existing transfer channels
+- `double_vote.go` - integration tests for testing the handling of double voting
- `expired_client.go` - integration tests for testing expired clients
- `key_assignment.go` - integration tests for testing key assignment
- `instance_test.go` - ties the integration test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback
diff --git a/tests/integration/democracy.go b/tests/integration/democracy.go
index baea36857b..341b421d21 100644
--- a/tests/integration/democracy.go
+++ b/tests/integration/democracy.go
@@ -302,11 +302,13 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams() {
votingAccounts := s.consumerChain.SenderAccounts
bondDenom, err := stakingKeeper.BondDenom(s.consumerCtx())
s.Require().NoError(err)
+
depositAmount := params.MinDeposit
duration := (3 * time.Second)
params.VotingPeriod = &duration
err = govKeeper.Params.Set(s.consumerCtx(), params)
s.Assert().NoError(err)
+
proposer := s.consumerChain.SenderAccount
s.consumerChain.NextBlock()
votersOldBalances := getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts)
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 8e4c2b9888..4693233182 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -20,7 +20,7 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// TesRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.
+// TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.
// @Long Description@
// The test sets up a provider and consumer chain and completes the channel initialization.
// Then, it sends tokens into the FeeCollector on the consumer chain,
@@ -269,10 +269,15 @@ func (s *CCVTestSuite) TestSendRewardsRetries() {
"expected escrow balance to BE updated - OLD: %s, NEW: %s", oldEscBalance, newEscBalance)
}
-// TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected
-// number of block have passed. It also checks that the IBC transfer transfer states are discarded if
-// the reward distribution to the provider has failed.
-//
+// TestEndBlockRD tests that the last transmission block height is correctly updated after the expected number of block have passed.
+// @Long Description@
+// The test first sets up CCV and transmission channels between the provider
+// and consumer chains. It then fills the fee pool on the consumer chain, prepares the system for reward
+// distribution, and optionally corrupts the transmission channel to simulate failure scenarios.
+// After advancing the block height, the test verifies whether the LBTH is updated correctly
+// and if the escrow balance changes as expected. The test also checks that the IBC transfer
+// transfer states are discarded if the reward distribution to the provider has failed.
+
// Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking.
func (s *CCVTestSuite) TestEndBlockRD() {
testCases := []struct {
@@ -392,8 +397,11 @@ func (s *CCVTestSuite) TestEndBlockRD() {
}
}
-// TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(),
-// but is written as an integration test to avoid excessive mocking.
+// TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.
+// @Long Description@
+// The test first sets up CCV and transmission channels between the provider and consumer chains.
+// Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
+// function handles each scenario correctly by ensuring the expected number of token transfers and proper error handling.
func (s *CCVTestSuite) TestSendRewardsToProvider() {
testCases := []struct {
name string
@@ -535,7 +543,11 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() {
}
}
-// TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback
+// TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.
+// @Long Description@
+// The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
+// the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly, rewards are allocated as expected,
+// and the appropriate errors are raised when conditions are not met.
func (s *CCVTestSuite) TestIBCTransferMiddleware() {
var (
data transfertypes.FungibleTokenPacketData
@@ -995,8 +1007,13 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() {
}
}
-// TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with
-// consumer validators that have different heights. Specifically, test that validators that have been consumer validators
+// TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` test with
+// consumer validators that have different heights.
+// @Long Description@
+// It sets up a context where the consumer validators have different join heights and verifies that rewards are
+// correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
+// among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
+// who do not meet the required join height criteria. It confirms that validators that have been consumer validators
// for some time receive rewards, while validators that recently became consumer validators do not receive rewards.
func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights() {
// Note this test is an adaptation of a `TestAllocateTokensToConsumerValidators` testcase.
@@ -1105,7 +1122,13 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida
}
}
-// TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains
+// TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains.
+// @Long Description@
+// It sets up multiple consumer and transfer channels and verifies the distribution of rewards from
+// various consumer chains to the provider's reward pool. It ensures that the consumer reward pools are
+// correctly populated and that rewards are properly transferred to the provider. The test checks that
+// the provider's reward pool balance reflects the accumulated rewards from all consumer chains after
+// processing IBC transfer packets and relaying committed packets.
func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() {
s.SetupAllCCVChannels()
s.SetupAllTransferChannels()
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index 2f275fd95c..715a652fe6 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -12,8 +12,11 @@ import (
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
)
-// TestHandleConsumerDoubleVoting verifies that handling a double voting evidence
-// of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator
+// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.
+// @Long Description@
+// The test sets up a CVV channel, creates various double voting scenarios, and submits these to the provider chain.
+// It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the correct
+// slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in incorrect penalties.
func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -266,8 +269,12 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
}
}
-// TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting
-// evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations
+// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
+// @Long Description@
+// The test sets up a CVV channel, creates various double voting scenarios, and submits these to the provider chain.
+// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
+// handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
+// The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go
index 5a55c75079..2d164145bf 100644
--- a/tests/integration/expired_client.go
+++ b/tests/integration/expired_client.go
@@ -17,9 +17,13 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired.
-// While the consumer client is expired (or inactive for some reason) all packets will be queued and
-// and cleared once the consumer client is established.
+// TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.
+// @Long Description@
+// The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tockens to provider,
+// sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
+// all packets will be queued. The packet sending and checks are then repeated. After that more tockens are bond on
+// provider to change validator powers. Finally expired client is upgraded to the consumer
+// and all packets are cleared once the consumer client is established.
func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
@@ -83,7 +87,10 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
}
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
-// While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded.
+// @Long Description@
+// The test sets up a CVV channel and bonds tockens on provider, then it sends CCV packet to consumer and rebonds tockens on provider.
+// Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
+// Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded.
func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
consumerKeeper := s.consumerApp.GetConsumerKeeper()
From 4e11ae923bf333d277e9a5a3f929c9ae680e0eef Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 23 Aug 2024 16:10:36 +0200
Subject: [PATCH 24/88] Improved misbehavior.go test descriptions
---
tests/integration/README.md | 1 +
tests/integration/misbehaviour.go | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index b3e9b41b05..1ecf606831 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -14,6 +14,7 @@ Integration tests are categorized into files as follows:
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
- `changeover.go` - integration tests for testing reuse of existing transfer channels
- `double_vote.go` - integration tests for testing the handling of double voting
+- `misbehavior.go` - integration tests for testing the handling of misbehaviors
- `expired_client.go` - integration tests for testing expired clients
- `key_assignment.go` - integration tests for testing key assignment
- `instance_test.go` - ties the integration test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 8f760b1bd0..4d213f0d22 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -14,8 +14,12 @@ import (
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
)
-// TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour,
-// with conflicting headers forming an equivocation, results in the jailing of the validators
+// TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.
+// @Long Description@
+// The test sets up a CVV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
+// It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
+// After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
+// validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert that their tokens are adjusted based on the slashing fraction.
func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
From ae10a1288007cb658fd03120b085cda4f1000f94 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 26 Aug 2024 09:17:03 +0200
Subject: [PATCH 25/88] Improved normal_operations.go test descriptions
---
tests/integration/misbehaviour.go | 3 ++-
tests/integration/normal_operations.go | 8 +++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 4d213f0d22..9ab3270bcf 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -19,7 +19,8 @@ import (
// The test sets up a CVV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
// It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
// After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
-// validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert that their tokens are adjusted based on the slashing fraction.
+// validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert
+// that their tokens are adjusted based on the slashing fraction.
func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/normal_operations.go b/tests/integration/normal_operations.go
index 155ac4f44d..5bc813697e 100644
--- a/tests/integration/normal_operations.go
+++ b/tests/integration/normal_operations.go
@@ -9,7 +9,13 @@ import (
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// Tests the tracking of historical info in the context of new blocks being committed
+// TestHistoricalInfo tests the tracking of historical information in the context of new blocks being committed.
+// @Long Description@
+// The test first saves the initial number of CC validators and current block height.
+// Then it adds a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
+// After, the test setup creates 2 validators and then calls TrackHistoricalInfo with header block height
+// Test cases verify that historical information is pruned correctly and that the validator set is updated as expected.
+// Execution of test cases checks if the historical information is correctly handled and pruned based on the block height.
func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so we can copy locks
consumerKeeper := k.consumerApp.GetConsumerKeeper()
cCtx := k.consumerChain.GetContext
From 62a5181d975a482cb8dcd23690d29bb13a64020d Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 26 Aug 2024 10:04:17 +0200
Subject: [PATCH 26/88] Improved provider_gov_hooks.go test descriptions
---
tests/integration/README.md | 1 +
tests/integration/provider_gov_hooks.go | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index 1ecf606831..1406091b35 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -12,6 +12,7 @@ Integration tests are categorized into files as follows:
- `distribution.go` - integration tests for the _Reward Distribution_ sub-protocol
- `stop_consumer.go` - integration tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
+- `provider_gov_hooks.go` - integration tests for testing provider hooks
- `changeover.go` - integration tests for testing reuse of existing transfer channels
- `double_vote.go` - integration tests for testing the handling of double voting
- `misbehavior.go` - integration tests for testing the handling of misbehaviors
diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go
index 8f5ba95de7..bebdb35d67 100644
--- a/tests/integration/provider_gov_hooks.go
+++ b/tests/integration/provider_gov_hooks.go
@@ -13,8 +13,13 @@ import (
testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper"
)
-// tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks
-// hooks require adding a proposal in the gov module and registering a consumer chain with the provider module
+// TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.
+// @Long Description
+// The test sets up the account that will submit the proposal, and then the proposal is created.
+// After the proposal is submitted the AfterProposalSubmission hook is triggered
+// and it should handle the submission of the proposal in the provider module.
+// Proposal submission is then verified, and lastly AfterProposalVotingPeriodEnded is triggered.
+// Tests verifies the deletion of the proposal.
func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() {
ctx := s.providerChain.GetContext()
providerKeeper := s.providerApp.GetProviderKeeper()
From df4de45c25915a09ecc7c1b3dc35891084e4cdf0 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 26 Aug 2024 10:13:44 +0200
Subject: [PATCH 27/88] Improved query_providerinfo_test.go test descriptions
---
tests/integration/README.md | 1 +
tests/integration/query_providerinfo_test.go | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index 1406091b35..294ae7384a 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -13,6 +13,7 @@ Integration tests are categorized into files as follows:
- `stop_consumer.go` - integration tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
- `provider_gov_hooks.go` - integration tests for testing provider hooks
+- `query_providerinfo_test.go` - integration tests for testing provider info
- `changeover.go` - integration tests for testing reuse of existing transfer channels
- `double_vote.go` - integration tests for testing the handling of double voting
- `misbehavior.go` - integration tests for testing the handling of misbehaviors
diff --git a/tests/integration/query_providerinfo_test.go b/tests/integration/query_providerinfo_test.go
index 8058248310..57bbfd8d1a 100644
--- a/tests/integration/query_providerinfo_test.go
+++ b/tests/integration/query_providerinfo_test.go
@@ -1,5 +1,10 @@
package integration
+// TestQueryProviderInfo tests the results of GetProviderInfo method.
+// @Long Description
+// The test sets up a CVV channel and sends an empty VSC packet.
+// Then verifies that the result of GetProviderInfo method is correct and it
+// provides expected information about the blockchain provider and consumer.
func (s *CCVTestSuite) TestQueryProviderInfo() {
s.SetupCCVChannel(s.path)
s.SendEmptyVSCPacket()
From dbc0051f7873e9491a9599ebec1954d43ced39e8 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 26 Aug 2024 12:00:22 +0200
Subject: [PATCH 28/88] Removed warnings from setup.go
---
tests/integration/setup.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/integration/setup.go b/tests/integration/setup.go
index eeb980200f..9386ce6cb9 100644
--- a/tests/integration/setup.go
+++ b/tests/integration/setup.go
@@ -396,7 +396,7 @@ func (suite *CCVTestSuite) SetupAllTransferChannels() {
}
}
-func (s CCVTestSuite) validateEndpointsClientConfig(consumerBundle icstestingutils.ConsumerBundle) { //nolint:govet // this is a test so we can copy locks
+func (s *CCVTestSuite) validateEndpointsClientConfig(consumerBundle icstestingutils.ConsumerBundle) { //nolint:govet // this is a test so we can copy locks
consumerKeeper := consumerBundle.GetKeeper()
providerStakingKeeper := s.providerApp.GetTestStakingKeeper()
From bb00e27e3a2cb65227c75a9fa49860c5fa3661b7 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Tue, 27 Aug 2024 16:04:13 +0200
Subject: [PATCH 29/88] Improved slashing.go test descriptions
---
tests/integration/provider_gov_hooks.go | 2 +-
tests/integration/query_providerinfo_test.go | 2 +-
tests/integration/slashing.go | 65 +++++++++++++++++---
3 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go
index bebdb35d67..322f772be4 100644
--- a/tests/integration/provider_gov_hooks.go
+++ b/tests/integration/provider_gov_hooks.go
@@ -14,7 +14,7 @@ import (
)
// TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.
-// @Long Description
+// @Long Description@
// The test sets up the account that will submit the proposal, and then the proposal is created.
// After the proposal is submitted the AfterProposalSubmission hook is triggered
// and it should handle the submission of the proposal in the provider module.
diff --git a/tests/integration/query_providerinfo_test.go b/tests/integration/query_providerinfo_test.go
index 57bbfd8d1a..5e29bdbc5a 100644
--- a/tests/integration/query_providerinfo_test.go
+++ b/tests/integration/query_providerinfo_test.go
@@ -1,7 +1,7 @@
package integration
// TestQueryProviderInfo tests the results of GetProviderInfo method.
-// @Long Description
+// @Long Description@
// The test sets up a CVV channel and sends an empty VSC packet.
// Then verifies that the result of GetProviderInfo method is correct and it
// provides expected information about the blockchain provider and consumer.
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 254a8467a4..f58a7ef725 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -29,9 +29,18 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed
-// from consumer to provider, handled by provider, with a VSC and jailing
-// eventually effective on consumer and provider.
+// TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider,
+// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
+// @Long Description@
+// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
+// The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
+// Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
+// it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
+// timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
+// After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
+// process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
+// and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
+// chain acknowledges receipt of the packet from the provider chain.
//
// Note: This method does not test the actual slash packet sending logic for downtime
// and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
@@ -172,7 +181,17 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
s.Require().NoError(err)
}
-// Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet.
+// TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets.
+// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
+// @Long Description@
+// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
+// The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
+// Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
+// The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
+// timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
+// and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
+// packet to confirm that it has been processed.
+//
// Note that double-sign slash packets should not affect the provider validator set.
func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() {
// Setup CCV channel for all instantiated consumers
@@ -303,6 +322,12 @@ func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
}
// TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.
+// @Long Description@
+// It retrives a validator from provider chain's validators and cheks if it's bonded.
+// The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
+// The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
+// It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
+//
// Note that only downtime slash packets are processed by HandleSlashPacket.
func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
providerKeeper := suite.providerApp.GetProviderKeeper()
@@ -345,6 +370,11 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
}
// TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting
+// @Long Description@
+// It sets up all CCV channels and expects panic if ccv channel is not established via dest channel of packet.
+// After the correct channelID is added to the packet, a panic shouldn't occur anymore.
+// The test creates an instance of SlashPacketData and then verifies correct processing and error handling
+// for slashing packets received by the provider chain.
func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
providerKeeper := suite.providerApp.GetProviderKeeper()
firstBundle := suite.getFirstBundle()
@@ -441,9 +471,15 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
suite.Require().Equal(ccv.SlashPacketHandledResult, ackResult, "expected successful ack")
}
-// TestValidatorDowntime tests if a slash packet is sent
-// and if the outstanding slashing flag is switched
+// TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched
// when a validator has downtime on the slashing module
+// @Long Description@
+// It sets up all CCV channel and send an empty VSC packet, then retrives the address of a validator.
+// Validator signins blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and commited.
+// The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
+// Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
+// Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
+// It verifies that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block.
func (suite *CCVTestSuite) TestValidatorDowntime() {
// initial setup
suite.SetupCCVChannel(suite.path)
@@ -555,8 +591,12 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
})
}
-// TestValidatorDoubleSigning tests if a slash packet is sent
-// when a double-signing evidence is handled by the evidence module
+// TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module
+// @Long Description@
+// It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
+// evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
+// The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
+// it cheks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent
func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// initial setup
suite.SetupCCVChannel(suite.path)
@@ -644,6 +684,11 @@ func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets.
// In normal operation slash packets are queued in BeginBlock and sent in EndBlock.
+// @Long Description@
+// It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
+// Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
+// After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
+// are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty.
func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
suite.SetupCCVChannel(suite.path)
@@ -724,6 +769,10 @@ func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
// TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or
// have any undesired behavior when a slash packet is queued before the CCV channel is established.
// Then once the CCV channel is established, the slash packet should be sent soon after.
+// @Long Description@
+// It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
+// The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
+// The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent.
func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From c193198a1878647ce219f795e7ca078e62ba0464 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Tue, 27 Aug 2024 16:58:39 +0200
Subject: [PATCH 30/88] Improved stop_consumer.go test descriptions
---
tests/integration/stop_consumer.go | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go
index f7b2d6ef96..d8aa7c1bb5 100644
--- a/tests/integration/stop_consumer.go
+++ b/tests/integration/stop_consumer.go
@@ -10,7 +10,17 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// Tests the functionality of stopping a consumer chain at a higher level than unit tests
+// TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.
+// @Long Description@
+// It retrieves a validator from the provider chain's validators and then the delegator address.
+// Then the test sets up test operations, populating the provider chain states using the following operations:
+// - Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
+// - Delegate the total bond amount to the chosen validator.
+// - Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
+// - Set SlashAck state for the consumer chain ID.
+//
+// After, the setup operations are executed, and the consumer chain is stopped. Finally, the test checks that the state
+// associated with the consumer chain is properly cleaned up after it is stopped.
func (s *CCVTestSuite) TestStopConsumerChain() {
providerKeeper := s.providerApp.GetProviderKeeper()
providerStakingKeeper := s.providerApp.GetTestStakingKeeper()
From e3ebe8c8eafbf6d6892a1f21264a5ea0cf40d337 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Tue, 27 Aug 2024 18:00:29 +0200
Subject: [PATCH 31/88] Improved throttle_retry.go test descriptions
---
tests/integration/throttle_retry.go | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go
index fcc795bb27..f09f8908e6 100644
--- a/tests/integration/throttle_retry.go
+++ b/tests/integration/throttle_retry.go
@@ -11,6 +11,15 @@ import (
)
// TestSlashRetries tests the throttling v2 retry logic at an integration level.
+// @Long Description@
+// This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
+// Two validators are then selected, and their signing information is set up.
+// The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
+// It verifies that the packet is sent. Packet is then recived on the provider side and handled. The test then confirms that the first validator has been jailed
+// and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
+// that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
+// The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
+// checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain.
func (s *CCVTestSuite) TestSlashRetries() {
s.SetupAllCCVChannels()
s.SendEmptyVSCPacket() // Establish ccv channel
From 547ef242e40d5fe944a4a3324ee04c53c57818a0 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 28 Aug 2024 17:00:37 +0200
Subject: [PATCH 32/88] Improved throttle.go test descriptions
---
tests/integration/throttle.go | 51 +++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 8 deletions(-)
diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go
index d9bfa1ed28..e841720ec2 100644
--- a/tests/integration/throttle.go
+++ b/tests/integration/throttle.go
@@ -21,6 +21,14 @@ const fullSlashMeterString = "1.0"
// TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer,
// two slash packets, and no VSC matured packets. The most basic scenario.
+// @Long Description@
+// It sets up various test cases, all CCV channels and validator powers. Also, the initial value of the slash meter is retrieved, and the test verifies it
+// has the expected value. All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
+// The test then creates a slash packet for the first validator and sends it from the consumer to the provider.
+// Afterward, it asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
+// Then, a second slash packet is created for a different validator, and the test validates that the second validator is
+// not jailed after sending the second slash packet. Next, it replenishes the slash meter until it is positive.
+// Lastly, it asserts that validator 2 is jailed once the slash packet is retried and that it has no more voting power.
func (s *CCVTestSuite) TestBasicSlashPacketThrottling() {
// setupValidatePowers gives the default 4 validators 25% power each (1000 power).
// Note this in test cases.
@@ -194,6 +202,13 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() {
// TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple
// consumers sending slash packets to the provider, with VSC matured packets sprinkled around.
+// @Long Description@
+// It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash packets are sent from each of the chosen
+// consumer bundles to the provider chain. They will each slash a different validator. The test then confirms that the slash packet for the first consumer was handled first,
+// and afterward, the slash packets for the second and third consumers were bounced. It then checks the total power of validators in the provider
+// chain to ensure it reflects the expected state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued
+// The slash meter is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated and verified again.
+// Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test confirms that all validators are jailed.
func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
// Setup test
s.SetupAllCCVChannels()
@@ -314,8 +329,12 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
}
}
-// TestPacketSpam confirms that the provider can handle a large number of
-// incoming slash packets in a single block.
+// TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.
+// @Long Description@
+// It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
+// The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between downtime and double-sign infractions.
+// The test then simulates the reception of the 500 packets by the provider chain within the same block. Lastly, it verifies that the first three validators
+// have been jailed as expected. This confirms that the system correctly processed the slash packets and applied the penalties.
func (s *CCVTestSuite) TestPacketSpam() {
// Setup ccv channels to all consumers
s.SetupAllCCVChannels()
@@ -467,8 +486,14 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
}
}
-// TestSlashingSmallValidators tests that multiple slash packets from validators with small
-// power can be handled by the provider chain in a non-throttled manner.
+// TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.
+// @Long Description@
+// It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
+// The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
+// It then sets up default signing information for the three smaller validators to prepare them for being jailed.
+// The slash packets for the small validators are then constructed and sent.
+// Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
+// that the three smaller ones have been penalized and jailed.
func (s *CCVTestSuite) TestSlashingSmallValidators() {
s.SetupAllCCVChannels()
providerKeeper := s.providerApp.GetProviderKeeper()
@@ -542,6 +567,10 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() {
}
// TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.
+// @Long Description@
+// It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
+// Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
+// Lastly, it changes the replenish fraction and asserts the new expected allowance.
//
// TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges.
func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() {
@@ -565,12 +594,18 @@ func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() {
s.Require().Equal(int64(1200), providerKeeper.GetSlashMeterAllowance(s.providerCtx()).Int64())
}
-// Similar to TestSlashSameValidator, but 100% of val power is jailed a single block,
-// and in the first packets recv for that block.
-// This edge case should not occur in practice, but is useful to validate that
+// TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.
+// @Long Description@
+// It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
+// One slash packet is created for each validator, and then an additional five more for each validator
+// in order to test the system's ability to handle multiple slashing events in a single block.
+// The test then receives and processes each slashing packet in the provider chain
+// and afterward, it checks that all validators are jailed as expected.
+//
+// Note: This edge case should not occur in practice, but it is useful to validate that
// the slash meter can allow any number of slash packets to be handled in a single block when
// its allowance is set to "1.0".
-func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a test so we can copy locks
+func (s *CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a test so we can copy locks
s.SetupAllCCVChannels()
From 31a85e08e5721fb79d5f604da2b9628e0858ffe7 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 28 Aug 2024 17:04:21 +0200
Subject: [PATCH 33/88] Fixed spelling mistake
---
tests/integration/double_vote.go | 4 ++--
tests/integration/misbehaviour.go | 2 +-
tests/integration/query_providerinfo_test.go | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index 715a652fe6..609c870957 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -14,7 +14,7 @@ import (
// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.
// @Long Description@
-// The test sets up a CVV channel, creates various double voting scenarios, and submits these to the provider chain.
+// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
// It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the correct
// slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in incorrect penalties.
func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
@@ -271,7 +271,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
// @Long Description@
-// The test sets up a CVV channel, creates various double voting scenarios, and submits these to the provider chain.
+// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
// handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
// The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 9ab3270bcf..ac7ac00b41 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -16,7 +16,7 @@ import (
// TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.
// @Long Description@
-// The test sets up a CVV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
+// The test sets up a CCV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
// It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
// After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
// validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert
diff --git a/tests/integration/query_providerinfo_test.go b/tests/integration/query_providerinfo_test.go
index 5e29bdbc5a..a1121537a6 100644
--- a/tests/integration/query_providerinfo_test.go
+++ b/tests/integration/query_providerinfo_test.go
@@ -2,7 +2,7 @@ package integration
// TestQueryProviderInfo tests the results of GetProviderInfo method.
// @Long Description@
-// The test sets up a CVV channel and sends an empty VSC packet.
+// The test sets up a CCV channel and sends an empty VSC packet.
// Then verifies that the result of GetProviderInfo method is correct and it
// provides expected information about the blockchain provider and consumer.
func (s *CCVTestSuite) TestQueryProviderInfo() {
From 6707dcc13f4d21b5489e5802172397e1355f36c3 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Thu, 29 Aug 2024 10:43:26 +0200
Subject: [PATCH 34/88] Improved valset_update.go test descriptions
---
tests/integration/valset_update.go | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/tests/integration/valset_update.go b/tests/integration/valset_update.go
index 994dfab4af..fa5dfc7835 100644
--- a/tests/integration/valset_update.go
+++ b/tests/integration/valset_update.go
@@ -13,7 +13,11 @@ import (
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
-// TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on provider
+// TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.
+// @Long Description@
+// It sets up CCV and transfer channels. Some tokens are then bonded on the provider side in order to change validator power.
+// The test then relays a packet from the provider chain to the consumer chain.
+// Lastly, it relays a matured packet from the consumer chain back to the provider chain.
func (s *CCVTestSuite) TestPacketRoundtrip() {
s.SetupCCVChannel(s.path)
s.SetupTransferChannel()
@@ -36,8 +40,17 @@ func (s *CCVTestSuite) TestPacketRoundtrip() {
relayAllCommittedPackets(s, s.consumerChain, s.path, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, 1)
}
-// TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call
-// and its integration with SendPackets call.
+// TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.
+// @Long Description@
+// It sets up CCV channel and then creates and simulates the sending of three VSC packets
+// from the provider chain to the consumer chain at different times. The first packet is sent, and its processing is validated.
+// After simulating the passage of one hour, the second packet is sent and its processing is validated. Then after simulating the
+// passage of 24 more hours, the third packet is sent and its processing is validated. The test then retrieves all packet maturity
+// times from the consumer, and this is used to check the maturity status of the packets sent earlier.
+// The test then advances the time so that the first two packets reach their unbonding period, while the third packet does not.
+// Next it ensures first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
+// The third packet is still in the store and has not yet been processed for unbonding.
+// Finally, the test checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state.
func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From d6af82ec5fbffbae4d2e849a6d10d7da4c21baeb Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 12:40:39 +0200
Subject: [PATCH 35/88] Improved test documentation
---
scripts/test_doc/extract_docstrings.go | 31 +++-
scripts/test_doc/test_documentation.md | 206 ++++++++++++++++++-------
tests/integration/common.go | 2 +-
tests/integration/distribution.go | 2 +-
tests/integration/double_vote.go | 5 +-
tests/integration/expired_client.go | 6 +-
tests/integration/key_assignment.go | 2 +-
tests/integration/slashing.go | 6 +-
tests/integration/unbonding.go | 2 +-
9 files changed, 187 insertions(+), 75 deletions(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index 98287277de..ce939a646a 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -5,7 +5,6 @@ import (
"go/ast"
"go/parser"
"go/token"
- "io/ioutil"
"log"
"os"
"path/filepath"
@@ -26,8 +25,6 @@ func main() {
// Write the header for the markdown file
fmt.Fprintf(out, "# Test Documentation\n\n")
- fmt.Fprintf(out, "| File | Function | Short Description |\n")
- fmt.Fprintf(out, "|------|----------|-------------------|\n")
errorStatusCode := false
@@ -66,7 +63,7 @@ func main() {
// It returns a list of test functions that are missing docstrings.
func extractDocstrings(filePath string, out *os.File) []string {
// Read the Go source file
- src, err := ioutil.ReadFile(filePath)
+ src, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("Error reading file %s: %v\n", filePath, err)
}
@@ -80,14 +77,29 @@ func extractDocstrings(filePath string, out *os.File) []string {
functionsMissingDocstrings := []string{}
+ // Files that do not contain test functions are excluded from the documentation.
+ fileNameWritten := false
+
// Traverse the AST
for _, f := range node.Decls {
if fn, isFn := f.(*ast.FuncDecl); isFn && strings.HasPrefix(fn.Name.Name, "Test") {
// Check if the function has a docstring
if fn.Doc != nil {
+
+ if !fileNameWritten {
+ relativePath := strings.TrimPrefix(filePath, "../../tests/integration/")
+ doclink := fmt.Sprintf("[%s](%s)", relativePath, filePath)
+ fmt.Fprintf(out, "# %s \n", doclink)
+ fmt.Fprintf(out, " Test Specifications
\n\n")
+
+ // Write table header
+ fmt.Fprintf(out, "| Function | Short Description |\n")
+ fmt.Fprintf(out, "|----------|-------------------|\n")
+ fileNameWritten = true
+ }
+
doc := fn.Doc.Text()
- relativePath := strings.TrimPrefix(filePath, "../../tests/integration/")
- link := fmt.Sprintf("[%s](%s#L%d)", relativePath, filePath, fset.Position(fn.Pos()).Line)
+ link := fmt.Sprintf("[%s](%s#L%d)", fn.Name.Name, filePath, fset.Position(fn.Pos()).Line)
// Split the docstring based on the separator "========"
parts := strings.Split(doc, "\n@Long Description@\n")
@@ -113,12 +125,15 @@ func extractDocstrings(filePath string, out *os.File) []string {
description += fmt.Sprintf("Details
%s ", longDescription)
}
- fmt.Fprintf(out, "| %s | %s | %s |\n", link, fn.Name.Name, description)
+ fmt.Fprintf(out, " %s | %s |\n", link, description)
} else {
functionsMissingDocstrings = append(functionsMissingDocstrings, fn.Name.Name)
+
}
}
}
-
+ if fileNameWritten {
+ fmt.Fprintf(out, " \n\n")
+ }
return functionsMissingDocstrings
}
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index beea538a38..6fa8268181 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -1,57 +1,153 @@
# Test Documentation
-| File | Function | Short Description |
-|------|----------|-------------------|
-| [changeover.go](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
-| [channel_init.go](../../tests/integration/channel_init.go#L10) | TestInitTimeout | TestInitTimeout tests that the init timeout is respected.Details
The test sets up a provider with a configured init timeout period.
It then creates a connection between the provider and consumer chains,
and then performs a handshake (stopping at various stages of the process to simulate a timeout).
It then increments the time by the init timeout period and checks that the chain was removed if the timeout was reached,
or that the chain was not removed if the handshake was indeed completed before the timeout. |
-| [democracy.go](../../tests/integration/democracy.go#L79) | TestDemocracyRewardsDistribution | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
-| [democracy.go](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
-| [democracy.go](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
-| [distribution.go](../../tests/integration/distribution.go#L32) | TestRewardsDistribution | TesRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
-| [distribution.go](../../tests/integration/distribution.go#L201) | TestSendRewardsRetries | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
-| [distribution.go](../../tests/integration/distribution.go#L277) | TestEndBlockRD | TestEndBlockRD tests that the last transmission block height (LTBH) is correctly updated after the expected number of block have passed. It also checks that the IBC transfer transfer states are discarded if the reward distribution to the provider has failed. Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L397) | TestSendRewardsToProvider | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking. |
-| [distribution.go](../../tests/integration/distribution.go#L539) | TestIBCTransferMiddleware | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback |
-| [distribution.go](../../tests/integration/distribution.go#L721) | TestAllocateTokens | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool |
-| [distribution.go](../../tests/integration/distribution.go#L861) | TestAllocateTokensToConsumerValidators | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
-| [distribution.go](../../tests/integration/distribution.go#L996) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` with consumer validators that have different heights. Specifically, test that validators that have been consumer validators for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
-| [distribution.go](../../tests/integration/distribution.go#L1104) | TestMultiConsumerRewardsDistribution | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains |
-| [double_vote.go](../../tests/integration/double_vote.go#L17) | TestHandleConsumerDoubleVoting | TestHandleConsumerDoubleVoting verifies that handling a double voting evidence of a consumer chain results in the expected tombstoning, jailing, and slashing of the misbehaved validator |
-| [double_vote.go](../../tests/integration/double_vote.go#L271) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations verifies that handling a successful double voting evidence of a consumer chain results in the expected slashing of the misbehave validator undelegations |
-| [expired_client.go](../../tests/integration/expired_client.go#L23) | TestVSCPacketSendExpiredClient | TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. While the consumer client is expired (or inactive for some reason) all packets will be queued and and cleared once the consumer client is established. |
-| [expired_client.go](../../tests/integration/expired_client.go#L87) | TestConsumerPacketSendExpiredClient | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired. While the provider client is expired all packets will be queued and and cleared once the provider client is upgraded. |
-| [key_assignment.go](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queud
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
-| [misbehaviour.go](../../tests/integration/misbehaviour.go#L19) | TestHandleConsumerMisbehaviour | TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, with conflicting headers forming an equivocation, results in the jailing of the validators |
-| [misbehaviour.go](../../tests/integration/misbehaviour.go#L97) | TestGetByzantineValidators | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a header with a subset of the validators on the consumer chain,
then creates a second header (in a variety of different ways),
and checks which validators are considered Byzantine
by calling the GetByzantineValidators function.
The test scenarios are:
* when one of the headers is empty, the function should return an error
* when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
* when the signatures in one of the headers are corrupted, the function should return an error
* when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
* for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
-| [misbehaviour.go](../../tests/integration/misbehaviour.go#L394) | TestCheckMisbehaviour | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or freezing the client. |
-| [normal_operations.go](../../tests/integration/normal_operations.go#L13) | TestHistoricalInfo | Tests the tracking of historical info in the context of new blocks being committed |
-| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L18) | TestAfterPropSubmissionAndVotingPeriodEnded | tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks hooks require adding a proposal in the gov module and registering a consumer chain with the provider module |
-| [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go#L60) | TestGetConsumerAdditionLegacyPropFromProp | TestGetConsumerAdditionLegacyPropFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on various types of proposals to test the behavior of the hook.Details
The tes case created a provider chain,
then submits a Proposal with various different types of content.
Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook. |
-| [slashing.go](../../tests/integration/slashing.go#L39) | TestRelayAndApplyDowntimePacket | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider. Note: This method does not test the actual slash packet sending logic for downtime and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for those types of tests. |
-| [slashing.go](../../tests/integration/slashing.go#L177) | TestRelayAndApplyDoubleSignPacket | Similar setup to TestRelayAndApplyDowntimePacket, but with a double sign slash packet. Note that double-sign slash packets should not affect the provider validator set. |
-| [slashing.go](../../tests/integration/slashing.go#L263) | TestSlashPacketAcknowledgement | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
-| [slashing.go](../../tests/integration/slashing.go#L307) | TestHandleSlashPacketDowntime | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests. Note that only downtime slash packets are processed by HandleSlashPacket. |
-| [slashing.go](../../tests/integration/slashing.go#L348) | TestOnRecvSlashPacketErrors | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting |
-| [slashing.go](../../tests/integration/slashing.go#L447) | TestValidatorDowntime | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module |
-| [slashing.go](../../tests/integration/slashing.go#L560) | TestValidatorDoubleSigning | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module |
-| [slashing.go](../../tests/integration/slashing.go#L647) | TestQueueAndSendSlashPacket | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock. |
-| [slashing.go](../../tests/integration/slashing.go#L727) | TestCISBeforeCCVEstablished | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after. |
-| [stop_consumer.go](../../tests/integration/stop_consumer.go#L14) | TestStopConsumerChain | Tests the functionality of stopping a consumer chain at a higher level than unit tests |
-| [stop_consumer.go](../../tests/integration/stop_consumer.go#L99) | TestStopConsumerOnChannelClosed | TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
-| [throttle.go](../../tests/integration/throttle.go#L24) | TestBasicSlashPacketThrottling | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario. |
-| [throttle.go](../../tests/integration/throttle.go#L197) | TestMultiConsumerSlashPacketThrottling | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around. |
-| [throttle.go](../../tests/integration/throttle.go#L319) | TestPacketSpam | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block. |
-| [throttle.go](../../tests/integration/throttle.go#L391) | TestDoubleSignDoesNotAffectThrottling | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
-| [throttle.go](../../tests/integration/throttle.go#L472) | TestSlashingSmallValidators | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner. |
-| [throttle.go](../../tests/integration/throttle.go#L547) | TestSlashMeterAllowanceChanges | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change. TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
-| [throttle.go](../../tests/integration/throttle.go#L573) | TestSlashAllValidators | Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, and in the first packets recv for that block. This edge case should not occur in practice, but is useful to validate that the slash meter can allow any number of slash packets to be handled in a single block when its allowance is set to "1.0". |
-| [throttle_retry.go](../../tests/integration/throttle_retry.go#L14) | TestSlashRetries | TestSlashRetries tests the throttling v2 retry logic at an integration level. |
-| [unbonding.go](../../tests/integration/unbonding.go#L16) | TestUndelegationNormalOperation | TestUndelegationNormalOperation tests that undelegations complete after the unbonding period elapses on both the consumer and provider, without VSC packets timing out. |
-| [unbonding.go](../../tests/integration/unbonding.go#L131) | TestUndelegationVscTimeout | TestUndelegationVscTimeout tests that an undelegation completes after vscTimeoutPeriod even if it does not reach maturity on the consumer chain. In this case, the consumer chain is removed. |
-| [unbonding.go](../../tests/integration/unbonding.go#L192) | TestUndelegationDuringInit | TestUndelegationDuringInit checks that before the CCV channel is established - no undelegations can complete, even if the provider unbonding period elapses - all the VSC packets are stored in state as pending - if the channel handshake times out, then the undelegation completes |
-| [unbonding.go](../../tests/integration/unbonding.go#L304) | TestUnbondingNoConsumer | Bond some tokens on provider Unbond them to create unbonding op Check unbonding ops on both sides Advance time so that provider's unbonding op completes Check that unbonding has completed in provider staking |
-| [unbonding.go](../../tests/integration/unbonding.go#L342) | TestRedelegationNoConsumer | TestRedelegationNoConsumer tests a redelegate transaction submitted on a provider chain with no consumers |
-| [unbonding.go](../../tests/integration/unbonding.go#L392) | TestRedelegationProviderFirst | TestRedelegationWithConsumer tests a redelegate transaction submitted on a provider chain when the unbonding period elapses first on the provider chain |
-| [unbonding.go](../../tests/integration/unbonding.go#L475) | TestTooManyLastValidators | This test reproduces a fixed bug when an inactive validator enters back into the active set. It used to cause a panic in the provider module hook called by AfterUnbondingInitiated during the staking module EndBlock. |
-| [valset_update.go](../../tests/integration/valset_update.go#L17) | TestPacketRoundtrip | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on provider |
-| [valset_update.go](../../tests/integration/valset_update.go#L41) | TestQueueAndSendVSCMaturedPackets | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call. |
+# [changeover.go](../../tests/integration/changeover.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+
+
+# [democracy.go](../../tests/integration/democracy.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestDemocracyRewardsDistribution](../../tests/integration/democracy.go#L79) | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
+ [TestDemocracyGovernanceWhitelisting](../../tests/integration/democracy.go#L195) | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
+ [TestDemocracyMsgUpdateParams](../../tests/integration/democracy.go#L295) | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
+
+
+# [distribution.go](../../tests/integration/distribution.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestRewardsDistribution](../../tests/integration/distribution.go#L32) | TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
+ [TestSendRewardsRetries](../../tests/integration/distribution.go#L204) | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
+ [TestEndBlockRD](../../tests/integration/distribution.go#L285) | Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+ [TestSendRewardsToProvider](../../tests/integration/distribution.go#L408) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers and proper error handling. |
+ [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly, rewards are allocated as expected,
and the appropriate errors are raised when conditions are not met. |
+ [TestAllocateTokens](../../tests/integration/distribution.go#L744) | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool.Details
The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
and checks that the rewards are allocated as expected. |
+ [TestAllocateTokensToConsumerValidators](../../tests/integration/distribution.go#L884) | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
+ [TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights](../../tests/integration/distribution.go#L1026) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with consumer validators that have different heights.Details
It sets up a context where the consumer validators have different join heights and verifies that rewards are
correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
who do not meet the required join height criteria. It confirms that validators that have been consumer validators
for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
+ [TestMultiConsumerRewardsDistribution](../../tests/integration/distribution.go#L1142) | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains.Details
It sets up multiple consumer and transfer channels and verifies the distribution of rewards from
various consumer chains to the provider's reward pool. It ensures that the consumer reward pools are
correctly populated and that rewards are properly transferred to the provider. The test checks that
the provider's reward pool balance reflects the accumulated rewards from all consumer chains after
processing IBC transfer packets and relaying committed packets. |
+
+
+# [double_vote.go](../../tests/integration/double_vote.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L21) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
incorrect penalties. |
+ [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
+
+
+# [expired_client.go](../../tests/integration/expired_client.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bond on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
+ [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CVV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
+
+
+# [key_assignment.go](../../tests/integration/key_assignment.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestKeyAssignment](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
+
+
+# [misbehaviour.go](../../tests/integration/misbehaviour.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestHandleConsumerMisbehaviour](../../tests/integration/misbehaviour.go#L24) | TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.Details
The test sets up a CCV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert
that their tokens are adjusted based on the slashing fraction. |
+ [TestGetByzantineValidators](../../tests/integration/misbehaviour.go#L102) | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a header with a subset of the validators on the consumer chain,
then creates a second header (in a variety of different ways),
and checks which validators are considered Byzantine
by calling the GetByzantineValidators function.
The test scenarios are:
* when one of the headers is empty, the function should return an error
* when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
* when the signatures in one of the headers are corrupted, the function should return an error
* when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
* for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
+ [TestCheckMisbehaviour](../../tests/integration/misbehaviour.go#L399) | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or freezing the client. |
+
+
+# [normal_operations.go](../../tests/integration/normal_operations.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestHistoricalInfo](../../tests/integration/normal_operations.go#L19) | TestHistoricalInfo tests the tracking of historical information in the context of new blocks being committed.Details
The test first saves the initial number of CC validators and current block height.
Then it adds a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
After, the test setup creates 2 validators and then calls TrackHistoricalInfo with header block height
Test cases verify that historical information is pruned correctly and that the validator set is updated as expected.
Execution of test cases checks if the historical information is correctly handled and pruned based on the block height. |
+
+
+# [provider_gov_hooks.go](../../tests/integration/provider_gov_hooks.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestAfterPropSubmissionAndVotingPeriodEnded](../../tests/integration/provider_gov_hooks.go#L23) | TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.Details
The test sets up the account that will submit the proposal, and then the proposal is created.
After the proposal is submitted the AfterProposalSubmission hook is triggered
and it should handle the submission of the proposal in the provider module.
Proposal submission is then verified, and lastly AfterProposalVotingPeriodEnded is triggered.
Tests verifies the deletion of the proposal. |
+ [TestGetConsumerAdditionFromProp](../../tests/integration/provider_gov_hooks.go#L58) | TestGetConsumerAdditionFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on various types of proposals to test the behavior of the hook.Details
The test case creates a provider chain, then submits a Proposal with various different types of content.
Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook. |
+
+
+# [slashing.go](../../tests/integration/slashing.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L48) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
+ [TestRelayAndApplyDoubleSignPacket](../../tests/integration/slashing.go#L190) | TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets. handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
packet to confirm that it has been processed.
Note that double-sign slash packets should not affect the provider validator set. |
+ [TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L276) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
+ [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrives a validator from provider chain's validators and cheks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
+ [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing settingDetails
It sets up all CCV channels and expects panic if ccv channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L477) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing moduleDetails
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
It verifies that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L594) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence moduleDetails
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L686) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L770) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+
+
+# [stop_consumer.go](../../tests/integration/stop_consumer.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestStopConsumerChain](../../tests/integration/stop_consumer.go#L24) | TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.Details
It retrieves a validator from the provider chain's validators and then the delegator address.
Then the test sets up test operations, populating the provider chain states using the following operations:
- Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
- Delegate the total bond amount to the chosen validator.
- Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
- Set SlashAck state for the consumer chain ID.
After, the setup operations are executed, and the consumer chain is stopped. Finally, the test checks that the state
associated with the consumer chain is properly cleaned up after it is stopped. |
+ [TestStopConsumerOnChannelClosed](../../tests/integration/stop_consumer.go#L109) | TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
+
+
+# [throttle.go](../../tests/integration/throttle.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestBasicSlashPacketThrottling](../../tests/integration/throttle.go#L32) | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario.Details
It sets up various test cases, all CCV channels and validator powers. Also, the initial value of the slash meter is retrieved, and the test verifies it
has the expected value. All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
The test then creates a slash packet for the first validator and sends it from the consumer to the provider.
Afterward, it asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
Then, a second slash packet is created for a different validator, and the test validates that the second validator is
not jailed after sending the second slash packet. Next, it replenishes the slash meter until it is positive.
Lastly, it asserts that validator 2 is jailed once the slash packet is retried and that it has no more voting power. |
+ [TestMultiConsumerSlashPacketThrottling](../../tests/integration/throttle.go#L212) | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.Details
It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash packets are sent from each of the chosen
consumer bundles to the provider chain. They will each slash a different validator. The test then confirms that the slash packet for the first consumer was handled first,
and afterward, the slash packets for the second and third consumers were bounced. It then checks the total power of validators in the provider
chain to ensure it reflects the expected state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued
The slash meter is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated and verified again.
Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test confirms that all validators are jailed. |
+ [TestPacketSpam](../../tests/integration/throttle.go#L338) | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.Details
It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between downtime and double-sign infractions.
The test then simulates the reception of the 500 packets by the provider chain within the same block. Lastly, it verifies that the first three validators
have been jailed as expected. This confirms that the system correctly processed the slash packets and applied the penalties. |
+ [TestDoubleSignDoesNotAffectThrottling](../../tests/integration/throttle.go#L410) | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
+ [TestSlashingSmallValidators](../../tests/integration/throttle.go#L497) | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.Details
It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
It then sets up default signing information for the three smaller validators to prepare them for being jailed.
The slash packets for the small validators are then constructed and sent.
Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
that the three smaller ones have been penalized and jailed. |
+ [TestSlashMeterAllowanceChanges](../../tests/integration/throttle.go#L576) | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.Details
It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
Lastly, it changes the replenish fraction and asserts the new expected allowance.
TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
+ [TestSlashAllValidators](../../tests/integration/throttle.go#L608) | TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.Details
It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
One slash packet is created for each validator, and then an additional five more for each validator
in order to test the system's ability to handle multiple slashing events in a single block.
The test then receives and processes each slashing packet in the provider chain
and afterward, it checks that all validators are jailed as expected.
Note: This edge case should not occur in practice, but it is useful to validate that
the slash meter can allow any number of slash packets to be handled in a single block when
its allowance is set to "1.0". |
+
+
+# [throttle_retry.go](../../tests/integration/throttle_retry.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestSlashRetries](../../tests/integration/throttle_retry.go#L23) | TestSlashRetries tests the throttling v2 retry logic at an integration level.Details
This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
Two validators are then selected, and their signing information is set up.
The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
It verifies that the packet is sent. Packet is then recived on the provider side and handled. The test then confirms that the first validator has been jailed
and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain. |
+
+
+# [unbonding.go](../../tests/integration/unbonding.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestUndelegationCompletion](../../tests/integration/unbonding.go#L14) | TestUndelegationCompletion tests that undelegations complete after the unbonding period elapses on the provider, regardless of the consumer's stateDetails
It sets up a CCV channel and performs an initial delegation of tokens followed by a partial undelegation
(undelegating 1/4 of the tokens). Then it verifies that the staking unbonding operation is created as expected. Block height is then incremented
on the provider. After this period elapses, the test checks that the unbonding operation has been completed. Finally, it verifies
that the token balances are correctly updated, ensuring that the expected amount of tokens has been returned to the account. |
+
+
+# [valset_update.go](../../tests/integration/valset_update.go)
+ Test Specifications
+
+| Function | Short Description |
+|----------|-------------------|
+ [TestPacketRoundtrip](../../tests/integration/valset_update.go#L21) | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.Details
It sets up CCV and transfer channels. Some tokens are then bonded on the provider side in order to change validator power.
The test then relays a packet from the provider chain to the consumer chain.
Lastly, it relays a matured packet from the consumer chain back to the provider chain. |
+ [TestQueueAndSendVSCMaturedPackets](../../tests/integration/valset_update.go#L54) | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.Details
It sets up CCV channel and then creates and simulates the sending of three VSC packets
from the provider chain to the consumer chain at different times. The first packet is sent, and its processing is validated.
After simulating the passage of one hour, the second packet is sent and its processing is validated. Then after simulating the
passage of 24 more hours, the third packet is sent and its processing is validated. The test then retrieves all packet maturity
times from the consumer, and this is used to check the maturity status of the packets sent earlier.
The test then advances the time so that the first two packets reach their unbonding period, while the third packet does not.
Next it ensures first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
The third packet is still in the store and has not yet been processed for unbonding.
Finally, the test checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state. |
+
+
diff --git a/tests/integration/common.go b/tests/integration/common.go
index 46ef499d01..f6a05b49fa 100644
--- a/tests/integration/common.go
+++ b/tests/integration/common.go
@@ -75,7 +75,7 @@ func (s *CCVTestSuite) getVal(ctx sdk.Context, valAddr sdk.ValAddress) stakingty
func (s *CCVTestSuite) getValConsAddr(tmVal tmtypes.Validator) sdk.ConsAddress {
val, err := tmVal.ToProto()
s.Require().NoError(err)
- pubkey, err := cryptocodec.FromTmProtoPublicKey(val.GetPubKey())
+ pubkey, err := cryptocodec.FromCmtProtoPublicKey(val.GetPubKey())
s.Require().Nil(err)
return sdk.GetConsAddress(pubkey)
}
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 3fa6ac5164..abec9705f9 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -1015,7 +1015,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() {
}
}
-// TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests `AllocateTokensToConsumerValidators` test with
+// TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with
// consumer validators that have different heights.
// @Long Description@
// It sets up a context where the consumer validators have different join heights and verifies that rewards are
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index 609c870957..8365f12e93 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -15,8 +15,9 @@ import (
// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.
// @Long Description@
// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
-// It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the correct
-// slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in incorrect penalties.
+// It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
+// correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
+// incorrect penalties.
func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go
index 409338493e..0bead23606 100644
--- a/tests/integration/expired_client.go
+++ b/tests/integration/expired_client.go
@@ -19,9 +19,9 @@ import (
// TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.
// @Long Description@
-// The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tockens to provider,
+// The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
// sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
-// all packets will be queued. The packet sending and checks are then repeated. After that more tockens are bond on
+// all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bond on
// provider to change validator powers. Finally expired client is upgraded to the consumer
// and all packets are cleared once the consumer client is established.
func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
@@ -88,7 +88,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
// @Long Description@
-// The test sets up a CVV channel and bonds tockens on provider, then it sends CCV packet to consumer and rebonds tockens on provider.
+// The test sets up a CVV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
// Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
// Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded.
func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index 9b31c9f9a5..8bdbff9398 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -19,7 +19,7 @@ import (
// Each test scenarios sets up a provider chain and then assigns a key for a validator.
// However, the assignment comes at different times in the protocol lifecycle.
// The test covers the following scenarios:
-// * successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queud
+// * successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
// * successfully assign the key after the CCV channel initialization is complete
// * successfully assign the key during an same epoch where the validator power changes
// * get an error when assigning the same key twice in the same block by different validators
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 0ee9ff949e..c5fb1f78bb 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -468,8 +468,8 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
// TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched
// when a validator has downtime on the slashing module
// @Long Description@
-// It sets up all CCV channel and send an empty VSC packet, then retrives the address of a validator.
-// Validator signins blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and commited.
+// It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
+// Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
// The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
// Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
// Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
@@ -590,7 +590,7 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
// It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
// evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
// The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
-// it cheks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent
+// it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent
func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// initial setup
suite.SetupCCVChannel(suite.path)
diff --git a/tests/integration/unbonding.go b/tests/integration/unbonding.go
index 56fef0f125..8955497ae4 100644
--- a/tests/integration/unbonding.go
+++ b/tests/integration/unbonding.go
@@ -6,7 +6,7 @@ import (
// TestUndelegationCompletion tests that undelegations complete after
// the unbonding period elapses on the provider, regardless of the consumer's state
-// Long Description:
+// @Long Description@
// It sets up a CCV channel and performs an initial delegation of tokens followed by a partial undelegation
// (undelegating 1/4 of the tokens). Then it verifies that the staking unbonding operation is created as expected. Block height is then incremented
// on the provider. After this period elapses, the test checks that the unbonding operation has been completed. Finally, it verifies
From eec95590c87f4151d53de27a2a4e3530ad45d8ec Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 12:43:24 +0200
Subject: [PATCH 36/88] Improved testing-docs.yml
---
.github/workflows/testing-docs.yml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 1959d658bf..86572010c4 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -45,6 +45,13 @@ jobs:
git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
cp scripts/test_doc/test_documentation.md generated_file.md
if ! diff -q generated_file.md committed_file.md; then
- echo "Documentation for integration tests is out of date. Please run `make testing-docs`!"
+ echo "Documentation for integration tests is out of date. Updating and pushing changes..."
+ cp generated_file.md scripts/test_doc/test_documentation.md
+ git config user.name "github-actions"
+ git config user.email "github-actions@github.com"
+ git add scripts/test_doc/test_documentation.md
+ git commit -m "Update testing documentation"
+ git push origin HEAD
+ echo "Documentation updated and pushed."
exit 1
fi
\ No newline at end of file
From 3d4e8b368f6e4a08099acdac47a38e5bce5cc858 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:03:58 +0200
Subject: [PATCH 37/88] Testing git workflow for testing-docs
---
tests/integration/changeover.go | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b18ea38f4b..e1a034b3fe 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -1,6 +1,8 @@
package integration
import (
+ "fmt"
+
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
@@ -60,3 +62,11 @@ func (suite *CCVTestSuite) TestRecycleTransferChannel() {
channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx())
suite.Require().Len(channels, 2)
}
+
+// TestFoo tests testing-docs test
+// @Long Description@
+// It will be deleted
+func (suite *CCVTestSuite) TestFoo() {
+
+ fmt.Println("Foo test")
+}
From ce1847625178a0c3e9a1e0fdbb96eeec3678d545 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:11:03 +0200
Subject: [PATCH 38/88] Testing git workflow for testing-docs
---
.github/workflows/testing-docs.yml | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 86572010c4..2f94451836 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -46,12 +46,6 @@ jobs:
cp scripts/test_doc/test_documentation.md generated_file.md
if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
- cp generated_file.md scripts/test_doc/test_documentation.md
- git config user.name "github-actions"
- git config user.email "github-actions@github.com"
- git add scripts/test_doc/test_documentation.md
- git commit -m "Update testing documentation"
- git push origin HEAD
- echo "Documentation updated and pushed."
+ echo "Branch name is: ${GITHUB_REF#refs/heads/}"
exit 1
fi
\ No newline at end of file
From 9c16b6411718f68516d65ba44109334532be419b Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:14:30 +0200
Subject: [PATCH 39/88] Testing git workflow for testing-docs
---
.github/workflows/testing-docs.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 2f94451836..ab46e32615 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -46,6 +46,10 @@ jobs:
cp scripts/test_doc/test_documentation.md generated_file.md
if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
- echo "Branch name is: ${GITHUB_REF#refs/heads/}"
+ if [ -n "$GITHUB_HEAD_REF" ]; then
+ branch=$GITHUB_HEAD_REF
+ else
+ branch=${GITHUB_REF#refs/heads/}
+ echo "Branch name is: ${branch}"
exit 1
fi
\ No newline at end of file
From 458a956c56cfca12a457c9e840cd7fd443a47019 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:16:54 +0200
Subject: [PATCH 40/88] Testing git workflow for testing-docs
---
.github/workflows/testing-docs.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index ab46e32615..95cbbe595d 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -48,8 +48,9 @@ jobs:
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
+ echo "Pull request branch name: $branch"
else
branch=${GITHUB_REF#refs/heads/}
- echo "Branch name is: ${branch}"
- exit 1
+ echo "Branch name: $branch"
+ fi
fi
\ No newline at end of file
From 7d0e31affa89c53003178471e30ad84b258960ff Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:24:42 +0200
Subject: [PATCH 41/88] Testing git workflow for testing-docs
---
.github/workflows/testing-docs.yml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 95cbbe595d..b45050b25c 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -46,6 +46,11 @@ jobs:
cp scripts/test_doc/test_documentation.md generated_file.md
if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
+ cp generated_file.md scripts/test_doc/test_documentation.md
+ git config user.name "github-actions"
+ git config user.email "github-actions@github.com"
+ git add scripts/test_doc/test_documentation.md
+ git commit -m "Update testing documentation"
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
echo "Pull request branch name: $branch"
@@ -53,4 +58,6 @@ jobs:
branch=${GITHUB_REF#refs/heads/}
echo "Branch name: $branch"
fi
+ git push origin "$branch"
+ exit 1
fi
\ No newline at end of file
From 48808df8ea65ccca0d89071440628e183e12dc69 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:29:23 +0200
Subject: [PATCH 42/88] Testing git workflow for testing-docs
---
.github/workflows/testing-docs.yml | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index b45050b25c..910c7b4bfe 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -47,10 +47,7 @@ jobs:
if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
cp generated_file.md scripts/test_doc/test_documentation.md
- git config user.name "github-actions"
- git config user.email "github-actions@github.com"
- git add scripts/test_doc/test_documentation.md
- git commit -m "Update testing documentation"
+
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
echo "Pull request branch name: $branch"
@@ -58,6 +55,17 @@ jobs:
branch=${GITHUB_REF#refs/heads/}
echo "Branch name: $branch"
fi
+
+ git fetch origin $branch
+ git checkout $branch
+
+ cp generated_file.md scripts/test_doc/test_documentation.md
+ git config user.name "github-actions"
+ git config user.email "github-actions@github.com"
+ git add scripts/test_doc/test_documentation.md
+ git commit -m "Update testing documentation"
+
git push origin "$branch"
+
exit 1
fi
\ No newline at end of file
From 62279bf17fed6f4118040697b9d73c6ad1ac1011 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 30 Aug 2024 11:30:06 +0000
Subject: [PATCH 43/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 6fa8268181..36bb85e2e6 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L19) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestFoo](../../tests/integration/changeover.go#L69) | TestFoo tests testing-docs testDetails
It will be deleted |
# [democracy.go](../../tests/integration/democracy.go)
From db65fbf61e913ebae9204f7035a2104aabfb3ab9 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:39:55 +0200
Subject: [PATCH 44/88] Testing git workflow for testing-docs
---
scripts/test_doc/test_documentation.md | 3 +--
tests/integration/changeover.go | 10 ----------
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 36bb85e2e6..6fa8268181 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,8 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L19) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
- [TestFoo](../../tests/integration/changeover.go#L69) | TestFoo tests testing-docs testDetails
It will be deleted |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
# [democracy.go](../../tests/integration/democracy.go)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index e1a034b3fe..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -1,8 +1,6 @@
package integration
import (
- "fmt"
-
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
@@ -62,11 +60,3 @@ func (suite *CCVTestSuite) TestRecycleTransferChannel() {
channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx())
suite.Require().Len(channels, 2)
}
-
-// TestFoo tests testing-docs test
-// @Long Description@
-// It will be deleted
-func (suite *CCVTestSuite) TestFoo() {
-
- fmt.Println("Foo test")
-}
From 464fa3b17d30634f30553bc9ff9dac9fd2406888 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:50:17 +0200
Subject: [PATCH 45/88] Testing git workflow for testing-docs
---
tests/integration/changeover.go | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b18ea38f4b..e1a034b3fe 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -1,6 +1,8 @@
package integration
import (
+ "fmt"
+
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
@@ -60,3 +62,11 @@ func (suite *CCVTestSuite) TestRecycleTransferChannel() {
channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx())
suite.Require().Len(channels, 2)
}
+
+// TestFoo tests testing-docs test
+// @Long Description@
+// It will be deleted
+func (suite *CCVTestSuite) TestFoo() {
+
+ fmt.Println("Foo test")
+}
From f9c57602beec2657e9f5a5193d4730b942454541 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 30 Aug 2024 11:51:00 +0000
Subject: [PATCH 46/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 6fa8268181..36bb85e2e6 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L19) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestFoo](../../tests/integration/changeover.go#L69) | TestFoo tests testing-docs testDetails
It will be deleted |
# [democracy.go](../../tests/integration/democracy.go)
From b1ea0ee49b8fba6e8db7a9bb6cd6d585eed65a2c Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 13:55:47 +0200
Subject: [PATCH 47/88] Testing git workflow for testing-docs
---
tests/integration/changeover.go | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index e1a034b3fe..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -1,8 +1,6 @@
package integration
import (
- "fmt"
-
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
@@ -62,11 +60,3 @@ func (suite *CCVTestSuite) TestRecycleTransferChannel() {
channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx())
suite.Require().Len(channels, 2)
}
-
-// TestFoo tests testing-docs test
-// @Long Description@
-// It will be deleted
-func (suite *CCVTestSuite) TestFoo() {
-
- fmt.Println("Foo test")
-}
From 096afcdcc6256428baff246f4a356fd03b25c1bc Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 30 Aug 2024 11:56:23 +0000
Subject: [PATCH 48/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 36bb85e2e6..6fa8268181 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,8 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L19) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
- [TestFoo](../../tests/integration/changeover.go#L69) | TestFoo tests testing-docs testDetails
It will be deleted |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
# [democracy.go](../../tests/integration/democracy.go)
From efc71c2892b63f9ee7e52e163238285992b55401 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 15:35:35 +0200
Subject: [PATCH 49/88] Improved some test descriptions
---
tests/integration/distribution.go | 6 +++---
tests/integration/double_vote.go | 6 +++---
tests/integration/expired_client.go | 6 +++---
tests/integration/key_assignment.go | 2 +-
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index abec9705f9..a5ec37c084 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -404,7 +404,7 @@ func (s *CCVTestSuite) TestEndBlockRD() {
// @Long Description@
// The test first sets up CCV and transmission channels between the provider and consumer chains.
// Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
-// function handles each scenario correctly by ensuring the expected number of token transfers and proper error handling.
+// function handles each scenario correctly by ensuring the expected number of token transfers.
func (s *CCVTestSuite) TestSendRewardsToProvider() {
testCases := []struct {
name string
@@ -549,8 +549,8 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() {
// TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.
// @Long Description@
// The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
-// the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly, rewards are allocated as expected,
-// and the appropriate errors are raised when conditions are not met.
+// the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly and
+// rewards are allocated as expected.
func (s *CCVTestSuite) TestIBCTransferMiddleware() {
var (
data transfertypes.FungibleTokenPacketData
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index 8365f12e93..bf989a8105 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -273,9 +273,9 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
// @Long Description@
// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
-// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
-// handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
-// The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
+// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that it
+// handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these actions.
+// It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go
index 0bead23606..544af1a828 100644
--- a/tests/integration/expired_client.go
+++ b/tests/integration/expired_client.go
@@ -19,9 +19,9 @@ import (
// TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.
// @Long Description@
-// The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
+// The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
// sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
-// all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bond on
+// all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
// provider to change validator powers. Finally expired client is upgraded to the consumer
// and all packets are cleared once the consumer client is established.
func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
@@ -88,7 +88,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
// @Long Description@
-// The test sets up a CVV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
+// The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
// Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
// Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded.
func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index 8bdbff9398..c6ce3fc95f 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -16,7 +16,7 @@ import (
// TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.
// @Long Description@
-// Each test scenarios sets up a provider chain and then assigns a key for a validator.
+// Each test scenario sets up a provider chain and then assigns a key for a validator.
// However, the assignment comes at different times in the protocol lifecycle.
// The test covers the following scenarios:
// * successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
From 833227c2bf8313d9ebbdda7d7aefdcf69a3e71aa Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 30 Aug 2024 13:36:17 +0000
Subject: [PATCH 50/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 6fa8268181..34293ddd74 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -26,8 +26,8 @@
[TestRewardsDistribution](../../tests/integration/distribution.go#L32) | TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
[TestSendRewardsRetries](../../tests/integration/distribution.go#L204) | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
[TestEndBlockRD](../../tests/integration/distribution.go#L285) | Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
- [TestSendRewardsToProvider](../../tests/integration/distribution.go#L408) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers and proper error handling. |
- [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly, rewards are allocated as expected,
and the appropriate errors are raised when conditions are not met. |
+ [TestSendRewardsToProvider](../../tests/integration/distribution.go#L408) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers. |
+ [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly and
rewards are allocated as expected. |
[TestAllocateTokens](../../tests/integration/distribution.go#L744) | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool.Details
The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
and checks that the rewards are allocated as expected. |
[TestAllocateTokensToConsumerValidators](../../tests/integration/distribution.go#L884) | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
[TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights](../../tests/integration/distribution.go#L1026) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with consumer validators that have different heights.Details
It sets up a context where the consumer validators have different join heights and verifies that rewards are
correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
who do not meet the required join height criteria. It confirms that validators that have been consumer validators
for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
@@ -40,7 +40,7 @@
| Function | Short Description |
|----------|-------------------|
[TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L21) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
incorrect penalties. |
- [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
+ [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that it
handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these actions.
It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
# [expired_client.go](../../tests/integration/expired_client.go)
@@ -48,8 +48,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bond on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
- [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CVV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
+ [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
+ [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
# [key_assignment.go](../../tests/integration/key_assignment.go)
@@ -57,7 +57,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestKeyAssignment](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
+ [TestKeyAssignment](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenario sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
# [misbehaviour.go](../../tests/integration/misbehaviour.go)
From 675aaef4ed8022f5abe10bb0aead9539e518c38c Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 15:44:57 +0200
Subject: [PATCH 51/88] Fix minor typos
---
scripts/test_doc/test_documentation.md | 16 ++++++++--------
tests/integration/slashing.go | 4 ++--
tests/integration/throttle_retry.go | 2 +-
x/ccv/types/utils.go | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 6fa8268181..00b0df0f8c 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -26,8 +26,8 @@
[TestRewardsDistribution](../../tests/integration/distribution.go#L32) | TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
[TestSendRewardsRetries](../../tests/integration/distribution.go#L204) | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
[TestEndBlockRD](../../tests/integration/distribution.go#L285) | Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
- [TestSendRewardsToProvider](../../tests/integration/distribution.go#L408) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers and proper error handling. |
- [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly, rewards are allocated as expected,
and the appropriate errors are raised when conditions are not met. |
+ [TestSendRewardsToProvider](../../tests/integration/distribution.go#L408) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers. |
+ [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly and
rewards are allocated as expected. |
[TestAllocateTokens](../../tests/integration/distribution.go#L744) | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool.Details
The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
and checks that the rewards are allocated as expected. |
[TestAllocateTokensToConsumerValidators](../../tests/integration/distribution.go#L884) | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
[TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights](../../tests/integration/distribution.go#L1026) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with consumer validators that have different heights.Details
It sets up a context where the consumer validators have different join heights and verifies that rewards are
correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
who do not meet the required join height criteria. It confirms that validators that have been consumer validators
for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
@@ -40,7 +40,7 @@
| Function | Short Description |
|----------|-------------------|
[TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L21) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
incorrect penalties. |
- [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately,
handles undelegations and redelegations accurately. Then it confirms that the validator’s staking status reflects these actions.
The test also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
+ [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that it
handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these actions.
It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
# [expired_client.go](../../tests/integration/expired_client.go)
@@ -48,8 +48,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CVV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bond on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
- [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CVV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
+ [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
+ [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
# [key_assignment.go](../../tests/integration/key_assignment.go)
@@ -57,7 +57,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestKeyAssignment](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenarios sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
+ [TestKeyAssignment](../../tests/integration/key_assignment.go#L33) | TestKeyAssignment tests key assignments relayed from the provider chain to the consumer chain at different times in the protocol lifecycle.Details
Each test scenario sets up a provider chain and then assigns a key for a validator.
However, the assignment comes at different times in the protocol lifecycle.
The test covers the following scenarios:
* successfully assign the key before the CCV channel initialization is complete, then check that a VSCPacket is indeed queued
* successfully assign the key after the CCV channel initialization is complete
* successfully assign the key during an same epoch where the validator power changes
* get an error when assigning the same key twice in the same block by different validators
* get an error when assigning the same key twice in the same block by the same validator
* successfully assign two different keys in the same block by one validator
* get an error when assigning the same key twice in different blocks by different validators
* get an error when assigning the same key twice in different blocks by the same validator
For each scenario where the key assignment does not produce an error,
the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
the provider and consumer chain can be updated. |
# [misbehaviour.go](../../tests/integration/misbehaviour.go)
@@ -95,7 +95,7 @@
[TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L48) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
[TestRelayAndApplyDoubleSignPacket](../../tests/integration/slashing.go#L190) | TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets. handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
packet to confirm that it has been processed.
Note that double-sign slash packets should not affect the provider validator set. |
[TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L276) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
- [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrives a validator from provider chain's validators and cheks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
+ [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
[TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing settingDetails
It sets up all CCV channels and expects panic if ccv channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
[TestValidatorDowntime](../../tests/integration/slashing.go#L477) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing moduleDetails
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
It verifies that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
[TestValidatorDoubleSigning](../../tests/integration/slashing.go#L594) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence moduleDetails
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
@@ -131,7 +131,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestSlashRetries](../../tests/integration/throttle_retry.go#L23) | TestSlashRetries tests the throttling v2 retry logic at an integration level.Details
This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
Two validators are then selected, and their signing information is set up.
The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
It verifies that the packet is sent. Packet is then recived on the provider side and handled. The test then confirms that the first validator has been jailed
and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain. |
+ [TestSlashRetries](../../tests/integration/throttle_retry.go#L23) | TestSlashRetries tests the throttling v2 retry logic at an integration level.Details
This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
Two validators are then selected, and their signing information is set up.
The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
It verifies that the packet is sent. Packet is then received on the provider side and handled. The test then confirms that the first validator has been jailed
and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain. |
# [unbonding.go](../../tests/integration/unbonding.go)
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index c5fb1f78bb..2dd97450f3 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -60,7 +60,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
tmVal := s.consumerChain.Vals.Validators[0]
val, err := tmVal.ToProto()
s.Require().NoError(err)
- pubkey, err := cryptocodec.FromTmProtoPublicKey(val.GetPubKey())
+ pubkey, err := cryptocodec.FromCmtProtoPublicKey(val.GetPubKey())
s.Require().Nil(err)
consumerConsAddr := providertypes.NewConsumerConsAddress(sdk.GetConsAddress(pubkey))
// map consumer consensus address to provider consensus address
@@ -317,7 +317,7 @@ func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
// TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.
// @Long Description@
-// It retrives a validator from provider chain's validators and cheks if it's bonded.
+// It retrieves a validator from provider chain's validators and checks if it's bonded.
// The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
// The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
// It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go
index f09f8908e6..80c912609f 100644
--- a/tests/integration/throttle_retry.go
+++ b/tests/integration/throttle_retry.go
@@ -15,7 +15,7 @@ import (
// This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
// Two validators are then selected, and their signing information is set up.
// The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
-// It verifies that the packet is sent. Packet is then recived on the provider side and handled. The test then confirms that the first validator has been jailed
+// It verifies that the packet is sent. Packet is then received on the provider side and handled. The test then confirms that the first validator has been jailed
// and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
// that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
// The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
diff --git a/x/ccv/types/utils.go b/x/ccv/types/utils.go
index 05e2387eb8..a363db5c25 100644
--- a/x/ccv/types/utils.go
+++ b/x/ccv/types/utils.go
@@ -54,7 +54,7 @@ func AccumulateChanges(currentChanges, newChanges []abci.ValidatorUpdate) []abci
// TMCryptoPublicKeyToConsAddr converts a TM public key to an SDK public key
// and returns the associated consensus address
func TMCryptoPublicKeyToConsAddr(k tmprotocrypto.PublicKey) (sdk.ConsAddress, error) {
- sdkK, err := cryptocodec.FromTmProtoPublicKey(k)
+ sdkK, err := cryptocodec.FromCmtProtoPublicKey(k)
if err != nil {
return nil, err
}
From a45c6c918ae3c6ea59f67348e87fac2f88c3ba85 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 30 Aug 2024 16:00:05 +0200
Subject: [PATCH 52/88] Finished testing-docs.yml
---
.github/workflows/testing-docs.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 910c7b4bfe..f20f00888d 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -50,10 +50,8 @@ jobs:
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
- echo "Pull request branch name: $branch"
else
branch=${GITHUB_REF#refs/heads/}
- echo "Branch name: $branch"
fi
git fetch origin $branch
From 02b0a3859e1e501b848657cfaddc14a7b2819d1d Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 2 Sep 2024 11:29:06 +0200
Subject: [PATCH 53/88] Fix minor typos
---
scripts/test_doc/test_documentation.md | 30 ++++++++++++-------------
tests/integration/double_vote.go | 8 +++----
tests/integration/expired_client.go | 7 +++---
tests/integration/provider_gov_hooks.go | 2 +-
tests/integration/slashing.go | 17 +++++++-------
tests/integration/throttle.go | 24 +++++++++++---------
6 files changed, 47 insertions(+), 41 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 00b0df0f8c..9511743ea1 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -40,7 +40,7 @@
| Function | Short Description |
|----------|-------------------|
[TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L21) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
incorrect penalties. |
- [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that it
handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these actions.
It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
+ [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L279) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that
it handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these
actions. It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
# [expired_client.go](../../tests/integration/expired_client.go)
@@ -49,7 +49,7 @@
| Function | Short Description |
|----------|-------------------|
[TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L27) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
- [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L94) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded. |
+ [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L95) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on
provider. Then it checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client
is expired. Finally it confirms that while the provider client is expired all packets will be queued and then cleared
once the provider client is upgraded. |
# [key_assignment.go](../../tests/integration/key_assignment.go)
@@ -83,7 +83,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestAfterPropSubmissionAndVotingPeriodEnded](../../tests/integration/provider_gov_hooks.go#L23) | TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.Details
The test sets up the account that will submit the proposal, and then the proposal is created.
After the proposal is submitted the AfterProposalSubmission hook is triggered
and it should handle the submission of the proposal in the provider module.
Proposal submission is then verified, and lastly AfterProposalVotingPeriodEnded is triggered.
Tests verifies the deletion of the proposal. |
+ [TestAfterPropSubmissionAndVotingPeriodEnded](../../tests/integration/provider_gov_hooks.go#L23) | TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.Details
The test sets up the account that will create the proposal, and then the proposal is submitted.
After the proposal is submitted the AfterProposalSubmission hook is triggered
and it should handle the submission of the proposal in the provider module.
Proposal submission is then verified, and lastly AfterProposalVotingPeriodEnded is triggered.
Tests verifies the deletion of the proposal. |
[TestGetConsumerAdditionFromProp](../../tests/integration/provider_gov_hooks.go#L58) | TestGetConsumerAdditionFromProp manually calls the GetConsumerAdditionLegacyPropFromProp hook on various types of proposals to test the behavior of the hook.Details
The test case creates a provider chain, then submits a Proposal with various different types of content.
Then, it tries to get the ConsumerAdditionProposal from the proposal using the hook.
Test cases include a proposal with no messages; a proposal with a transfer message; a proposal with an unrelated legacy proposal;
a proposal with an invalid legacy proposal; and a proposal with a ConsumerAdditionProposal.
In the case of a valid ConsumerAdditionProposal, the test verifies that the proposal is found and returned by the hook. |
@@ -93,14 +93,14 @@
| Function | Short Description |
|----------|-------------------|
[TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L48) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
- [TestRelayAndApplyDoubleSignPacket](../../tests/integration/slashing.go#L190) | TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets. handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
packet to confirm that it has been processed.
Note that double-sign slash packets should not affect the provider validator set. |
+ [TestRelayAndApplyDoubleSignPacket](../../tests/integration/slashing.go#L190) | TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
packet to confirm that it has been processed.
Note that double-sign slash packets should not affect the provider validator set. |
[TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L276) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
[TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
- [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing settingDetails
It sets up all CCV channels and expects panic if ccv channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
- [TestValidatorDowntime](../../tests/integration/slashing.go#L477) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing moduleDetails
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
It verifies that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
- [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L594) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence moduleDetails
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
- [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L686) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
- [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L770) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+ [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L478) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L595) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L687) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L771) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
# [stop_consumer.go](../../tests/integration/stop_consumer.go)
@@ -118,12 +118,12 @@
| Function | Short Description |
|----------|-------------------|
[TestBasicSlashPacketThrottling](../../tests/integration/throttle.go#L32) | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario.Details
It sets up various test cases, all CCV channels and validator powers. Also, the initial value of the slash meter is retrieved, and the test verifies it
has the expected value. All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
The test then creates a slash packet for the first validator and sends it from the consumer to the provider.
Afterward, it asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
Then, a second slash packet is created for a different validator, and the test validates that the second validator is
not jailed after sending the second slash packet. Next, it replenishes the slash meter until it is positive.
Lastly, it asserts that validator 2 is jailed once the slash packet is retried and that it has no more voting power. |
- [TestMultiConsumerSlashPacketThrottling](../../tests/integration/throttle.go#L212) | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.Details
It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash packets are sent from each of the chosen
consumer bundles to the provider chain. They will each slash a different validator. The test then confirms that the slash packet for the first consumer was handled first,
and afterward, the slash packets for the second and third consumers were bounced. It then checks the total power of validators in the provider
chain to ensure it reflects the expected state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued
The slash meter is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated and verified again.
Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test confirms that all validators are jailed. |
- [TestPacketSpam](../../tests/integration/throttle.go#L338) | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.Details
It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between downtime and double-sign infractions.
The test then simulates the reception of the 500 packets by the provider chain within the same block. Lastly, it verifies that the first three validators
have been jailed as expected. This confirms that the system correctly processed the slash packets and applied the penalties. |
- [TestDoubleSignDoesNotAffectThrottling](../../tests/integration/throttle.go#L410) | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
- [TestSlashingSmallValidators](../../tests/integration/throttle.go#L497) | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.Details
It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
It then sets up default signing information for the three smaller validators to prepare them for being jailed.
The slash packets for the small validators are then constructed and sent.
Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
that the three smaller ones have been penalized and jailed. |
- [TestSlashMeterAllowanceChanges](../../tests/integration/throttle.go#L576) | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.Details
It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
Lastly, it changes the replenish fraction and asserts the new expected allowance.
TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
- [TestSlashAllValidators](../../tests/integration/throttle.go#L608) | TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.Details
It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
One slash packet is created for each validator, and then an additional five more for each validator
in order to test the system's ability to handle multiple slashing events in a single block.
The test then receives and processes each slashing packet in the provider chain
and afterward, it checks that all validators are jailed as expected.
Note: This edge case should not occur in practice, but it is useful to validate that
the slash meter can allow any number of slash packets to be handled in a single block when
its allowance is set to "1.0". |
+ [TestMultiConsumerSlashPacketThrottling](../../tests/integration/throttle.go#L214) | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.Details
It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash
packets are sent from each of the chosen consumer bundles to the provider chain. They will each slash a different validator. The test
then confirms that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
third consumers were bounced. It then checks the total power of validators in the provider chain to ensure it reflects the expected
state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued. The slash meter
is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated
and verified again. Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test
confirms that all validators are jailed. |
+ [TestPacketSpam](../../tests/integration/throttle.go#L341) | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.Details
It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between
downtime and double-sign infractions. The test then simulates the reception of the 500 packets by the provider chain within
the same block. Lastly, it verifies that the first three validators have been jailed as expected. This confirms that the
system correctly processed the slash packets and applied the penalties. |
+ [TestDoubleSignDoesNotAffectThrottling](../../tests/integration/throttle.go#L413) | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
+ [TestSlashingSmallValidators](../../tests/integration/throttle.go#L501) | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.Details
It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
It then sets up default signing information for the three smaller validators to prepare them for being jailed.
The slash packets for the small validators are then constructed and sent.
Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
that the three smaller ones have been penalized and jailed. |
+ [TestSlashMeterAllowanceChanges](../../tests/integration/throttle.go#L580) | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.Details
It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
Lastly, it changes the replenish fraction and asserts the new expected allowance.
TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
+ [TestSlashAllValidators](../../tests/integration/throttle.go#L612) | TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.Details
It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
One slash packet is created for each validator, and then an additional five more for each validator
in order to test the system's ability to handle multiple slashing events in a single block.
The test then receives and processes each slashing packet in the provider chain
and afterward, it checks that all validators are jailed as expected.
Note: This edge case should not occur in practice, but it is useful to validate that
the slash meter can allow any number of slash packets to be handled in a single block when
its allowance is set to "1.0". |
# [throttle_retry.go](../../tests/integration/throttle_retry.go)
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index bf989a8105..6e2a3c2dd7 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -270,12 +270,12 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
}
}
-// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
+// TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
// @Long Description@
// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
-// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that it
-// handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these actions.
-// It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
+// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that
+// it handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these
+// actions. It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go
index 544af1a828..34177bf2be 100644
--- a/tests/integration/expired_client.go
+++ b/tests/integration/expired_client.go
@@ -88,9 +88,10 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
// @Long Description@
-// The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on provider.
-// Checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client is expired.
-// Confirms that while the provider client is expired all packets will be queued and then cleared once the provider client is upgraded.
+// The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on
+// provider. Then it checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client
+// is expired. Finally it confirms that while the provider client is expired all packets will be queued and then cleared
+// once the provider client is upgraded.
func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
consumerKeeper := s.consumerApp.GetConsumerKeeper()
diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go
index c0e786042d..9de16a9aeb 100644
--- a/tests/integration/provider_gov_hooks.go
+++ b/tests/integration/provider_gov_hooks.go
@@ -15,7 +15,7 @@ import (
// TestAfterPropSubmissionAndVotingPeriodEnded tests the results of GetProviderInfo method.
// @Long Description@
-// The test sets up the account that will submit the proposal, and then the proposal is created.
+// The test sets up the account that will create the proposal, and then the proposal is submitted.
// After the proposal is submitted the AfterProposalSubmission hook is triggered
// and it should handle the submission of the proposal in the provider module.
// Proposal submission is then verified, and lastly AfterProposalVotingPeriodEnded is triggered.
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 2dd97450f3..a6807607f4 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -175,7 +175,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
s.Require().NoError(err)
}
-// TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets.
+// TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets,
// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
// @Long Description@
// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
@@ -363,9 +363,9 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
suite.Require().Equal(suite.providerCtx().BlockTime().Add(jailDuration), signingInfo.JailedUntil)
}
-// TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting
+// TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.
// @Long Description@
-// It sets up all CCV channels and expects panic if ccv channel is not established via dest channel of packet.
+// It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
// After the correct channelID is added to the packet, a panic shouldn't occur anymore.
// The test creates an instance of SlashPacketData and then verifies correct processing and error handling
// for slashing packets received by the provider chain.
@@ -466,14 +466,15 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
}
// TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched
-// when a validator has downtime on the slashing module
+// when a validator has downtime on the slashing module.
// @Long Description@
// It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
// Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
// The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
-// Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends the pending packets.
-// Then checks if slash record is created and verifies that the consumer queue still contains the packet since no acknowledgment has been received from the provider.
-// It verifies that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block.
+// Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
+// the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
+// acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
+// slashing flag prevents the jailed validator to keep missing block.
func (suite *CCVTestSuite) TestValidatorDowntime() {
// initial setup
suite.SetupCCVChannel(suite.path)
@@ -585,7 +586,7 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
})
}
-// TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module
+// TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.
// @Long Description@
// It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
// evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go
index e841720ec2..04c1d671f4 100644
--- a/tests/integration/throttle.go
+++ b/tests/integration/throttle.go
@@ -203,12 +203,14 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() {
// TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple
// consumers sending slash packets to the provider, with VSC matured packets sprinkled around.
// @Long Description@
-// It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash packets are sent from each of the chosen
-// consumer bundles to the provider chain. They will each slash a different validator. The test then confirms that the slash packet for the first consumer was handled first,
-// and afterward, the slash packets for the second and third consumers were bounced. It then checks the total power of validators in the provider
-// chain to ensure it reflects the expected state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued
-// The slash meter is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated and verified again.
-// Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test confirms that all validators are jailed.
+// It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash
+// packets are sent from each of the chosen consumer bundles to the provider chain. They will each slash a different validator. The test
+// then confirms that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
+// third consumers were bounced. It then checks the total power of validators in the provider chain to ensure it reflects the expected
+// state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued. The slash meter
+// is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated
+// and verified again. Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test
+// confirms that all validators are jailed.
func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
// Setup test
s.SetupAllCCVChannels()
@@ -332,9 +334,10 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
// TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.
// @Long Description@
// It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
-// The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between downtime and double-sign infractions.
-// The test then simulates the reception of the 500 packets by the provider chain within the same block. Lastly, it verifies that the first three validators
-// have been jailed as expected. This confirms that the system correctly processed the slash packets and applied the penalties.
+// The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between
+// downtime and double-sign infractions. The test then simulates the reception of the 500 packets by the provider chain within
+// the same block. Lastly, it verifies that the first three validators have been jailed as expected. This confirms that the
+// system correctly processed the slash packets and applied the penalties.
func (s *CCVTestSuite) TestPacketSpam() {
// Setup ccv channels to all consumers
s.SetupAllCCVChannels()
@@ -486,7 +489,8 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
}
}
-// TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.
+// TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain
+// in a non-throttled manner.
// @Long Description@
// It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
// The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
From cd346d097c18aa1e3f3b4518679539e6f389fc16 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 2 Sep 2024 14:39:36 +0200
Subject: [PATCH 54/88] Rename test from testing-docs.yml
---
.github/workflows/testing-docs.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index f20f00888d..933c6f6b21 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -1,4 +1,4 @@
-name: Check up-to-date testing docs
+name: Generate up-to-date testing docs
on:
workflow_call:
From e52ae4ee6dd38ce4aff7501ae13e4f34e4f85f60 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 4 Sep 2024 13:24:23 +0200
Subject: [PATCH 55/88] Cleaned up TODOs and updated test descriptions
---
scripts/test_doc/test_documentation.md | 2 +-
tests/integration/stop_consumer.go | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 9511743ea1..ddaf103cbf 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -109,7 +109,7 @@
| Function | Short Description |
|----------|-------------------|
[TestStopConsumerChain](../../tests/integration/stop_consumer.go#L24) | TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.Details
It retrieves a validator from the provider chain's validators and then the delegator address.
Then the test sets up test operations, populating the provider chain states using the following operations:
- Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
- Delegate the total bond amount to the chosen validator.
- Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
- Set SlashAck state for the consumer chain ID.
After, the setup operations are executed, and the consumer chain is stopped. Finally, the test checks that the state
associated with the consumer chain is properly cleaned up after it is stopped. |
- [TestStopConsumerOnChannelClosed](../../tests/integration/stop_consumer.go#L109) | TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
+ [TestStopConsumerOnChannelClosed](../../tests/integration/stop_consumer.go#L114) | TestStopConsumerOnChannelClosed tests stopping a consumer chain correctly.Details
This test sets up CCV channel and transfer channel, and sends empty VSC packet.
Then it stops the consumer chain and verifies that the provider chain's channel end is closed
TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
# [throttle.go](../../tests/integration/throttle.go)
diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go
index 71d6a6dc12..291ee8e887 100644
--- a/tests/integration/stop_consumer.go
+++ b/tests/integration/stop_consumer.go
@@ -105,6 +105,11 @@ func (s *CCVTestSuite) TestStopConsumerChain() {
s.checkConsumerChainIsRemoved(firstBundle.Chain.ChainID, true)
}
+// TestStopConsumerOnChannelClosed tests stopping a consumer chain correctly.
+// @Long Description@
+// This test sets up CCV channel and transfer channel, and sends empty VSC packet.
+// Then it stops the consumer chain and verifies that the provider chain's channel end is closed
+//
// TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end
func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() {
// init the CCV channel states
From 281e22652321c26f127c9287aa463840d0bd71bc Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Thu, 5 Sep 2024 09:15:26 +0200
Subject: [PATCH 56/88] Added check in misbehaviour.go
---
tests/integration/misbehaviour.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index ac7ac00b41..96739679eb 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -581,6 +581,10 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() {
for _, tc := range testCases {
s.Run(tc.name, func() {
err := s.providerApp.GetProviderKeeper().CheckMisbehaviour(s.providerCtx(), *tc.misbehaviour)
+ cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), s.path.EndpointA.ClientID)
+ s.Require().True(ok)
+ // verify that the client wasn't frozen
+ s.Require().Zero(cs.(*ibctmtypes.ClientState).FrozenHeight)
if tc.expPass {
s.NoError(err)
} else {
From d35efea0639823cbb41a550e4ac24fadc91ccd3b Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 11 Sep 2024 10:00:59 +0200
Subject: [PATCH 57/88] Fixed integration tests
---
tests/integration/key_assignment.go | 36 +----------------------------
1 file changed, 1 insertion(+), 35 deletions(-)
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index e65300bd1e..beb183a0b6 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -47,9 +47,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
// check that a VSCPacket is queued
s.nextEpoch()
pendingPackets := pk.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId)
@@ -73,9 +70,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
s.nextEpoch()
return nil
@@ -98,9 +92,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
delAddr := s.providerChain.SenderAccount.GetAddress()
delegate(s, delAddr, bondAmt)
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
s.nextEpoch()
return nil
@@ -108,6 +99,7 @@ func (s *CCVTestSuite) TestKeyAssignment() {
},
{
"double same-key assignment in same block by different vals", func(pk *providerkeeper.Keeper) error {
+ // establish CCV channel
// establish CCV channel
s.SetupCCVChannel(s.path)
@@ -118,25 +110,12 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
// same key assignment, but different validator
validator2, _ := generateNewConsumerKey(s, 1)
err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator2, consumerKey)
-
- // check that the key was not assigned to the second validator
- valConsAddr2, getConsAddrErr := validator2.GetConsAddr() // make sure we don't override err, which we are saving for below
- s.Require().NoError(getConsAddrErr)
- actualConsumerKey2, found := pk.GetValidatorConsumerPubKey(s.providerCtx(), s.consumerChain.ChainID, types.NewProviderConsAddress(valConsAddr2))
- s.Require().True(found)
- // the key for the second validator should *not* be the one we just assigned to the first validator
- s.Require().NotEqual(consumerKey, actualConsumerKey2)
-
if err != nil {
return err
}
-
s.nextEpoch()
return nil
@@ -176,9 +155,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
// same key assignment
validator, consumerKey = generateNewConsumerKey(s, 0)
err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey)
@@ -187,7 +163,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
}
// check that the second key was also assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
s.nextEpoch()
@@ -206,9 +181,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
s.nextEpoch()
// same key assignment
@@ -243,9 +215,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
s.nextEpoch()
// same key assignment
@@ -270,9 +239,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the key was assigned correctly
- s.CheckKeyAssignment(validator, consumerKey)
-
s.nextEpoch()
// same key assignment
From 316e735354ebee08afcd4377c8620ee660c559ee Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 11 Sep 2024 13:44:34 +0200
Subject: [PATCH 58/88] Removed additional comments from key_assignment.go
---
tests/integration/key_assignment.go | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index beb183a0b6..2f7e7fa6b3 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -99,7 +99,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
},
{
"double same-key assignment in same block by different vals", func(pk *providerkeeper.Keeper) error {
- // establish CCV channel
// establish CCV channel
s.SetupCCVChannel(s.path)
@@ -162,8 +161,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
return err
}
- // check that the second key was also assigned correctly
-
s.nextEpoch()
return nil
From dd0aeca8645e0f2251e68c9b69393bced68dcff4 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 16 Sep 2024 17:46:38 +0200
Subject: [PATCH 59/88] Removed outdated file descriptions
---
tests/integration/README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index 5ebbd8d97b..756e0ad414 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -11,7 +11,6 @@ Integration tests are categorized into files as follows:
- `distribution.go` - integration tests for the _Reward Distribution_ sub-protocol
- `stop_consumer.go` - integration tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
-- `provider_gov_hooks.go` - integration tests for testing provider hooks
- `query_providerinfo_test.go` - integration tests for testing provider info
- `changeover.go` - integration tests for testing reuse of existing transfer channels
- `double_vote.go` - integration tests for testing the handling of double voting
From d1473e43da9b4bfc6f149241fafeebc7914b6744 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Mon, 16 Sep 2024 15:47:47 +0000
Subject: [PATCH 60/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 42123c1d0c..af65306060 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -88,10 +88,10 @@
[TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L276) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
[TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
[TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
- [TestValidatorDowntime](../../tests/integration/slashing.go#L479) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
- [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L596) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
- [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L688) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
- [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L772) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L489) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L606) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L698) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L782) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
# [stop_consumer.go](../../tests/integration/stop_consumer.go)
From 641208e329d7ea718147995011c5fd5e129b65d5 Mon Sep 17 00:00:00 2001
From: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com>
Date: Mon, 16 Sep 2024 17:48:06 +0200
Subject: [PATCH 61/88] Update .github/workflows/testing-docs.yml
Co-authored-by: Marius Poke
---
.github/workflows/testing-docs.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 933c6f6b21..65bff86add 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -37,6 +37,7 @@ jobs:
Makefile
- name: Generate testing docs
+ if: env.GIT_DIFF
run: make testing-docs
- name: Check for changes
From 9d357b44b9e55acaeca8836bce185e69facbb758 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 16 Sep 2024 17:52:27 +0200
Subject: [PATCH 62/88] Update tests/integration/README.md
---
tests/integration/README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/integration/README.md b/tests/integration/README.md
index 756e0ad414..bc22799e33 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -11,13 +11,13 @@ Integration tests are categorized into files as follows:
- `distribution.go` - integration tests for the _Reward Distribution_ sub-protocol
- `stop_consumer.go` - integration tests for the _Consumer Chain Removal_ sub-protocol
- `normal_operations.go` - integration tests for _normal operations_ of ICS enabled chains
-- `query_providerinfo_test.go` - integration tests for testing provider info
-- `changeover.go` - integration tests for testing reuse of existing transfer channels
-- `double_vote.go` - integration tests for testing the handling of double voting
-- `misbehavior.go` - integration tests for testing the handling of misbehaviors
-- `partial_set_security_test.go` - integration tests for testing the partial set security
-- `expired_client.go` - integration tests for testing expired clients
-- `key_assignment.go` - integration tests for testing key assignment
+- `query_providerinfo_test.go` - integration tests for the `GetProviderInfo` method
+- `changeover.go` - integration tests for reuse of existing transfer channels
+- `double_vote.go` - integration tests for the handling of double voting
+- `misbehavior.go` - integration tests for the handling of misbehaviors
+- `partial_set_security_test.go` - integration tests for the partial set security
+- `expired_client.go` - integration tests for expired clients
+- `key_assignment.go` - integration tests for key assignment
- `instance_test.go` - ties the integration test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback
To run the integration tests defined in this repo on any arbitrary consumer and provider implementation, copy the pattern exemplified in `instance_test.go` and `specific_setup.go`
From cd3dd199069f00d470ce9588c747bee867acae00 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Mon, 16 Sep 2024 17:57:35 +0200
Subject: [PATCH 63/88] Removed TestRelayAndApplyDoubleSignPacket test from
slashing.go
---
tests/integration/slashing.go | 93 -----------------------------------
1 file changed, 93 deletions(-)
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 7b989142c7..2be06818ad 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -175,99 +175,6 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
s.Require().NoError(err)
}
-// TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets,
-// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
-// @Long Description@
-// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
-// The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
-// Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
-// The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
-// timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
-// and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
-// packet to confirm that it has been processed.
-//
-// Note that double-sign slash packets should not affect the provider validator set.
-func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() {
- // Setup CCV channel for all instantiated consumers
- s.SetupAllCCVChannels()
-
- providerStakingKeeper := s.providerApp.GetTestStakingKeeper()
- providerKeeper := s.providerApp.GetProviderKeeper()
- providerSlashingKeeper := s.providerApp.GetTestSlashingKeeper()
-
- validatorsPerChain := len(s.consumerChain.Vals.Validators)
-
- // pick first consumer validator
- tmVal := s.consumerChain.Vals.Validators[0]
- val, err := tmVal.ToProto()
- s.Require().NoError(err)
- pubkey, err := cryptocodec.FromCmtProtoPublicKey(val.GetPubKey())
- s.Require().Nil(err)
- consumerConsAddr := providertypes.NewConsumerConsAddress(sdk.GetConsAddress(pubkey))
- // map consumer consensus address to provider consensus address
- providerConsAddr, found := providerKeeper.GetValidatorByConsumerAddr(
- s.providerCtx(),
- s.getFirstBundle().ConsumerId,
- consumerConsAddr)
- s.Require().True(found)
-
- stakingVal, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
- s.Require().NoError(err)
- valOldBalance := stakingVal.Tokens
-
- // Setup first val with mapped consensus address to be jailed on provider by setting signing info
- // convert validator to TM type
- pk, err := stakingVal.ConsPubKey()
- s.Require().NoError(err)
- tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk)
- s.Require().NoError(err)
- s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction)))
-
- // Send slash packet from the first consumer chain
- var (
- timeoutHeight = clienttypes.Height{}
- timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano())
- )
- slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1)
- packet := sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData())
-
- // Advance a few more blocks to make sure any voting power changes would be reflected
- s.providerChain.NextBlock()
- s.providerChain.NextBlock()
- s.providerChain.NextBlock()
-
- // Confirm validator was NOT removed from provider validator set
- s.Require().Len(s.providerChain.Vals.Validators, validatorsPerChain)
-
- // Get staking keeper's validator obj after the relayed slash packet
- stakingValAfter, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
- s.Require().NoError(err)
-
- // check that the validator's tokens were NOT slashed on provider
- valNewBalance := stakingValAfter.GetTokens()
- s.Require().Equal(valOldBalance, valNewBalance)
-
- // Get signing info for the validator
- valSignInfo, err := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr())
- s.Require().NoError(err)
-
- // check that the validator's unjailing time is NOT updated on provider
- s.Require().Zero(valSignInfo.JailedUntil)
-
- // check that the validator is not jailed and still bonded on provider
- s.Require().False(stakingValAfter.Jailed)
- s.Require().Equal(stakingValAfter.Status, stakingtypes.Bonded)
-
- // check that validator was NOT tombstoned on provider
- s.Require().False(valSignInfo.Tombstoned)
-
- // check that slashing packet gets acknowledged successfully,
- // provider returns V1Result acks for double sign packets
- ack := channeltypes.NewResultAcknowledgement(ccv.V1Result)
- err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement())
- s.Require().NoError(err)
-}
-
// TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.
// @Long Description@
// It sets up a provider and consumer chain, with channel initialization between them performed,
From 1f23596d05615a245799706ea7f1859834ac3ce8 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Mon, 16 Sep 2024 15:58:12 +0000
Subject: [PATCH 64/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index af65306060..e76e2e7b30 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -84,14 +84,13 @@
| Function | Short Description |
|----------|-------------------|
[TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L48) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
- [TestRelayAndApplyDoubleSignPacket](../../tests/integration/slashing.go#L190) | TestRelayAndApplyDoubleSignPacket tests correct processing of double sign slashing packets, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
The double sign slashing packet is then created and sent from the consumer chain to the provider chain.
timeout and sets infraction type to be double signed. The test then verifies that the validator wasn't slashed, that its status is still bonded,
and that the unjailing time and tombstone status are correctly managed. Provider chain then sends an acknowledgment for the slashing
packet to confirm that it has been processed.
Note that double-sign slash packets should not affect the provider validator set. |
- [TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L276) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
- [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L326) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
- [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L372) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
- [TestValidatorDowntime](../../tests/integration/slashing.go#L489) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
- [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L606) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
- [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L698) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
- [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L782) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+ [TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L183) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
+ [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L233) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
+ [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L279) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L396) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L513) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L605) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L689) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
# [stop_consumer.go](../../tests/integration/stop_consumer.go)
From 9d85473d55fb6f693f614c07afbaaa8e1208809d Mon Sep 17 00:00:00 2001
From: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com>
Date: Mon, 16 Sep 2024 17:58:50 +0200
Subject: [PATCH 65/88] Update .github/workflows/testing-docs.yml
Co-authored-by: Marius Poke
---
.github/workflows/testing-docs.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 65bff86add..7a1f4797e7 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -1,4 +1,4 @@
-name: Generate up-to-date testing docs
+name: Generate testing docs
on:
workflow_call:
From a888ae6d271a02df2233a7050c3e73e2613cf2f0 Mon Sep 17 00:00:00 2001
From: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com>
Date: Tue, 17 Sep 2024 08:12:42 +0200
Subject: [PATCH 66/88] Update scripts/test_doc/test_documentation.md
Co-authored-by: Marius Poke
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index e76e2e7b30..be5ef43e30 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -1,6 +1,6 @@
# Test Documentation
-# [changeover.go](../../tests/integration/changeover.go)
+## [changeover.go](../../tests/integration/changeover.go)
Test Specifications
| Function | Short Description |
From 96c2ac45a365b196373021dea407d055decf9c85 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Tue, 17 Sep 2024 06:13:32 +0000
Subject: [PATCH 67/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index be5ef43e30..e76e2e7b30 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -1,6 +1,6 @@
# Test Documentation
-## [changeover.go](../../tests/integration/changeover.go)
+# [changeover.go](../../tests/integration/changeover.go)
Test Specifications
| Function | Short Description |
From 43cfa7a08cd3f09393b91d4ce08abced122eb8e4 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Tue, 17 Sep 2024 11:48:46 +0200
Subject: [PATCH 68/88] Integration test comments refactored
---
scripts/test_doc/test_documentation.md | 82 ++++++++--------
tests/integration/democracy.go | 26 ++---
tests/integration/distribution.go | 97 ++++++++++---------
tests/integration/double_vote.go | 19 ++--
tests/integration/expired_client.go | 19 ++--
tests/integration/key_assignment.go | 9 --
tests/integration/misbehaviour.go | 55 ++++++-----
tests/integration/normal_operations.go | 10 +-
.../integration/partial_set_security_test.go | 9 +-
tests/integration/query_providerinfo_test.go | 4 +-
tests/integration/slashing.go | 83 +++++++++-------
tests/integration/stop_consumer.go | 12 +--
tests/integration/throttle.go | 76 ++++++++-------
tests/integration/throttle_retry.go | 20 ++--
tests/integration/unbonding.go | 10 +-
tests/integration/valset_update.go | 28 +++---
16 files changed, 292 insertions(+), 267 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index e76e2e7b30..c08c00038b 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -13,9 +13,9 @@
| Function | Short Description |
|----------|-------------------|
- [TestDemocracyRewardsDistribution](../../tests/integration/democracy.go#L78) | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Sets up a democracy consumer chain
* Creates a new block
* Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions |
- [TestDemocracyGovernanceWhitelisting](../../tests/integration/democracy.go#L194) | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the auth and mint module parameters
* Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submits a proposal containing changes *only* to the mint module parameters
* Checks that the proposal is executed, since the change to the mint module is whitelisted.
* Submits a proposal containing changes *only* to the auth module parameters
* Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
- [TestDemocracyMsgUpdateParams](../../tests/integration/democracy.go#L294) | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Sets up a democracy consumer chain
* Submits a proposal containing changes to the consumer module parameters
* Checks that the proposal is executed, and the parameters are updated |
+ [TestDemocracyRewardsDistribution](../../tests/integration/democracy.go#L78) | TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.Details
* Set up a democracy consumer chain.
* Create a new block.
* Check that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions. |
+ [TestDemocracyGovernanceWhitelisting](../../tests/integration/democracy.go#L194) | TestDemocracyGovernanceWhitelisting checks that only whitelisted governance proposals can be executed on democracy consumer chains.Details
For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
* Set up a democracy consumer chain.
* Submit a proposal containing changes to the auth and mint module parameters.
* Check that the proposal is not executed, since the change to the auth module is not whitelisted.
* Submit a proposal containing changes *only* to the mint module parameters.
* Check that the proposal is executed, since the change to the mint module is whitelisted.
* Submit a proposal containing changes *only* to the auth module parameters.
* Check that again, the proposal is not executed, since the change to the auth module is not whitelisted. |
+ [TestDemocracyMsgUpdateParams](../../tests/integration/democracy.go#L294) | TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.Details
* Set up a democracy consumer chain.
* Submit a proposal containing changes to the consumer module parameters.
* Check that the proposal is executed, and the parameters are updated. |
# [distribution.go](../../tests/integration/distribution.go)
@@ -23,15 +23,15 @@
| Function | Short Description |
|----------|-------------------|
- [TestRewardsDistribution](../../tests/integration/distribution.go#L33) | TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
The test sets up a provider and consumer chain and completes the channel initialization.
Then, it sends tokens into the FeeCollector on the consumer chain,
and checks that these tokens distributed correctly across the provider and consumer chain.
It first checks that the tokens are distributed purely on the consumer chain,
then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
It does not whitelist the consumer denom, so the tokens are expected to stay in
the ConsumerRewardsPool on the provider chain. |
- [TestSendRewardsRetries](../../tests/integration/distribution.go#L205) | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
The test sets up a provider and consumer chain and completes the channel initialization.
It fills the fee pool on the consumer chain,
then corrupts the transmission channel and tries to send rewards to the provider chain,
which should fail.
The test then advances the block height to trigger a retry of the reward transmission,
and confirms that this time, the transmission is successful. |
- [TestEndBlockRD](../../tests/integration/distribution.go#L286) | Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
- [TestSendRewardsToProvider](../../tests/integration/distribution.go#L409) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
The test first sets up CCV and transmission channels between the provider and consumer chains.
Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers. |
- [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L555) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly and
rewards are allocated as expected. |
- [TestAllocateTokens](../../tests/integration/distribution.go#L745) | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool.Details
The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
and checks that the rewards are allocated as expected. |
- [TestAllocateTokensToConsumerValidators](../../tests/integration/distribution.go#L885) | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
The test exclusively uses the provider chain.
It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
The test then checks that the expected number of tokens were allocated to the validators.
The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
- [TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights](../../tests/integration/distribution.go#L1028) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with consumer validators that have different heights.Details
It sets up a context where the consumer validators have different join heights and verifies that rewards are
correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
who do not meet the required join height criteria. It confirms that validators that have been consumer validators
for some time receive rewards, while validators that recently became consumer validators do not receive rewards. |
- [TestMultiConsumerRewardsDistribution](../../tests/integration/distribution.go#L1146) | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains.Details
It sets up multiple consumer and transfer channels and verifies the distribution of rewards from
various consumer chains to the provider's reward pool. It ensures that the consumer reward pools are
correctly populated and that rewards are properly transferred to the provider. The test checks that
the provider's reward pool balance reflects the accumulated rewards from all consumer chains after
processing IBC transfer packets and relaying committed packets. |
+ [TestRewardsDistribution](../../tests/integration/distribution.go#L32) | TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.Details
* Set up a provider and consumer chain and completes the channel initialization.
* Send tokens into the FeeCollector on the consumer chain,
and check that these tokens distributed correctly across the provider and consumer chain.
* Check that the tokens are distributed purely on the consumer chain,
then advance the block height to make the consumer chain send a packet with rewards to the provider chain.
* Don't whitelist the consumer denom, so that the tokens stay in the ConsumerRewardsPool on the provider chain. |
+ [TestSendRewardsRetries](../../tests/integration/distribution.go#L202) | TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocksDetails
* Set up a provider and consumer chain and complete the channel initialization.
* Fill the fee pool on the consumer chain, then corrupt the transmission channel
and try to send rewards to the provider chain, which should fail.
* Advance the block height to trigger a retry of the reward transmission, and confirm that this time, the transmission is successful. |
+ [TestEndBlockRD](../../tests/integration/distribution.go#L284) | TestEndBlockRD tests that the last transmission block height is correctly updated after the expected number of block have passed.Details
* Set up CCV and transmission channels between the provider and consumer chains.
* Fill the fee pool on the consumer chain, prepare the system for reward
distribution, and optionally corrupt the transmission channel to simulate failure scenarios.
* After advancing the block height, verify whether the LBTH is updated correctly
and if the escrow balance changes as expected.
* Check that the IBC transfer states are discarded if the reward distribution
to the provider has failed.
Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking. |
+ [TestSendRewardsToProvider](../../tests/integration/distribution.go#L407) | TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.Details
* Set up CCV and transmission channels between the provider and consumer chains.
* Verify the SendRewardsToProvider() function under various scenarios and checks if the
function handles each scenario correctly by ensuring the expected number of token transfers. |
+ [TestIBCTransferMiddleware](../../tests/integration/distribution.go#L554) | TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.Details
* Set up IBC and transfer channels.
* Simulate various scenarios of token transfers from the provider chain to
the consumer chain, and evaluate how the middleware processes these transfers.
* Ensure that token transfers are handled correctly and rewards are allocated as expected. |
+ [TestAllocateTokens](../../tests/integration/distribution.go#L744) | TestAllocateTokens is a happy-path test of the consumer rewards pool allocation to opted-in validators and the community pool.Details
* Set up a provider chain and multiple consumer chains, and initialize the channels between them.
* Fund the consumer rewards pools on the provider chain and allocate rewards to the consumer chains.
* Begin a new block to cause rewards to be distributed to the validators and the community pool,
and check that the rewards are allocated as expected. |
+ [TestAllocateTokensToConsumerValidators](../../tests/integration/distribution.go#L884) | TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.Details
* The test exclusively uses the provider chain.
* Set up a current set of consumer validators, then call the AllocateTokensToConsumerValidators
function to allocate a number of tokens to the validators.
* Check that the expected number of tokens were allocated to the validators.
* The test covers the following scenarios:
- The tokens to be allocated are empty
- The consumer validator set is empty
- The tokens are allocated to a single validator
- The tokens are allocated to multiple validators |
+ [TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights](../../tests/integration/distribution.go#L1029) | TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with consumer validators that have different heights.Details
* Set up a context where the consumer validators have different join heights and verify that rewards are
correctly allocated only to validators who have been active long enough.
* Ensure that rewards are evenly distributed among eligible validators, that validators
can withdraw their rewards correctly, and that no rewards are allocated to validators
who do not meet the required join height criteria.
* Confirm that validators that have been consumer validators for some time receive rewards,
while validators that recently became consumer validators do not receive rewards. |
+ [TestMultiConsumerRewardsDistribution](../../tests/integration/distribution.go#L1149) | TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains.Details
* Set up multiple consumer and transfer channels and verify the distribution of rewards from
various consumer chains to the provider's reward pool.
* Ensure that the consumer reward pools are correctly populated
and that rewards are properly transferred to the provider.
* Checks that the provider's reward pool balance reflects the accumulated
rewards from all consumer chains after processing IBC transfer packets and relaying
committed packets. |
# [double_vote.go](../../tests/integration/double_vote.go)
@@ -39,8 +39,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L22) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
incorrect penalties. |
- [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L280) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that
it handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these
actions. It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected. |
+ [TestHandleConsumerDoubleVoting](../../tests/integration/double_vote.go#L23) | TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.Details
* Set up a CCV channel.
* Create various double voting scenarios and submit those to the provider chain.
* Check if the provider chain correctly processes the evidence, jail and tombstone validators as needed, and apply the
correct slashing penalties.
* Verify that invalid evidence is properly rejected and does not result in incorrect penalties. |
+ [TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations](../../tests/integration/double_vote.go#L283) | TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.Details
* Set up a CCV channel.
* Create various double voting scenarios and submit those to the provider chain.
* Verify that the evidence is processed correctly.
* Ensure that the provider chain slashes the validator appropriately, and that it handles undelegations and redelegations accurately.
* Confirm that the validator’s staking status reflects these actions.
* Check if the slashing penalties are applied correctly and update the validator’s balance and delegations as expected. |
# [expired_client.go](../../tests/integration/expired_client.go)
@@ -48,8 +48,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L28) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
provider to change validator powers. Finally expired client is upgraded to the consumer
and all packets are cleared once the consumer client is established. |
- [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L96) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on
provider. Then it checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client
is expired. Finally it confirms that while the provider client is expired all packets will be queued and then cleared
once the provider client is upgraded. |
+ [TestVSCPacketSendExpiredClient](../../tests/integration/expired_client.go#L29) | TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.Details
* Set up a CCV channel and expire the client on consumer chain.
* Bond tokens to provider, send CCV packet to consumer and check pending packets.
* While the consumer client is expired (or inactive for some reason) all packets will be queued.
* The packet sending and checks are then repeated.
* More tokens are bonded on provider to change validator powers.
* Upgrade expired client to the consumer and all packets are cleared once the consumer client is established. |
+ [TestConsumerPacketSendExpiredClient](../../tests/integration/expired_client.go#L99) | TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.Details
* Set up a CCV channel and bond tokens on provider.
* Send CCV packet to consumer and rebond tokens on provider.
* Check for pending VSC packets and relay all VSC packets to consumer.
* The provider client is then expired.
* Confirm that while the provider client is expired all packets will be queued and then cleared
once the provider client is upgraded. |
# [key_assignment.go](../../tests/integration/key_assignment.go)
@@ -65,9 +65,9 @@
| Function | Short Description |
|----------|-------------------|
- [TestHandleConsumerMisbehaviour](../../tests/integration/misbehaviour.go#L25) | TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.Details
The test sets up a CCV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert
that their tokens are adjusted based on the slashing fraction. |
- [TestGetByzantineValidators](../../tests/integration/misbehaviour.go#L103) | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a header with a subset of the validators on the consumer chain,
then creates a second header (in a variety of different ways),
and checks which validators are considered Byzantine
by calling the GetByzantineValidators function.
The test scenarios are:
* when one of the headers is empty, the function should return an error
* when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
* when the signatures in one of the headers are corrupted, the function should return an error
* when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
* for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
- [TestCheckMisbehaviour](../../tests/integration/misbehaviour.go#L400) | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
The test sets up a provider and consumer chain.
It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
The test scenarios are:
* both headers are identical (returns an error)
* the misbehaviour is not for the consumer chain (returns an error)
* passing an invalid client id (returns an error)
* passing a misbehaviour with different header height (returns an error)
* passing a misbehaviour older than the min equivocation evidence height (returns an error)
* one header of the misbehaviour has insufficient voting power (returns an error)
* passing a valid misbehaviour (no error)
It does not test actually submitting the misbehaviour to the chain or freezing the client. |
+ [TestHandleConsumerMisbehaviour](../../tests/integration/misbehaviour.go#L25) | TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.Details
* Set up a CCV channel and send an empty VSC packet to ensure that the consumer client revision height is greater than 0.
* Construct a Misbehaviour object with two conflicting headers and process the equivocation evidence.
* Verify that the provider chain correctly processes this misbehavior.
* Ensure that all involved validators are jailed, tombstoned, and slashed according to the expected outcomes.
* Assert that their tokens are adjusted based on the slashing fraction. |
+ [TestGetByzantineValidators](../../tests/integration/misbehaviour.go#L101) | TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.Details
* Set up a provider and consumer chain.
* Create a header with a subset of the validators on the consumer chain, then create a second header (in a variety of different ways),
and check which validators are considered Byzantine by calling the GetByzantineValidators function.
* The test scenarios are:
- when one of the headers is empty, the function should return an error
- when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
- when the signatures in one of the headers are corrupted, the function should return an error
- when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
- for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine |
+ [TestCheckMisbehaviour](../../tests/integration/misbehaviour.go#L399) | TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.Details
* Set up a provider and consumer chain.
* Create a valid client header and then create a misbehaviour by creating a second header in a variety of different ways.
* Check that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
* The test scenarios are:
- both headers are identical (returns an error)
- the misbehaviour is not for the consumer chain (returns an error)
- passing an invalid client id (returns an error)
- passing a misbehaviour with different header height (returns an error)
- passing a misbehaviour older than the min equivocation evidence height (returns an error)
- one header of the misbehaviour has insufficient voting power (returns an error)
- passing a valid misbehaviour (no error)
* Test does not test actually submitting the misbehaviour to the chain or freezing the client. |
# [normal_operations.go](../../tests/integration/normal_operations.go)
@@ -75,7 +75,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestHistoricalInfo](../../tests/integration/normal_operations.go#L19) | TestHistoricalInfo tests the tracking of historical information in the context of new blocks being committed.Details
The test first saves the initial number of CC validators and current block height.
Then it adds a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
After, the test setup creates 2 validators and then calls TrackHistoricalInfo with header block height
Test cases verify that historical information is pruned correctly and that the validator set is updated as expected.
Execution of test cases checks if the historical information is correctly handled and pruned based on the block height. |
+ [TestHistoricalInfo](../../tests/integration/normal_operations.go#L19) | TestHistoricalInfo tests the tracking of historical information in the context of new blocks being committed.Details
* Save the initial number of CC validators and current block height.
* Add a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
* Create 2 validators and then call TrackHistoricalInfo with header block height.
* Verify that historical information is pruned correctly and that the validator set is updated as expected.
* Check if the historical information is correctly handled and pruned based on the block height. |
# [slashing.go](../../tests/integration/slashing.go)
@@ -83,14 +83,14 @@
| Function | Short Description |
|----------|-------------------|
- [TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L48) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
- [TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L183) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
It sets up a provider and consumer chain, with channel initialization between them performed,
then sends a slash packet with randomized fields from the consumer to the provider.
The provider processes the packet |
- [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L233) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
It retrieves a validator from provider chain's validators and checks if it's bonded.
The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
- [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L279) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
After the correct channelID is added to the packet, a panic shouldn't occur anymore.
The test creates an instance of SlashPacketData and then verifies correct processing and error handling
for slashing packets received by the provider chain. |
- [TestValidatorDowntime](../../tests/integration/slashing.go#L396) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
slashing flag prevents the jailed validator to keep missing block. |
- [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L513) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent |
- [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L605) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty. |
- [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L689) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+ [TestRelayAndApplyDowntimePacket](../../tests/integration/slashing.go#L51) | TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider, handled by provider, with a VSC and jailing eventually effective on consumer and provider.Details
* Set up CCV channels and retrieve consumer validators.
* Select a validator and create its consensus address.
* Retrieve the provider consensus address that corresponds to the consumer consensus address of the validator.
* The validator's current state is also retrieved, including its token balance,
* Set validator's signing information is to ensure it will be jailed for downtime.
* Create the slashing packet and send it from the consumer chain to the provider chain with a specified timeout.
* Receive the packet and verify that the validator was removed from the provider validator set.
* Relay VSC packets from the provider chain to each consumer chain and verify that the consumer chains correctly process these packets.
* Check the validator's balance and status on the provider chain to ensure it was jailed correctly but not slashed,
and its unjailing time is updated.
* Reset the outstanding downtime flag on the consumer chain, and ensure that the consumer
chain acknowledges receipt of the packet from the provider chain.
Note: This method does not test the actual slash packet sending logic for downtime
and double-signing, see TestValidatorDowntime and TestValidatorDoubleSigning for
those types of tests. |
+ [TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L186) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
* Set up a provider and consumer chain, with channel initialization between them performed.
* Send a slash packet with randomized fields from the consumer to the provider.
* The provider processes the packet |
+ [TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L237) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
* Retrieve a validator from provider chain's validators and checks if it's bonded.
* Set tThe signing information for the validator.
* The provider processes the downtime slashing packet from the consumer.
* Check that the validator has been jailed as a result of the downtime slashing packet being processed.
* Verify that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
+ [TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L283) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
* Set up all CCV channels and expect panic if the channel is not established via dest channel of packet.
* After the correct channelID is added to the packet, a panic shouldn't occur anymore.
* Create an instance of SlashPacketData and then verify correct processing and error handling
for slashing packets received by the provider chain. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L391) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
* Set up all CCV channel and send an empty VSC packet, then retrieve the address of a validator.
* Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
* Simulate the validator missing blocks and then verify that the validator is jailed and the jailed time is correctly updated.
* Ensure that the missed block counters are reset.
* Check that there is a pending slash packet in the queue, and then send the pending packets.
* Check if slash record is created and verify that the consumer queue still contains the packet since no
acknowledgment has been received from the provider.
* Verify that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L511) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
* Set up all CCV channel and send an empty VSC packet.
* Create a validator public key and address.
* Set the infraction parameters and create evidence of double signing.
* Add validator signing-info are also to the store and construct the slash packet.
* Simulate double signing and sends the slash packet.
* Verify the handling of slash packet, and check if slash record was created and if it's waiting for reply.
* Confirm that the queue is not cleared and the slash packet is sent. |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L605) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
* Set up all CCV channels and then queue slash packets for both downtime and double-signing infractions.
* Check that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
* Prepare the CCV channel for sending actual slash packets.
* Send the slash packets and check that the outstanding downtime flags are correctly set for validators that were slashed
for downtime infractions.
* Ensure that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L690) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
* Check that no pending packets exist and that there's no slash record found.
* Triggers a slashing event which queues a slash packet.
* The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
*Verify that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
# [stop_consumer.go](../../tests/integration/stop_consumer.go)
@@ -98,8 +98,8 @@
| Function | Short Description |
|----------|-------------------|
- [TestStopConsumerChain](../../tests/integration/stop_consumer.go#L26) | TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.Details
It retrieves a validator from the provider chain's validators and then the delegator address.
Then the test sets up test operations, populating the provider chain states using the following operations:
- Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
- Delegate the total bond amount to the chosen validator.
- Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
- Set SlashAck state for the consumer chain ID.
After, the setup operations are executed, and the consumer chain is stopped. Finally, the test checks that the state
associated with the consumer chain is properly cleaned up after it is stopped. |
- [TestStopConsumerOnChannelClosed](../../tests/integration/stop_consumer.go#L117) | TestStopConsumerOnChannelClosed tests stopping a consumer chain correctly.Details
This test sets up CCV channel and transfer channel, and sends empty VSC packet.
Then it stops the consumer chain and verifies that the provider chain's channel end is closed
TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
+ [TestStopConsumerChain](../../tests/integration/stop_consumer.go#L26) | TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.Details
* Retrieve a validator from the provider chain's validators and then the delegator address.
* Set up test operations, populating the provider chain states using the following operations:
- Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
- Delegate the total bond amount to the chosen validator.
- Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
- Set SlashAck state for the consumer chain ID.
* After, the setup operations are executed, and the consumer chain is stopped.
* Check that the state associated with the consumer chain is properly cleaned up after it is stopped. |
+ [TestStopConsumerOnChannelClosed](../../tests/integration/stop_consumer.go#L117) | TestStopConsumerOnChannelClosed tests stopping a consumer chain correctly.Details
* Set up CCV channel and transfer channel, and send empty VSC packet.
* Stop the consumer chain and verify that the provider chain's channel end is closed.
TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end |
# [throttle.go](../../tests/integration/throttle.go)
@@ -107,13 +107,13 @@
| Function | Short Description |
|----------|-------------------|
- [TestBasicSlashPacketThrottling](../../tests/integration/throttle.go#L33) | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario.Details
It sets up various test cases, all CCV channels and validator powers. Also, the initial value of the slash meter is retrieved, and the test verifies it
has the expected value. All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
The test then creates a slash packet for the first validator and sends it from the consumer to the provider.
Afterward, it asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
Then, a second slash packet is created for a different validator, and the test validates that the second validator is
not jailed after sending the second slash packet. Next, it replenishes the slash meter until it is positive.
Lastly, it asserts that validator 2 is jailed once the slash packet is retried and that it has no more voting power. |
- [TestMultiConsumerSlashPacketThrottling](../../tests/integration/throttle.go#L215) | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.Details
It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash
packets are sent from each of the chosen consumer bundles to the provider chain. They will each slash a different validator. The test
then confirms that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
third consumers were bounced. It then checks the total power of validators in the provider chain to ensure it reflects the expected
state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued. The slash meter
is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated
and verified again. Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test
confirms that all validators are jailed. |
- [TestPacketSpam](../../tests/integration/throttle.go#L342) | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.Details
It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between
downtime and double-sign infractions. The test then simulates the reception of the 500 packets by the provider chain within
the same block. Lastly, it verifies that the first three validators have been jailed as expected. This confirms that the
system correctly processed the slash packets and applied the penalties. |
- [TestDoubleSignDoesNotAffectThrottling](../../tests/integration/throttle.go#L414) | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
It then sends 500 double sign slash packets from a consumer to the provider in a single block.
The test confirms that the slash meter is not affected by this, and that no validators are jailed. |
- [TestSlashingSmallValidators](../../tests/integration/throttle.go#L502) | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.Details
It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
It then sets up default signing information for the three smaller validators to prepare them for being jailed.
The slash packets for the small validators are then constructed and sent.
Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
that the three smaller ones have been penalized and jailed. |
- [TestSlashMeterAllowanceChanges](../../tests/integration/throttle.go#L581) | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.Details
It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
Lastly, it changes the replenish fraction and asserts the new expected allowance.
TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
- [TestSlashAllValidators](../../tests/integration/throttle.go#L613) | TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.Details
It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
One slash packet is created for each validator, and then an additional five more for each validator
in order to test the system's ability to handle multiple slashing events in a single block.
The test then receives and processes each slashing packet in the provider chain
and afterward, it checks that all validators are jailed as expected.
Note: This edge case should not occur in practice, but it is useful to validate that
the slash meter can allow any number of slash packets to be handled in a single block when
its allowance is set to "1.0". |
+ [TestBasicSlashPacketThrottling](../../tests/integration/throttle.go#L35) | TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer, two slash packets, and no VSC matured packets. The most basic scenario.Details
* Set up various test cases, all CCV channels and validator powers.
* Retrieve the initial value of the slash meter, and the test verify it has the expected value.
* All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
* Create a slash packet for the first validator and send it from the consumer to the provider.
* Asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
* Then, create a second slash packet for a different validator, and check if the second validator is
not jailed after sending the second slash packet.
* Replenishes the slash meter until it is positive.
* Assert that validator 2 is jailed once the slash packet is retried and that it has no more voting power. |
+ [TestMultiConsumerSlashPacketThrottling](../../tests/integration/throttle.go#L219) | TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple consumers sending slash packets to the provider, with VSC matured packets sprinkled around.Details
* Set up all CCV channels and validator powers.
* Choose three consumer bundles from the available bundles.
* Send the slash packets from each of the chosen consumer bundles to the provider chain. They will each slash a different validator.
* Confirm that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
third consumers were bounced.
* Check the total power of validators in the provider chain to ensure it reflects the expected state after the first validator has been jailed.
* Replenish the slash meter and handle one of the two queued slash packet entries when both are retried.
* Verify again that the total power is updated.
* Replenish the slash meter one more time, and handle the final slash packet.
* Confirm that all validators are jailed. |
+ [TestPacketSpam](../../tests/integration/throttle.go#L348) | TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.Details
* Set up all CCV channels and validator powers.
* Set the parameters related to the handling of slash packets.
* Prepare the slash packets for the first three validators, and create 500 slash packets, alternating between
downtime and double-sign infractions.
* Simulate the reception of the 500 packets by the provider chain within the same block.
* Verify that the first three validators have been jailed as expected. This confirms that the
system correctly processed the slash packets and applied the penalties. |
+ [TestDoubleSignDoesNotAffectThrottling](../../tests/integration/throttle.go#L420) | TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets do not affect the throttling mechanism.Details
* Set up a scenario where 3 validators are slashed for double signing, and the 4th is not.
* Send 500 double sign slash packets from a consumer to the provider in a single block.
* Confirm that the slash meter is not affected by this, and that no validators are jailed. |
+ [TestSlashingSmallValidators](../../tests/integration/throttle.go#L508) | TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain in a non-throttled manner.Details
* Set up all CCV channels and delegate tokens to four validators, giving the first validator a larger amount of power.
* Initialize the slash meter, and verify that none of the validators are jailed before the slash packets are processed.
* Set up default signing information for the three smaller validators to prepare them for being jailed.
* The slash packets for the small validators are then constructed and sent.
* Verify validator powers after processing the slash packets.
* Confirm that the large validator remains unaffected and that the three smaller ones have been penalized and jailed. |
+ [TestSlashMeterAllowanceChanges](../../tests/integration/throttle.go#L587) | TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.Details
* Set up all CCV channels, verify the initial slash meter allowance, and update the power of validators.
* Confirm that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
* Change the replenish fraction and assert the new expected allowance.
TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges. |
+ [TestSlashAllValidators](../../tests/integration/throttle.go#L619) | TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.Details
* Set up all CCV channels and validator powers.
* Set the slash meter parameters.
* Create one slash packet for each validator, and then an additional five more for each validator
in order to test the system's ability to handle multiple slashing events in a single block.
* Receive and process each slashing packet in the provider chain and check that all validators are jailed as expected.
Note: This edge case should not occur in practice, but it is useful to validate that
the slash meter can allow any number of slash packets to be handled in a single block when
its allowance is set to "1.0". |
# [throttle_retry.go](../../tests/integration/throttle_retry.go)
@@ -121,7 +121,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestSlashRetries](../../tests/integration/throttle_retry.go#L23) | TestSlashRetries tests the throttling v2 retry logic at an integration level.Details
This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
Two validators are then selected, and their signing information is set up.
The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
It verifies that the packet is sent. Packet is then received on the provider side and handled. The test then confirms that the first validator has been jailed
and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain. |
+ [TestSlashRetries](../../tests/integration/throttle_retry.go#L27) | TestSlashRetries tests the throttling v2 retry logic at an integration level.Details
* Set up the CCV channels and the provider.
* Retrieve the validators and ensure that none are initially jailed.
* Select two validators and set up their signing information.
* Set up the consumer, and then construct and queue a slashing packet for the first validator.
* Verify that the packet is sent.
* Receive the packet on the provider side and handle it.
* Confirm that the first validator has been jailed and check the provider's slash meter to ensure it reflects the correct state.
* Acknowledge the packet on the consumer chain, and verify that the slash record has been deleted and no pending packets remain.
* Confirm that packet sending is now permitted.
* Queue a second slashing packet for the second validator and verify its pending status.
* Handle the second packet, check that the second validator is jailed, and confirm
the final state of the slash record and pending packets on the consumer chain. |
# [unbonding.go](../../tests/integration/unbonding.go)
@@ -129,7 +129,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestUndelegationCompletion](../../tests/integration/unbonding.go#L14) | TestUndelegationCompletion tests that undelegations complete after the unbonding period elapses on the provider, regardless of the consumer's stateDetails
It sets up a CCV channel and performs an initial delegation of tokens followed by a partial undelegation
(undelegating 1/4 of the tokens). Then it verifies that the staking unbonding operation is created as expected. Block height is then incremented
on the provider. After this period elapses, the test checks that the unbonding operation has been completed. Finally, it verifies
that the token balances are correctly updated, ensuring that the expected amount of tokens has been returned to the account. |
+ [TestUndelegationCompletion](../../tests/integration/unbonding.go#L16) | TestUndelegationCompletion tests that undelegations complete after the unbonding period elapses on the provider, regardless of the consumer's stateDetails
* Set up CCV channel.
* Perform initial delegation of tokens followed by a partial undelegation (1/4 of the tokens).
* Verify that the staking unbonding operation is created as expected.
* Increment provider block height.
* Check that the unbonding operation has been completed.
* Verify that the token balances are correctly updated and the expected amount of tokens has been returned to the account. |
# [valset_update.go](../../tests/integration/valset_update.go)
@@ -137,7 +137,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestPacketRoundtrip](../../tests/integration/valset_update.go#L22) | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.Details
It sets up CCV and transfer channels. Some tokens are then bonded on the provider side in order to change validator power.
The test then relays a packet from the provider chain to the consumer chain.
Lastly, it relays a matured packet from the consumer chain back to the provider chain. |
- [TestQueueAndSendVSCMaturedPackets](../../tests/integration/valset_update.go#L55) | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.Details
It sets up CCV channel and then creates and simulates the sending of three VSC packets
from the provider chain to the consumer chain at different times. The first packet is sent, and its processing is validated.
After simulating the passage of one hour, the second packet is sent and its processing is validated. Then after simulating the
passage of 24 more hours, the third packet is sent and its processing is validated. The test then retrieves all packet maturity
times from the consumer, and this is used to check the maturity status of the packets sent earlier.
The test then advances the time so that the first two packets reach their unbonding period, while the third packet does not.
Next it ensures first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
The third packet is still in the store and has not yet been processed for unbonding.
Finally, the test checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state. |
+ [TestPacketRoundtrip](../../tests/integration/valset_update.go#L23) | TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.Details
* Set up CCV and transfer channels.
* Bond some tokens on the provider side in order to change validator power.
* Relay a packet from the provider chain to the consumer chain.
* Relays a matured packet from the consumer chain back to the provider chain. |
+ [TestQueueAndSendVSCMaturedPackets](../../tests/integration/valset_update.go#L59) | TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.Details
* Set up CCV channel.
* Create and simulate the sending of three VSC packets from the provider chain to the consumer chain at different times.
* Send the first packet and validate its processing.
* Simulate the passage of one hour.
* Send the second packet and validate its processing.
* Simulate the passage of 24 more hours.
* Send the third packet and validate its processing.
* Retrieve all packet maturity times from the consumer, and use this to check the maturity status of the packets sent earlier.
* Advance the time so that the first two packets reach their unbonding period, while the third packet does not.
* Ensure first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
* The third packet is still in the store and has not yet been processed for unbonding.
* Checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state. |
diff --git a/tests/integration/democracy.go b/tests/integration/democracy.go
index 30190fce9d..1271bce12e 100644
--- a/tests/integration/democracy.go
+++ b/tests/integration/democracy.go
@@ -72,9 +72,9 @@ func (suite *ConsumerDemocracyTestSuite) SetupTest() {
// TestDemocracyRewardsDistribution checks that rewards to democracy representatives, community pool, and provider redistribution account are done correctly.
// @Long Description@
-// * Sets up a democracy consumer chain
-// * Creates a new block
-// * Checks that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions
+// * Set up a democracy consumer chain.
+// * Create a new block.
+// * Check that rewards to democracy representatives, community pool, and provider redistribution account are distributed in the right proportions.
func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() {
s.consumerChain.NextBlock()
stakingKeeper := s.consumerApp.GetTestStakingKeeper()
@@ -184,13 +184,13 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() {
// can be executed on democracy consumer chains.
// @Long Description@
// For context, see the whitelist for proposals in app/consumer-democracy/proposals_whitelisting.go.
-// * Sets up a democracy consumer chain
-// * Submits a proposal containing changes to the auth and mint module parameters
-// * Checks that the proposal is not executed, since the change to the auth module is not whitelisted.
-// * Submits a proposal containing changes *only* to the mint module parameters
-// * Checks that the proposal is executed, since the change to the mint module is whitelisted.
-// * Submits a proposal containing changes *only* to the auth module parameters
-// * Checks that again, the proposal is not executed, since the change to the auth module is not whitelisted.
+// * Set up a democracy consumer chain.
+// * Submit a proposal containing changes to the auth and mint module parameters.
+// * Check that the proposal is not executed, since the change to the auth module is not whitelisted.
+// * Submit a proposal containing changes *only* to the mint module parameters.
+// * Check that the proposal is executed, since the change to the mint module is whitelisted.
+// * Submit a proposal containing changes *only* to the auth module parameters.
+// * Check that again, the proposal is not executed, since the change to the auth module is not whitelisted.
func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() {
govKeeper := s.consumerApp.GetTestGovKeeper()
params, err := govKeeper.Params.Get(s.consumerCtx())
@@ -288,9 +288,9 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() {
// TestDemocracyMsgUpdateParams checks that the consumer parameters can be updated through a governance proposal.
// @Long Description@
-// * Sets up a democracy consumer chain
-// * Submits a proposal containing changes to the consumer module parameters
-// * Checks that the proposal is executed, and the parameters are updated
+// * Set up a democracy consumer chain.
+// * Submit a proposal containing changes to the consumer module parameters.
+// * Check that the proposal is executed, and the parameters are updated.
func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams() {
govKeeper := s.consumerApp.GetTestGovKeeper()
params, err := govKeeper.Params.Get(s.consumerCtx())
diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go
index 69d66b94ee..64e7365e14 100644
--- a/tests/integration/distribution.go
+++ b/tests/integration/distribution.go
@@ -23,13 +23,12 @@ import (
// TestRewardsDistribution tests the distribution of rewards from the consumer chain to the provider chain.
// @Long Description@
-// The test sets up a provider and consumer chain and completes the channel initialization.
-// Then, it sends tokens into the FeeCollector on the consumer chain,
-// and checks that these tokens distributed correctly across the provider and consumer chain.
-// It first checks that the tokens are distributed purely on the consumer chain,
-// then advances the block height to make the consumer chain send a packet with rewards to the provider chain.
-// It does not whitelist the consumer denom, so the tokens are expected to stay in
-// the ConsumerRewardsPool on the provider chain.
+// * Set up a provider and consumer chain and completes the channel initialization.
+// * Send tokens into the FeeCollector on the consumer chain,
+// and check that these tokens distributed correctly across the provider and consumer chain.
+// * Check that the tokens are distributed purely on the consumer chain,
+// then advance the block height to make the consumer chain send a packet with rewards to the provider chain.
+// * Don't whitelist the consumer denom, so that the tokens stay in the ConsumerRewardsPool on the provider chain.
func (s *CCVTestSuite) TestRewardsDistribution() {
// set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain
s.SetupCCVChannel(s.path)
@@ -196,12 +195,10 @@ func (s *CCVTestSuite) TestRewardsDistribution() {
// TestSendRewardsRetries tests that failed reward transmissions are retried every BlocksPerDistributionTransmission blocks
// @Long Description@
-// The test sets up a provider and consumer chain and completes the channel initialization.
-// It fills the fee pool on the consumer chain,
-// then corrupts the transmission channel and tries to send rewards to the provider chain,
-// which should fail.
-// The test then advances the block height to trigger a retry of the reward transmission,
-// and confirms that this time, the transmission is successful.
+// * Set up a provider and consumer chain and complete the channel initialization.
+// * Fill the fee pool on the consumer chain, then corrupt the transmission channel
+// and try to send rewards to the provider chain, which should fail.
+// * Advance the block height to trigger a retry of the reward transmission, and confirm that this time, the transmission is successful.
func (s *CCVTestSuite) TestSendRewardsRetries() {
// TODO: this setup can be consolidated with other tests in the file
@@ -275,13 +272,14 @@ func (s *CCVTestSuite) TestSendRewardsRetries() {
// TestEndBlockRD tests that the last transmission block height is correctly updated after the expected number of block have passed.
// @Long Description@
-// The test first sets up CCV and transmission channels between the provider
-// and consumer chains. It then fills the fee pool on the consumer chain, prepares the system for reward
-// distribution, and optionally corrupts the transmission channel to simulate failure scenarios.
-// After advancing the block height, the test verifies whether the LBTH is updated correctly
-// and if the escrow balance changes as expected. The test also checks that the IBC transfer
-// transfer states are discarded if the reward distribution to the provider has failed.
-
+// * Set up CCV and transmission channels between the provider and consumer chains.
+// * Fill the fee pool on the consumer chain, prepare the system for reward
+// distribution, and optionally corrupt the transmission channel to simulate failure scenarios.
+// * After advancing the block height, verify whether the LBTH is updated correctly
+// and if the escrow balance changes as expected.
+// * Check that the IBC transfer states are discarded if the reward distribution
+// to the provider has failed.
+//
// Note: this method is effectively a unit test for EndBLockRD(), but is written as an integration test to avoid excessive mocking.
func (s *CCVTestSuite) TestEndBlockRD() {
testCases := []struct {
@@ -403,8 +401,8 @@ func (s *CCVTestSuite) TestEndBlockRD() {
// TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), but is written as an integration test to avoid excessive mocking.
// @Long Description@
-// The test first sets up CCV and transmission channels between the provider and consumer chains.
-// Then it verifies the SendRewardsToProvider() function under various scenarios and checks if the
+// * Set up CCV and transmission channels between the provider and consumer chains.
+// * Verify the SendRewardsToProvider() function under various scenarios and checks if the
// function handles each scenario correctly by ensuring the expected number of token transfers.
func (s *CCVTestSuite) TestSendRewardsToProvider() {
testCases := []struct {
@@ -549,9 +547,10 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() {
// TestIBCTransferMiddleware tests the logic of the IBC transfer OnRecvPacket callback.
// @Long Description@
-// The test first sets up IBC and transfer channels. Then it simulates various scenarios of token transfers from the provider chain to
-// the consumer chain, and evaluates how the middleware processes these transfers. It ensures that token transfers are handled correctly and
-// rewards are allocated as expected.
+// * Set up IBC and transfer channels.
+// * Simulate various scenarios of token transfers from the provider chain to
+// the consumer chain, and evaluate how the middleware processes these transfers.
+// * Ensure that token transfers are handled correctly and rewards are allocated as expected.
func (s *CCVTestSuite) TestIBCTransferMiddleware() {
var (
data transfertypes.FungibleTokenPacketData
@@ -738,10 +737,10 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() {
// TestAllocateTokens is a happy-path test of the consumer rewards pool allocation
// to opted-in validators and the community pool.
// @Long Description@
-// The test sets up a provider chain and multiple consumer chains, and initializes the channels between them.
-// It funds the consumer rewards pools on the provider chain and allocates rewards to the consumer chains.
-// Then, it begins a new block to cause rewards to be distributed to the validators and the community pool,
-// and checks that the rewards are allocated as expected.
+// * Set up a provider chain and multiple consumer chains, and initialize the channels between them.
+// * Fund the consumer rewards pools on the provider chain and allocate rewards to the consumer chains.
+// * Begin a new block to cause rewards to be distributed to the validators and the community pool,
+// and check that the rewards are allocated as expected.
func (s *CCVTestSuite) TestAllocateTokens() {
// set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain
s.SetupAllCCVChannels()
@@ -873,15 +872,15 @@ func (s *CCVTestSuite) prepareRewardDist() {
// TestAllocateTokensToConsumerValidators tests the allocation of tokens to consumer validators.
// @Long Description@
-// The test exclusively uses the provider chain.
-// It sets up a current set of consumer validators, then calls the AllocateTokensToConsumerValidators
+// * The test exclusively uses the provider chain.
+// * Set up a current set of consumer validators, then call the AllocateTokensToConsumerValidators
// function to allocate a number of tokens to the validators.
-// The test then checks that the expected number of tokens were allocated to the validators.
-// The test covers the following scenarios:
-// - The tokens to be allocated are empty
-// - The consumer validator set is empty
-// - The tokens are allocated to a single validator
-// - The tokens are allocated to multiple validators
+// * Check that the expected number of tokens were allocated to the validators.
+// * The test covers the following scenarios:
+// - The tokens to be allocated are empty
+// - The consumer validator set is empty
+// - The tokens are allocated to a single validator
+// - The tokens are allocated to multiple validators
func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() {
providerKeeper := s.providerApp.GetProviderKeeper()
distributionKeeper := s.providerApp.GetTestDistributionKeeper()
@@ -1020,11 +1019,13 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() {
// TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights tests AllocateTokensToConsumerValidators test with
// consumer validators that have different heights.
// @Long Description@
-// It sets up a context where the consumer validators have different join heights and verifies that rewards are
-// correctly allocated only to validators who have been active long enough. It ensures that rewards are evenly distributed
-// among eligible validators, that validators can withdraw their rewards correctly, and that no rewards are allocated to validators
-// who do not meet the required join height criteria. It confirms that validators that have been consumer validators
-// for some time receive rewards, while validators that recently became consumer validators do not receive rewards.
+// * Set up a context where the consumer validators have different join heights and verify that rewards are
+// correctly allocated only to validators who have been active long enough.
+// * Ensure that rewards are evenly distributed among eligible validators, that validators
+// can withdraw their rewards correctly, and that no rewards are allocated to validators
+// who do not meet the required join height criteria.
+// * Confirm that validators that have been consumer validators for some time receive rewards,
+// while validators that recently became consumer validators do not receive rewards.
func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValidatorHeights() {
// Note this test is an adaptation of a `TestAllocateTokensToConsumerValidators` testcase.
providerKeeper := s.providerApp.GetProviderKeeper()
@@ -1138,11 +1139,13 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida
// TestMultiConsumerRewardsDistribution tests the rewards distribution of multiple consumers chains.
// @Long Description@
-// It sets up multiple consumer and transfer channels and verifies the distribution of rewards from
-// various consumer chains to the provider's reward pool. It ensures that the consumer reward pools are
-// correctly populated and that rewards are properly transferred to the provider. The test checks that
-// the provider's reward pool balance reflects the accumulated rewards from all consumer chains after
-// processing IBC transfer packets and relaying committed packets.
+// * Set up multiple consumer and transfer channels and verify the distribution of rewards from
+// various consumer chains to the provider's reward pool.
+// * Ensure that the consumer reward pools are correctly populated
+// and that rewards are properly transferred to the provider.
+// * Checks that the provider's reward pool balance reflects the accumulated
+// rewards from all consumer chains after processing IBC transfer packets and relaying
+// committed packets.
func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() {
s.SetupAllCCVChannels()
s.SetupAllTransferChannels()
diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go
index 70c8a22649..e558b11d2b 100644
--- a/tests/integration/double_vote.go
+++ b/tests/integration/double_vote.go
@@ -15,10 +15,11 @@ import (
// TestHandleConsumerDoubleVoting tests the handling of double voting evidence from the consumer chain.
// @Long Description@
-// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
-// It checks if the provider chain correctly processes the evidence, jails and tombstones validators as needed, and applies the
-// correct slashing penalties. Finally, it verifies that invalid evidence is properly rejected and does not result in
-// incorrect penalties.
+// * Set up a CCV channel.
+// * Create various double voting scenarios and submit those to the provider chain.
+// * Check if the provider chain correctly processes the evidence, jail and tombstone validators as needed, and apply the
+// correct slashing penalties.
+// * Verify that invalid evidence is properly rejected and does not result in incorrect penalties.
func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -273,10 +274,12 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
// TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations tests the handling of double voting evidence from the consumer chain and checks if slashing, undelegations, and redelegations are correctly processed.
// @Long Description@
-// The test sets up a CCV channel, creates various double voting scenarios, and submits these to the provider chain.
-// It verifies that the evidence is processed correctly, ensures that the provider chain slashes the validator appropriately, and that
-// it handles undelegations and redelegations accurately. Then the test confirms that the validator’s staking status reflects these
-// actions. It also checks if the slashing penalties are applied correctly and updates the validator’s balance and delegations as expected.
+// * Set up a CCV channel.
+// * Create various double voting scenarios and submit those to the provider chain.
+// * Verify that the evidence is processed correctly.
+// * Ensure that the provider chain slashes the validator appropriately, and that it handles undelegations and redelegations accurately.
+// * Confirm that the validator’s staking status reflects these actions.
+// * Check if the slashing penalties are applied correctly and update the validator’s balance and delegations as expected.
func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go
index 67467b9539..099fdd1613 100644
--- a/tests/integration/expired_client.go
+++ b/tests/integration/expired_client.go
@@ -20,11 +20,12 @@ import (
// TestVSCPacketSendExpiredClient tests queueing of VSCPackets when the consumer client is expired.
// @Long Description@
-// The test sets up a CCV channel and expires the client on consumer chain. Then, it bonds tokens to provider,
-// sends CCV packet to consumer and checks pending packets. While the consumer client is expired (or inactive for some reason)
-// all packets will be queued. The packet sending and checks are then repeated. After that more tokens are bonded on
-// provider to change validator powers. Finally expired client is upgraded to the consumer
-// and all packets are cleared once the consumer client is established.
+// * Set up a CCV channel and expire the client on consumer chain.
+// * Bond tokens to provider, send CCV packet to consumer and check pending packets.
+// * While the consumer client is expired (or inactive for some reason) all packets will be queued.
+// * The packet sending and checks are then repeated.
+// * More tokens are bonded on provider to change validator powers.
+// * Upgrade expired client to the consumer and all packets are cleared once the consumer client is established.
func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
@@ -89,9 +90,11 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
// TestConsumerPacketSendExpiredClient tests the consumer sending packets when the provider client is expired.
// @Long Description@
-// The test sets up a CCV channel and bonds tokens on provider, then it sends CCV packet to consumer and rebonds tokens on
-// provider. Then it checks for pending VSC packets and relays all VSC packets to consumer. After that the provider client
-// is expired. Finally it confirms that while the provider client is expired all packets will be queued and then cleared
+// * Set up a CCV channel and bond tokens on provider.
+// * Send CCV packet to consumer and rebond tokens on provider.
+// * Check for pending VSC packets and relay all VSC packets to consumer.
+// * The provider client is then expired.
+// * Confirm that while the provider client is expired all packets will be queued and then cleared
// once the provider client is upgraded.
func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index 2f7e7fa6b3..1b39a3bef7 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -319,15 +319,6 @@ func (s *CCVTestSuite) TestKeyAssignment() {
}
}
-// CheckKeyAssignmentCorrectly checks if the key was assigned correctly.
-func (s *CCVTestSuite) CheckKeyAssignment(validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey) {
- valConsAddr, err := validator.GetConsAddr()
- s.Require().NoError(err)
- actualConsumerKey, found := s.providerApp.GetProviderKeeper().GetValidatorConsumerPubKey(s.providerCtx(), s.consumerChain.ChainID, types.NewProviderConsAddress(valConsAddr))
- s.Require().True(found)
- s.Require().Equal(consumerKey, actualConsumerKey)
-}
-
// generateNewConsumerKey generate new consumer key for the validator with valIndex
func generateNewConsumerKey(s *CCVTestSuite, valIndex int) (stakingtypes.Validator, tmprotocrypto.PublicKey) {
// get validator
diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go
index 4662c85bbe..86752ee466 100644
--- a/tests/integration/misbehaviour.go
+++ b/tests/integration/misbehaviour.go
@@ -17,11 +17,11 @@ import (
// TestHandleConsumerMisbehaviour tests the handling of consumer misbehavior.
// @Long Description@
-// The test sets up a CCV channel and sends an empty VSC packet to ensure that the consumer client revision height is greater than 0.
-// It then constructs a Misbehaviour object with two conflicting headers and process the equivocation evidence.
-// After that it verifies that the provider chain correctly processes this misbehavior. The test ensures that all involved
-// validators are jailed, tombstoned, and slashed according to the expected outcomes. It includes steps to assert
-// that their tokens are adjusted based on the slashing fraction.
+// * Set up a CCV channel and send an empty VSC packet to ensure that the consumer client revision height is greater than 0.
+// * Construct a Misbehaviour object with two conflicting headers and process the equivocation evidence.
+// * Verify that the provider chain correctly processes this misbehavior.
+// * Ensure that all involved validators are jailed, tombstoned, and slashed according to the expected outcomes.
+// * Assert that their tokens are adjusted based on the slashing fraction.
func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -89,17 +89,15 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() {
// TestGetByzantineValidators checks the GetByzantineValidators function on various instances of misbehaviour.
// @Long Description@
-// The test sets up a provider and consumer chain.
-// It creates a header with a subset of the validators on the consumer chain,
-// then creates a second header (in a variety of different ways),
-// and checks which validators are considered Byzantine
-// by calling the GetByzantineValidators function.
-// The test scenarios are:
-// * when one of the headers is empty, the function should return an error
-// * when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
-// * when the signatures in one of the headers are corrupted, the function should return an error
-// * when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
-// * for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine
+// * Set up a provider and consumer chain.
+// * Create a header with a subset of the validators on the consumer chain, then create a second header (in a variety of different ways),
+// and check which validators are considered Byzantine by calling the GetByzantineValidators function.
+// * The test scenarios are:
+// - when one of the headers is empty, the function should return an error
+// - when one of the headers has a corrupted validator set (e.g. by a validator having a different public key), the function should return an error
+// - when the signatures in one of the headers are corrupted, the function should return an error
+// - when the attack is an amnesia attack (i.e. the headers have different block IDs), no validator is considered byzantine
+// - for non-amnesia misbehaviour, all validators that signed both headers are considered byzantine
func (s *CCVTestSuite) TestGetByzantineValidators() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
@@ -384,19 +382,20 @@ func (s *CCVTestSuite) TestGetByzantineValidators() {
// TestCheckMisbehaviour tests that the CheckMisbehaviour function correctly checks for misbehaviour.
// @Long Description@
-// The test sets up a provider and consumer chain.
-// It creates a valid client header and then creates a misbehaviour by creating a second header in a variety of different ways.
-// It then checks that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
+// * Set up a provider and consumer chain.
+// * Create a valid client header and then create a misbehaviour by creating a second header in a variety of different ways.
+// * Check that the CheckMisbehaviour function correctly checks for misbehaviour by verifying that
// it returns an error when the misbehaviour is invalid and no error when the misbehaviour is valid.
-// The test scenarios are:
-// * both headers are identical (returns an error)
-// * the misbehaviour is not for the consumer chain (returns an error)
-// * passing an invalid client id (returns an error)
-// * passing a misbehaviour with different header height (returns an error)
-// * passing a misbehaviour older than the min equivocation evidence height (returns an error)
-// * one header of the misbehaviour has insufficient voting power (returns an error)
-// * passing a valid misbehaviour (no error)
-// It does not test actually submitting the misbehaviour to the chain or freezing the client.
+// * The test scenarios are:
+// - both headers are identical (returns an error)
+// - the misbehaviour is not for the consumer chain (returns an error)
+// - passing an invalid client id (returns an error)
+// - passing a misbehaviour with different header height (returns an error)
+// - passing a misbehaviour older than the min equivocation evidence height (returns an error)
+// - one header of the misbehaviour has insufficient voting power (returns an error)
+// - passing a valid misbehaviour (no error)
+//
+// * Test does not test actually submitting the misbehaviour to the chain or freezing the client.
func (s *CCVTestSuite) TestCheckMisbehaviour() {
s.SetupCCVChannel(s.path)
// required to have the consumer client revision height greater than 0
diff --git a/tests/integration/normal_operations.go b/tests/integration/normal_operations.go
index fa5b4afc67..2e6df8ced9 100644
--- a/tests/integration/normal_operations.go
+++ b/tests/integration/normal_operations.go
@@ -11,11 +11,11 @@ import (
// TestHistoricalInfo tests the tracking of historical information in the context of new blocks being committed.
// @Long Description@
-// The test first saves the initial number of CC validators and current block height.
-// Then it adds a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
-// After, the test setup creates 2 validators and then calls TrackHistoricalInfo with header block height
-// Test cases verify that historical information is pruned correctly and that the validator set is updated as expected.
-// Execution of test cases checks if the historical information is correctly handled and pruned based on the block height.
+// * Save the initial number of CC validators and current block height.
+// * Add a new validator and then advance the blockchain by one block, triggering the tracking of historical information.
+// * Create 2 validators and then call TrackHistoricalInfo with header block height.
+// * Verify that historical information is pruned correctly and that the validator set is updated as expected.
+// * Check if the historical information is correctly handled and pruned based on the block height.
func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so we can copy locks
consumerKeeper := k.consumerApp.GetConsumerKeeper()
cCtx := k.consumerChain.GetContext
diff --git a/tests/integration/partial_set_security_test.go b/tests/integration/partial_set_security_test.go
index ed0bfa301c..c79bcd3fe2 100644
--- a/tests/integration/partial_set_security_test.go
+++ b/tests/integration/partial_set_security_test.go
@@ -24,11 +24,10 @@ const stakeMultiplier = 1000000
// TestMinStake tests the min stake parameter.
// @Long Description@
-// It starts a provider and single consumer chain,
-// sets the initial powers according to the input, and then
-// sets the min stake parameter according to the test case.
-// Finally, it checks that the validator set on the consumer chain is as expected
-// according to the min stake parameter.
+// * Start a provider and single consumer chain.
+// * Set the initial powers according to the input.
+// * Set the min stake parameter according to the test case.
+// * Check that the validator set on the consumer chain is as expected according to the min stake parameter.
func TestMinStake(t *testing.T) {
testCases := []struct {
name string
diff --git a/tests/integration/query_providerinfo_test.go b/tests/integration/query_providerinfo_test.go
index a1121537a6..c3ca0c64e3 100644
--- a/tests/integration/query_providerinfo_test.go
+++ b/tests/integration/query_providerinfo_test.go
@@ -2,8 +2,8 @@ package integration
// TestQueryProviderInfo tests the results of GetProviderInfo method.
// @Long Description@
-// The test sets up a CCV channel and sends an empty VSC packet.
-// Then verifies that the result of GetProviderInfo method is correct and it
+// * Set up a CCV channel and send an empty VSC packet.
+// * Verify that the result of GetProviderInfo method is correct and it
// provides expected information about the blockchain provider and consumer.
func (s *CCVTestSuite) TestQueryProviderInfo() {
s.SetupCCVChannel(s.path)
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index 2be06818ad..f45ccef6c3 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -32,14 +32,17 @@ import (
// TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed from consumer to provider,
// handled by provider, with a VSC and jailing eventually effective on consumer and provider.
// @Long Description@
-// It sets up CCV channels and retrieves consumer validators. A validator is selected and its consensus address is created.
-// The test then retrieves the provider consensus address that corresponds to the consumer consensus address of the validator.
-// Also the validator's current state is retrieved, including its token balance, and the validator's signing information is set to ensure
-// it will be jailed for downtime. The slashing packet is then created and sent from the consumer chain to the provider chain with a specified
-// timeout. The packet is then received and the test also verifies that the validator was removed from the provider validator set.
-// After, the test relays VSC packets from the provider chain to each consumer chain and verifies that the consumer chains correctly
-// process these packets. The validator's balance and status on the provider chain are checked to ensure it was jailed correctly but not slashed,
-// and its unjailing time is updated. The outstanding downtime flag is reset on the consumer chain, and lastly, the test ensures that the consumer
+// * Set up CCV channels and retrieve consumer validators.
+// * Select a validator and create its consensus address.
+// * Retrieve the provider consensus address that corresponds to the consumer consensus address of the validator.
+// * The validator's current state is also retrieved, including its token balance,
+// * Set validator's signing information is to ensure it will be jailed for downtime.
+// * Create the slashing packet and send it from the consumer chain to the provider chain with a specified timeout.
+// * Receive the packet and verify that the validator was removed from the provider validator set.
+// * Relay VSC packets from the provider chain to each consumer chain and verify that the consumer chains correctly process these packets.
+// * Check the validator's balance and status on the provider chain to ensure it was jailed correctly but not slashed,
+// and its unjailing time is updated.
+// * Reset the outstanding downtime flag on the consumer chain, and ensure that the consumer
// chain acknowledges receipt of the packet from the provider chain.
//
// Note: This method does not test the actual slash packet sending logic for downtime
@@ -177,9 +180,9 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() {
// TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.
// @Long Description@
-// It sets up a provider and consumer chain, with channel initialization between them performed,
-// then sends a slash packet with randomized fields from the consumer to the provider.
-// The provider processes the packet
+// * Set up a provider and consumer chain, with channel initialization between them performed.
+// * Send a slash packet with randomized fields from the consumer to the provider.
+// * The provider processes the packet
func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
providerKeeper := s.providerApp.GetProviderKeeper()
consumerKeeper := s.consumerApp.GetConsumerKeeper()
@@ -224,10 +227,11 @@ func (s *CCVTestSuite) TestSlashPacketAcknowledgement() {
// TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.
// @Long Description@
-// It retrieves a validator from provider chain's validators and checks if it's bonded.
-// The signing information for the validator is then set. The provider processes the downtime slashing packet from the consumer.
-// The test then checks that the validator has been jailed as a result of the downtime slashing packet being processed.
-// It also verifies that the validator’s signing information is updated and that the jailing duration is set correctly.
+// * Retrieve a validator from provider chain's validators and checks if it's bonded.
+// * Set tThe signing information for the validator.
+// * The provider processes the downtime slashing packet from the consumer.
+// * Check that the validator has been jailed as a result of the downtime slashing packet being processed.
+// * Verify that the validator’s signing information is updated and that the jailing duration is set correctly.
//
// Note that only downtime slash packets are processed by HandleSlashPacket.
func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
@@ -272,9 +276,9 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
// TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.
// @Long Description@
-// It sets up all CCV channels and expects panic if the channel is not established via dest channel of packet.
-// After the correct channelID is added to the packet, a panic shouldn't occur anymore.
-// The test creates an instance of SlashPacketData and then verifies correct processing and error handling
+// * Set up all CCV channels and expect panic if the channel is not established via dest channel of packet.
+// * After the correct channelID is added to the packet, a panic shouldn't occur anymore.
+// * Create an instance of SlashPacketData and then verify correct processing and error handling
// for slashing packets received by the provider chain.
func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
providerKeeper := suite.providerApp.GetProviderKeeper()
@@ -376,13 +380,14 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
// TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched
// when a validator has downtime on the slashing module.
// @Long Description@
-// It sets up all CCV channel and send an empty VSC packet, then retrieves the address of a validator.
-// Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
-// The test simulates the validator missing blocks and then verifies that the validator is jailed and the jailed time is correctly updated.
-// Also it ensures that the missed block counters are reset. After it checks that there is a pending slash packet in the queue, the test sends
-// the pending packets. Then checks if slash record is created and verifies that the consumer queue still contains the packet since no
-// acknowledgment has been received from the provider. It verifies that the slash packet was sent and check that the outstanding
-// slashing flag prevents the jailed validator to keep missing block.
+// * Set up all CCV channel and send an empty VSC packet, then retrieve the address of a validator.
+// * Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
+// * Simulate the validator missing blocks and then verify that the validator is jailed and the jailed time is correctly updated.
+// * Ensure that the missed block counters are reset.
+// * Check that there is a pending slash packet in the queue, and then send the pending packets.
+// * Check if slash record is created and verify that the consumer queue still contains the packet since no
+// acknowledgment has been received from the provider.
+// * Verify that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block.
func (suite *CCVTestSuite) TestValidatorDowntime() {
// initial setup
suite.SetupCCVChannel(suite.path)
@@ -496,10 +501,13 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
// TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.
// @Long Description@
-// It sets up all CCV channel and sends an empty VSC packet, then creates a validator public key and address. Then the infraction parameters are set and
-// evidence of double signing is created. Validator signing-info are also added to the store and the slash packet is constructed.
-// The test then simulates double signing and sends the slash packet. It then verifies the handling of slash packet, and after
-// it checks if slash record was created and if it's waiting for reply. Lastly the test confirms that the queue is not cleared and the slash packet is sent
+// * Set up all CCV channel and send an empty VSC packet.
+// * Create a validator public key and address.
+// * Set the infraction parameters and create evidence of double signing.
+// * Add validator signing-info are also to the store and construct the slash packet.
+// * Simulate double signing and sends the slash packet.
+// * Verify the handling of slash packet, and check if slash record was created and if it's waiting for reply.
+// * Confirm that the queue is not cleared and the slash packet is sent.
func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// initial setup
suite.SetupCCVChannel(suite.path)
@@ -588,10 +596,12 @@ func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
// TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets.
// In normal operation slash packets are queued in BeginBlock and sent in EndBlock.
// @Long Description@
-// It sets up all CCV channels and then queues slash packets for both downtime and double-signing infractions.
-// Then, it checks that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
-// After the CCV channel for sending actual slash packets is prepared, the slash packets are sent, and the test checks that the outstanding downtime flags
-// are correctly set for validators that were slashed for downtime infractions. Lastly, the test ensures that the pending data packets queue is empty.
+// * Set up all CCV channels and then queue slash packets for both downtime and double-signing infractions.
+// * Check that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
+// * Prepare the CCV channel for sending actual slash packets.
+// * Send the slash packets and check that the outstanding downtime flags are correctly set for validators that were slashed
+// for downtime infractions.
+// * Ensure that the pending data packets queue is empty.
func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
suite.SetupCCVChannel(suite.path)
@@ -673,9 +683,10 @@ func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
// have any undesired behavior when a slash packet is queued before the CCV channel is established.
// Then once the CCV channel is established, the slash packet should be sent soon after.
// @Long Description@
-// It checks that no pending packets exist and that there's no slash record found. Then it triggers a slashing event which queues a slash packet.
-// The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
-// The test then verifies that a slashing record now exists, indicating that the slashing packet has been successfully sent.
+// * Check that no pending packets exist and that there's no slash record found.
+// * Triggers a slashing event which queues a slash packet.
+// * The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
+// *Verify that a slashing record now exists, indicating that the slashing packet has been successfully sent.
func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go
index c62ea28f46..c134c83abf 100644
--- a/tests/integration/stop_consumer.go
+++ b/tests/integration/stop_consumer.go
@@ -14,15 +14,15 @@ import (
// TestStopConsumerChain tests the functionality of stopping a consumer chain at a higher level than unit tests.
// @Long Description@
-// It retrieves a validator from the provider chain's validators and then the delegator address.
-// Then the test sets up test operations, populating the provider chain states using the following operations:
+// * Retrieve a validator from the provider chain's validators and then the delegator address.
+// * Set up test operations, populating the provider chain states using the following operations:
// - Setup CCV channels; establishes the CCV channel and sets channelToChain, chainToChannel, and initHeight mapping for the consumer chain ID.
// - Delegate the total bond amount to the chosen validator.
// - Undelegate the shares in four consecutive blocks evenly; create UnbondingOp and UnbondingOpIndex entries for the consumer chain ID.
// - Set SlashAck state for the consumer chain ID.
//
-// After, the setup operations are executed, and the consumer chain is stopped. Finally, the test checks that the state
-// associated with the consumer chain is properly cleaned up after it is stopped.
+// * After, the setup operations are executed, and the consumer chain is stopped.
+// * Check that the state associated with the consumer chain is properly cleaned up after it is stopped.
func (s *CCVTestSuite) TestStopConsumerChain() {
providerKeeper := s.providerApp.GetProviderKeeper()
providerStakingKeeper := s.providerApp.GetTestStakingKeeper()
@@ -110,8 +110,8 @@ func (s *CCVTestSuite) TestStopConsumerChain() {
// TestStopConsumerOnChannelClosed tests stopping a consumer chain correctly.
// @Long Description@
-// This test sets up CCV channel and transfer channel, and sends empty VSC packet.
-// Then it stops the consumer chain and verifies that the provider chain's channel end is closed
+// * Set up CCV channel and transfer channel, and send empty VSC packet.
+// * Stop the consumer chain and verify that the provider chain's channel end is closed.
//
// TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end
func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() {
diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go
index 0194fe9ffe..f7196d3e56 100644
--- a/tests/integration/throttle.go
+++ b/tests/integration/throttle.go
@@ -23,13 +23,15 @@ const fullSlashMeterString = "1.0"
// TestBasicSlashPacketThrottling tests slash packet throttling with a single consumer,
// two slash packets, and no VSC matured packets. The most basic scenario.
// @Long Description@
-// It sets up various test cases, all CCV channels and validator powers. Also, the initial value of the slash meter is retrieved, and the test verifies it
-// has the expected value. All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
-// The test then creates a slash packet for the first validator and sends it from the consumer to the provider.
-// Afterward, it asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
-// Then, a second slash packet is created for a different validator, and the test validates that the second validator is
-// not jailed after sending the second slash packet. Next, it replenishes the slash meter until it is positive.
-// Lastly, it asserts that validator 2 is jailed once the slash packet is retried and that it has no more voting power.
+// * Set up various test cases, all CCV channels and validator powers.
+// * Retrieve the initial value of the slash meter, and the test verify it has the expected value.
+// * All validators are retrieved as well, and it's ensured that none of them are jailed from the start.
+// * Create a slash packet for the first validator and send it from the consumer to the provider.
+// * Asserts that validator 0 is jailed, has no power, and that the slash meter and allowance have the expected values.
+// * Then, create a second slash packet for a different validator, and check if the second validator is
+// not jailed after sending the second slash packet.
+// * Replenishes the slash meter until it is positive.
+// * Assert that validator 2 is jailed once the slash packet is retried and that it has no more voting power.
func (s *CCVTestSuite) TestBasicSlashPacketThrottling() {
// setupValidatePowers gives the default 4 validators 25% power each (1000 power).
// Note this in test cases.
@@ -204,14 +206,16 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() {
// TestMultiConsumerSlashPacketThrottling tests slash packet throttling in the context of multiple
// consumers sending slash packets to the provider, with VSC matured packets sprinkled around.
// @Long Description@
-// It sets up all CCV channels and validator powers. It then chooses three consumer bundles from the available bundles. Next, the slash
-// packets are sent from each of the chosen consumer bundles to the provider chain. They will each slash a different validator. The test
-// then confirms that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
-// third consumers were bounced. It then checks the total power of validators in the provider chain to ensure it reflects the expected
-// state after the first validator has been jailed. The slash meter is then replenished, and one of the two queued. The slash meter
-// is then replenished, and one of the two queued slash packet entries is handled when both are retried. The total power is then updated
-// and verified again. Then, the slash meter is replenished one more time, and the final slash packet is handled. Lastly, the test
-// confirms that all validators are jailed.
+// * Set up all CCV channels and validator powers.
+// * Choose three consumer bundles from the available bundles.
+// * Send the slash packets from each of the chosen consumer bundles to the provider chain. They will each slash a different validator.
+// * Confirm that the slash packet for the first consumer was handled first, and afterward, the slash packets for the second and
+// third consumers were bounced.
+// * Check the total power of validators in the provider chain to ensure it reflects the expected state after the first validator has been jailed.
+// * Replenish the slash meter and handle one of the two queued slash packet entries when both are retried.
+// * Verify again that the total power is updated.
+// * Replenish the slash meter one more time, and handle the final slash packet.
+// * Confirm that all validators are jailed.
func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
// Setup test
s.SetupAllCCVChannels()
@@ -334,10 +338,12 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() {
// TestPacketSpam confirms that the provider can handle a large number of incoming slash packets in a single block.
// @Long Description@
-// It sets up all CCV channels and validator powers. Then the parameters related to the handling of slash packets are set.
-// The slash packets for the first three validators are then prepared, and 500 slash packets are created, alternating between
-// downtime and double-sign infractions. The test then simulates the reception of the 500 packets by the provider chain within
-// the same block. Lastly, it verifies that the first three validators have been jailed as expected. This confirms that the
+// * Set up all CCV channels and validator powers.
+// * Set the parameters related to the handling of slash packets.
+// * Prepare the slash packets for the first three validators, and create 500 slash packets, alternating between
+// downtime and double-sign infractions.
+// * Simulate the reception of the 500 packets by the provider chain within the same block.
+// * Verify that the first three validators have been jailed as expected. This confirms that the
// system correctly processed the slash packets and applied the penalties.
func (s *CCVTestSuite) TestPacketSpam() {
// Setup ccv channels to all consumers
@@ -408,9 +414,9 @@ func (s *CCVTestSuite) TestPacketSpam() {
// TestDoubleSignDoesNotAffectThrottling tests that a large number of double sign slash packets
// do not affect the throttling mechanism.
// @Long Description@
-// This test sets up a scenario where 3 validators are slashed for double signing, and the 4th is not.
-// It then sends 500 double sign slash packets from a consumer to the provider in a single block.
-// The test confirms that the slash meter is not affected by this, and that no validators are jailed.
+// * Set up a scenario where 3 validators are slashed for double signing, and the 4th is not.
+// * Send 500 double sign slash packets from a consumer to the provider in a single block.
+// * Confirm that the slash meter is not affected by this, and that no validators are jailed.
func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
// Setup ccv channels to all consumers
s.SetupAllCCVChannels()
@@ -493,12 +499,12 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() {
// TestSlashingSmallValidators tests that multiple slash packets from validators with small power can be handled by the provider chain
// in a non-throttled manner.
// @Long Description@
-// It sets up all CCV channels and delegates tokens to four validators, giving the first validator a larger amount of power.
-// The slash meter is then initialized, and the test verifies that none of the validators are jailed before the slash packets are processed.
-// It then sets up default signing information for the three smaller validators to prepare them for being jailed.
-// The slash packets for the small validators are then constructed and sent.
-// Lastly, the test verifies validator powers after processing the slash packets. It confirms that the large validator remains unaffected and
-// that the three smaller ones have been penalized and jailed.
+// * Set up all CCV channels and delegate tokens to four validators, giving the first validator a larger amount of power.
+// * Initialize the slash meter, and verify that none of the validators are jailed before the slash packets are processed.
+// * Set up default signing information for the three smaller validators to prepare them for being jailed.
+// * The slash packets for the small validators are then constructed and sent.
+// * Verify validator powers after processing the slash packets.
+// * Confirm that the large validator remains unaffected and that the three smaller ones have been penalized and jailed.
func (s *CCVTestSuite) TestSlashingSmallValidators() {
s.SetupAllCCVChannels()
providerKeeper := s.providerApp.GetProviderKeeper()
@@ -573,9 +579,9 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() {
// TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change.
// @Long Description@
-// It sets up all CCV channels, verifies the initial slash meter allowance, and updates the power of validators.
-// Then, it confirms that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
-// Lastly, it changes the replenish fraction and asserts the new expected allowance.
+// * Set up all CCV channels, verify the initial slash meter allowance, and update the power of validators.
+// * Confirm that the value of the slash meter allowance is adjusted correctly after updating the validators' powers.
+// * Change the replenish fraction and assert the new expected allowance.
//
// TODO: This should be a unit test, or replaced by TestTotalVotingPowerChanges.
func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() {
@@ -601,11 +607,11 @@ func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() {
// TestSlashAllValidators is similar to TestSlashSameValidator, but 100% of validators' power is jailed in a single block.
// @Long Description@
-// It sets up all CCV channels and validator powers. Then the slash meter parameters are set.
-// One slash packet is created for each validator, and then an additional five more for each validator
+// * Set up all CCV channels and validator powers.
+// * Set the slash meter parameters.
+// * Create one slash packet for each validator, and then an additional five more for each validator
// in order to test the system's ability to handle multiple slashing events in a single block.
-// The test then receives and processes each slashing packet in the provider chain
-// and afterward, it checks that all validators are jailed as expected.
+// * Receive and process each slashing packet in the provider chain and check that all validators are jailed as expected.
//
// Note: This edge case should not occur in practice, but it is useful to validate that
// the slash meter can allow any number of slash packets to be handled in a single block when
diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go
index 2498e78852..685fa03d2d 100644
--- a/tests/integration/throttle_retry.go
+++ b/tests/integration/throttle_retry.go
@@ -12,14 +12,18 @@ import (
// TestSlashRetries tests the throttling v2 retry logic at an integration level.
// @Long Description@
-// This test sets up the CCV channels and the provider. It retrieves the validators and ensures that none are initially jailed.
-// Two validators are then selected, and their signing information is set up.
-// The test also sets up the consumer, and then constructs and queues a slashing packet for the first validator.
-// It verifies that the packet is sent. Packet is then received on the provider side and handled. The test then confirms that the first validator has been jailed
-// and checks the provider's slash meter to ensure it reflects the correct state. The packet is acknowledged on the consumer chain, and it is verified
-// that the slash record has been deleted and no pending packets remain. Additionally, it confirms that packet sending is now permitted.
-// The test then queues a second slashing packet for the second validator and verifies its pending status. Finally, it handles the second packet,
-// checks that the second validator is jailed, and confirms the final state of the slash record and pending packets on the consumer chain.
+// * Set up the CCV channels and the provider.
+// * Retrieve the validators and ensure that none are initially jailed.
+// * Select two validators and set up their signing information.
+// * Set up the consumer, and then construct and queue a slashing packet for the first validator.
+// * Verify that the packet is sent.
+// * Receive the packet on the provider side and handle it.
+// * Confirm that the first validator has been jailed and check the provider's slash meter to ensure it reflects the correct state.
+// * Acknowledge the packet on the consumer chain, and verify that the slash record has been deleted and no pending packets remain.
+// * Confirm that packet sending is now permitted.
+// * Queue a second slashing packet for the second validator and verify its pending status.
+// * Handle the second packet, check that the second validator is jailed, and confirm
+// the final state of the slash record and pending packets on the consumer chain.
func (s *CCVTestSuite) TestSlashRetries() {
s.SetupAllCCVChannels()
s.SendEmptyVSCPacket() // Establish ccv channel
diff --git a/tests/integration/unbonding.go b/tests/integration/unbonding.go
index 8955497ae4..3f13d7cd1f 100644
--- a/tests/integration/unbonding.go
+++ b/tests/integration/unbonding.go
@@ -7,10 +7,12 @@ import (
// TestUndelegationCompletion tests that undelegations complete after
// the unbonding period elapses on the provider, regardless of the consumer's state
// @Long Description@
-// It sets up a CCV channel and performs an initial delegation of tokens followed by a partial undelegation
-// (undelegating 1/4 of the tokens). Then it verifies that the staking unbonding operation is created as expected. Block height is then incremented
-// on the provider. After this period elapses, the test checks that the unbonding operation has been completed. Finally, it verifies
-// that the token balances are correctly updated, ensuring that the expected amount of tokens has been returned to the account.
+// * Set up CCV channel.
+// * Perform initial delegation of tokens followed by a partial undelegation (1/4 of the tokens).
+// * Verify that the staking unbonding operation is created as expected.
+// * Increment provider block height.
+// * Check that the unbonding operation has been completed.
+// * Verify that the token balances are correctly updated and the expected amount of tokens has been returned to the account.
func (s *CCVTestSuite) TestUndelegationCompletion() {
s.SetupCCVChannel(s.path)
diff --git a/tests/integration/valset_update.go b/tests/integration/valset_update.go
index d9fb576cf5..89078bb26e 100644
--- a/tests/integration/valset_update.go
+++ b/tests/integration/valset_update.go
@@ -16,9 +16,10 @@ import (
// TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on the provider.
// @Long Description@
-// It sets up CCV and transfer channels. Some tokens are then bonded on the provider side in order to change validator power.
-// The test then relays a packet from the provider chain to the consumer chain.
-// Lastly, it relays a matured packet from the consumer chain back to the provider chain.
+// * Set up CCV and transfer channels.
+// * Bond some tokens on the provider side in order to change validator power.
+// * Relay a packet from the provider chain to the consumer chain.
+// * Relays a matured packet from the consumer chain back to the provider chain.
func (s *CCVTestSuite) TestPacketRoundtrip() {
s.SetupCCVChannel(s.path)
s.SetupTransferChannel()
@@ -43,15 +44,18 @@ func (s *CCVTestSuite) TestPacketRoundtrip() {
// TestQueueAndSendVSCMaturedPackets tests the behavior of EndBlock QueueVSCMaturedPackets call and its integration with SendPackets call.
// @Long Description@
-// It sets up CCV channel and then creates and simulates the sending of three VSC packets
-// from the provider chain to the consumer chain at different times. The first packet is sent, and its processing is validated.
-// After simulating the passage of one hour, the second packet is sent and its processing is validated. Then after simulating the
-// passage of 24 more hours, the third packet is sent and its processing is validated. The test then retrieves all packet maturity
-// times from the consumer, and this is used to check the maturity status of the packets sent earlier.
-// The test then advances the time so that the first two packets reach their unbonding period, while the third packet does not.
-// Next it ensures first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
-// The third packet is still in the store and has not yet been processed for unbonding.
-// Finally, the test checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state.
+// * Set up CCV channel.
+// * Create and simulate the sending of three VSC packets from the provider chain to the consumer chain at different times.
+// * Send the first packet and validate its processing.
+// * Simulate the passage of one hour.
+// * Send the second packet and validate its processing.
+// * Simulate the passage of 24 more hours.
+// * Send the third packet and validate its processing.
+// * Retrieve all packet maturity times from the consumer, and use this to check the maturity status of the packets sent earlier.
+// * Advance the time so that the first two packets reach their unbonding period, while the third packet does not.
+// * Ensure first two packets are unbonded, their maturity times are deleted, and that VSCMatured packets are queued.
+// * The third packet is still in the store and has not yet been processed for unbonding.
+// * Checks that the packet commitments for the processed packets are correctly reflected in the consumer chain's state.
func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From aafabb7cf7ff3a93c89044aaf52f857f78b0b3f4 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Tue, 17 Sep 2024 09:49:33 +0000
Subject: [PATCH 69/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index c08c00038b..1f5544bec5 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -87,10 +87,10 @@
[TestSlashPacketAcknowledgement](../../tests/integration/slashing.go#L186) | TestSlashPacketAcknowledgement tests the handling of a slash packet acknowledgement.Details
* Set up a provider and consumer chain, with channel initialization between them performed.
* Send a slash packet with randomized fields from the consumer to the provider.
* The provider processes the packet |
[TestHandleSlashPacketDowntime](../../tests/integration/slashing.go#L237) | TestHandleSlashPacketDowntime tests the handling of a downtime related slash packet, with integration tests.Details
* Retrieve a validator from provider chain's validators and checks if it's bonded.
* Set tThe signing information for the validator.
* The provider processes the downtime slashing packet from the consumer.
* Check that the validator has been jailed as a result of the downtime slashing packet being processed.
* Verify that the validator’s signing information is updated and that the jailing duration is set correctly.
Note that only downtime slash packets are processed by HandleSlashPacket. |
[TestOnRecvSlashPacketErrors](../../tests/integration/slashing.go#L283) | TestOnRecvSlashPacketErrors tests errors for the OnRecvSlashPacket method in an integration testing setting.Details
* Set up all CCV channels and expect panic if the channel is not established via dest channel of packet.
* After the correct channelID is added to the packet, a panic shouldn't occur anymore.
* Create an instance of SlashPacketData and then verify correct processing and error handling
for slashing packets received by the provider chain. |
- [TestValidatorDowntime](../../tests/integration/slashing.go#L391) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
* Set up all CCV channel and send an empty VSC packet, then retrieve the address of a validator.
* Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
* Simulate the validator missing blocks and then verify that the validator is jailed and the jailed time is correctly updated.
* Ensure that the missed block counters are reset.
* Check that there is a pending slash packet in the queue, and then send the pending packets.
* Check if slash record is created and verify that the consumer queue still contains the packet since no
acknowledgment has been received from the provider.
* Verify that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
- [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L511) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
* Set up all CCV channel and send an empty VSC packet.
* Create a validator public key and address.
* Set the infraction parameters and create evidence of double signing.
* Add validator signing-info are also to the store and construct the slash packet.
* Simulate double signing and sends the slash packet.
* Verify the handling of slash packet, and check if slash record was created and if it's waiting for reply.
* Confirm that the queue is not cleared and the slash packet is sent. |
- [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L605) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
* Set up all CCV channels and then queue slash packets for both downtime and double-signing infractions.
* Check that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
* Prepare the CCV channel for sending actual slash packets.
* Send the slash packets and check that the outstanding downtime flags are correctly set for validators that were slashed
for downtime infractions.
* Ensure that the pending data packets queue is empty. |
- [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L690) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
* Check that no pending packets exist and that there's no slash record found.
* Triggers a slashing event which queues a slash packet.
* The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
*Verify that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
+ [TestValidatorDowntime](../../tests/integration/slashing.go#L401) | TestValidatorDowntime tests if a slash packet is sent and if the outstanding slashing flag is switched when a validator has downtime on the slashing module.Details
* Set up all CCV channel and send an empty VSC packet, then retrieve the address of a validator.
* Validator signs blocks for the duration of the signedBlocksWindow and a slash packet is constructed to be sent and committed.
* Simulate the validator missing blocks and then verify that the validator is jailed and the jailed time is correctly updated.
* Ensure that the missed block counters are reset.
* Check that there is a pending slash packet in the queue, and then send the pending packets.
* Check if slash record is created and verify that the consumer queue still contains the packet since no
acknowledgment has been received from the provider.
* Verify that the slash packet was sent and check that the outstanding slashing flag prevents the jailed validator to keep missing block. |
+ [TestValidatorDoubleSigning](../../tests/integration/slashing.go#L521) | TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.Details
* Set up all CCV channel and send an empty VSC packet.
* Create a validator public key and address.
* Set the infraction parameters and create evidence of double signing.
* Add validator signing-info are also to the store and construct the slash packet.
* Simulate double signing and sends the slash packet.
* Verify the handling of slash packet, and check if slash record was created and if it's waiting for reply.
* Confirm that the queue is not cleared and the slash packet is sent. |
+ [TestQueueAndSendSlashPacket](../../tests/integration/slashing.go#L615) | TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets. In normal operation slash packets are queued in BeginBlock and sent in EndBlock.Details
* Set up all CCV channels and then queue slash packets for both downtime and double-signing infractions.
* Check that the correct number of slash requests are stored in the queue, including duplicates for downtime infractions.
* Prepare the CCV channel for sending actual slash packets.
* Send the slash packets and check that the outstanding downtime flags are correctly set for validators that were slashed
for downtime infractions.
* Ensure that the pending data packets queue is empty. |
+ [TestCISBeforeCCVEstablished](../../tests/integration/slashing.go#L700) | TestCISBeforeCCVEstablished tests that the consumer chain doesn't panic or have any undesired behavior when a slash packet is queued before the CCV channel is established. Then once the CCV channel is established, the slash packet should be sent soon after.Details
* Check that no pending packets exist and that there's no slash record found.
* Triggers a slashing event which queues a slash packet.
* The slash packet should be queued but not sent, and it should stay like that until the CCV channel is established and the packet is sent.
*Verify that a slashing record now exists, indicating that the slashing packet has been successfully sent. |
# [stop_consumer.go](../../tests/integration/stop_consumer.go)
From 6025b56d9d00d0d50507d64728c75c71f83fe94d Mon Sep 17 00:00:00 2001
From: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com>
Date: Tue, 17 Sep 2024 11:52:56 +0200
Subject: [PATCH 70/88] Update .github/workflows/testing-docs.yml
Co-authored-by: Marius Poke
---
.github/workflows/testing-docs.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 7a1f4797e7..bee1c4cf03 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -41,6 +41,7 @@ jobs:
run: make testing-docs
- name: Check for changes
+ if: env.GIT_DIFF
id: check_changes
run: |
git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
From 1cb3095b119421e2ad4c967f8d02caf7ab38d3d2 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 18 Sep 2024 13:37:11 +0200
Subject: [PATCH 71/88] Changed inconsistent make command name
---
.github/workflows/testing-docs.yml | 2 +-
Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 7a1f4797e7..c4ae841db4 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -38,7 +38,7 @@ jobs:
- name: Generate testing docs
if: env.GIT_DIFF
- run: make testing-docs
+ run: make build-testing-docs
- name: Check for changes
id: check_changes
diff --git a/Makefile b/Makefile
index 04f00662dd..c648654077 100644
--- a/Makefile
+++ b/Makefile
@@ -265,7 +265,7 @@ build-docs-deploy:
build-docs-local:
@cd docs && ./build_local.sh
-testing-docs:
+build-testing-docs:
@cd scripts/test_doc && go run extract_docstrings.go
###############################################################################
From 11d2d1f4f515a46df2540354701ed171d5f25ce8 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 18 Sep 2024 13:51:24 +0200
Subject: [PATCH 72/88] Testing testing-docs script
---
tests/integration/changeover.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b18ea38f4b..22d624fb1f 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -13,6 +13,7 @@ import (
// * creates a connection between the two chains
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
+//
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From 7c47913fef7b54039ba260d5f3fca12828a19cab Mon Sep 17 00:00:00 2001
From: github-actions
Date: Wed, 18 Sep 2024 11:52:01 +0000
Subject: [PATCH 73/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 1f5544bec5..1807c06177 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L18) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
# [democracy.go](../../tests/integration/democracy.go)
From 9ee3cd0686c7347341e44559ba76fc08456acb2b Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 18 Sep 2024 13:53:48 +0200
Subject: [PATCH 74/88] Testing testing-docs script
---
tests/integration/changeover.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index 22d624fb1f..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -13,7 +13,6 @@ import (
// * creates a connection between the two chains
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
-//
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From 255af8919928ac7e7cb31f08227569056ebee209 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Wed, 18 Sep 2024 11:54:50 +0000
Subject: [PATCH 75/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 1807c06177..1f5544bec5 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L18) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
# [democracy.go](../../tests/integration/democracy.go)
From 1526ef774fd918faa45ec0154609d401a5f1f765 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 18 Sep 2024 13:59:31 +0200
Subject: [PATCH 76/88] Changed inconsistent make command in TESTING.md
---
TESTING.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TESTING.md b/TESTING.md
index 929e920775..4a50f6d3de 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -24,7 +24,7 @@ When adding an integration test, write a brief description as a docstring in the
// that goes into more detail and describes the scenario.
```
-Then, run `make docs-test` to update the test documentation.
+Then, run `make build-testing-docs` to update the test documentation.
## Model-Based Tests (MBT)
From 642f3385077c7c1acf18cf29408fc911810b32fd Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 25 Sep 2024 10:23:38 +0200
Subject: [PATCH 77/88] Updated testing-docs.yml
---
.github/workflows/testing-docs.yml | 18 +++++++-----------
tests/integration/changeover.go | 1 +
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index fe544c5c84..6a823f43e6 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -12,7 +12,7 @@ on:
permissions:
contents: write
- pull-requests: write # 'write' access to pull requests
+ pull-requests: write # 'write' access to pull requests in order to update test documentation automatically
jobs:
testing-docs:
@@ -40,16 +40,12 @@ jobs:
if: env.GIT_DIFF
run: make build-testing-docs
- - name: Check for changes
+ - name: Check for changes and update automatically
if: env.GIT_DIFF
- id: check_changes
+ id: check_changes_and_update
run: |
- git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
- cp scripts/test_doc/test_documentation.md generated_file.md
- if ! diff -q generated_file.md committed_file.md; then
+ if ! git diff --exit-code HEAD:scripts/test_doc/test_documentation.md scripts/test_doc/test_documentation.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
- cp generated_file.md scripts/test_doc/test_documentation.md
-
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
else
@@ -58,13 +54,13 @@ jobs:
git fetch origin $branch
git checkout $branch
-
- cp generated_file.md scripts/test_doc/test_documentation.md
+ cp scripts/test_doc/test_documentation.md scripts/test_doc/test_documentation.md
+
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add scripts/test_doc/test_documentation.md
git commit -m "Update testing documentation"
-
+
git push origin "$branch"
exit 1
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b18ea38f4b..fddbc343a9 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -14,6 +14,7 @@ import (
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
+// testing
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From af544fa6e0f915118359b7ca7621f8d798a0c9fb Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 25 Sep 2024 10:26:38 +0200
Subject: [PATCH 78/88] Updated testing-docs.yml
---
.github/workflows/testing-docs.yml | 12 ++++++++----
tests/integration/changeover.go | 1 -
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 6a823f43e6..2aff76376b 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -44,8 +44,12 @@ jobs:
if: env.GIT_DIFF
id: check_changes_and_update
run: |
- if ! git diff --exit-code HEAD:scripts/test_doc/test_documentation.md scripts/test_doc/test_documentation.md; then
+ git show HEAD:scripts/test_doc/test_documentation.md > committed_file.md
+ cp scripts/test_doc/test_documentation.md generated_file.md
+ if ! diff -q generated_file.md committed_file.md; then
echo "Documentation for integration tests is out of date. Updating and pushing changes..."
+ cp generated_file.md scripts/test_doc/test_documentation.md
+
if [ -n "$GITHUB_HEAD_REF" ]; then
branch=$GITHUB_HEAD_REF
else
@@ -54,13 +58,13 @@ jobs:
git fetch origin $branch
git checkout $branch
- cp scripts/test_doc/test_documentation.md scripts/test_doc/test_documentation.md
-
+
+ cp generated_file.md scripts/test_doc/test_documentation.md
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add scripts/test_doc/test_documentation.md
git commit -m "Update testing documentation"
-
+
git push origin "$branch"
exit 1
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index fddbc343a9..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -14,7 +14,6 @@ import (
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
-// testing
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From 19d172e3408d64e8756ff25f8e11aa2d7f0c0fb0 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 25 Sep 2024 10:28:01 +0200
Subject: [PATCH 79/88] Testing testing-docs.yml
---
tests/integration/changeover.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index b18ea38f4b..fddbc343a9 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -14,6 +14,7 @@ import (
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
+// testing
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From d983bd9f1046475eeb75a7ad061ebe719435d67e Mon Sep 17 00:00:00 2001
From: github-actions
Date: Wed, 25 Sep 2024 08:32:47 +0000
Subject: [PATCH 80/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index 1f5544bec5..ae4ada9a5c 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L18) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
testing |
# [democracy.go](../../tests/integration/democracy.go)
From 2050bb4a80f90c0fad3239feff23ff981e0f4bd1 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 25 Sep 2024 10:33:51 +0200
Subject: [PATCH 81/88] Testing testing-docs.yml
---
tests/integration/changeover.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go
index fddbc343a9..b18ea38f4b 100644
--- a/tests/integration/changeover.go
+++ b/tests/integration/changeover.go
@@ -14,7 +14,6 @@ import (
// * creates a transfer channel between the two chains
// * transitions the standalone chain to a consumer chain
// * confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
-// testing
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
From 5678400b14ea0e356186396d2a3074401c7c587e Mon Sep 17 00:00:00 2001
From: github-actions
Date: Wed, 25 Sep 2024 08:35:16 +0000
Subject: [PATCH 82/88] Update testing documentation
---
scripts/test_doc/test_documentation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/test_doc/test_documentation.md b/scripts/test_doc/test_documentation.md
index ae4ada9a5c..1f5544bec5 100644
--- a/scripts/test_doc/test_documentation.md
+++ b/scripts/test_doc/test_documentation.md
@@ -5,7 +5,7 @@
| Function | Short Description |
|----------|-------------------|
- [TestRecycleTransferChannel](../../tests/integration/changeover.go#L18) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist.
testing |
+ [TestRecycleTransferChannel](../../tests/integration/changeover.go#L17) | TestRecycleTransferChannel tests that an existing transfer channel can be reused when transitioning from a standalone to a consumer chain.Details
The test case:
* sets up a provider chain and a standalone chain
* creates a connection between the two chains
* creates a transfer channel between the two chains
* transitions the standalone chain to a consumer chain
* confirms that no extra transfer channel is created, thus only one transfer channel and one CCV channel exist. |
# [democracy.go](../../tests/integration/democracy.go)
From d1d2a53ba9aff94e03e8e220a93e3cead340b665 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Fri, 27 Sep 2024 07:51:33 +0200
Subject: [PATCH 83/88] Removed failiure signal from testing-docs.yml
---
.github/workflows/testing-docs.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/testing-docs.yml b/.github/workflows/testing-docs.yml
index 2aff76376b..886c66b6ad 100644
--- a/.github/workflows/testing-docs.yml
+++ b/.github/workflows/testing-docs.yml
@@ -67,5 +67,4 @@ jobs:
git push origin "$branch"
- exit 1
fi
\ No newline at end of file
From 48e5f62e5e5eb9f9ca88a51de3dabd15d6a41f68 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Thu, 3 Oct 2024 14:40:14 +0200
Subject: [PATCH 84/88] Removed TestValidatorDoubleSigning from slashing.go
---
tests/integration/slashing.go | 95 -----------------------------------
1 file changed, 95 deletions(-)
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index f45ccef6c3..a8c9f1edc0 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -3,7 +3,6 @@ package integration
import (
"context"
"fmt"
- "time"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
@@ -499,100 +498,6 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
})
}
-// TestValidatorDoubleSigning tests if a slash packet is sent when a double-signing evidence is handled by the evidence module.
-// @Long Description@
-// * Set up all CCV channel and send an empty VSC packet.
-// * Create a validator public key and address.
-// * Set the infraction parameters and create evidence of double signing.
-// * Add validator signing-info are also to the store and construct the slash packet.
-// * Simulate double signing and sends the slash packet.
-// * Verify the handling of slash packet, and check if slash record was created and if it's waiting for reply.
-// * Confirm that the queue is not cleared and the slash packet is sent.
-func (suite *CCVTestSuite) TestValidatorDoubleSigning() {
- // initial setup
- suite.SetupCCVChannel(suite.path)
- suite.SendEmptyVSCPacket()
-
- // sync suite context after CCV channel is established
- ctx := suite.consumerCtx()
-
- channelID := suite.path.EndpointA.ChannelID
-
- // create a validator pubkey and address
- // note that the validator won't necessarily be in valset to due the TM delay
- pubkey := ed25519.GenPrivKey().PubKey()
- consAddr := sdk.ConsAddress(pubkey.Address())
-
- // set an arbitrary infraction height
- infractionHeight := ctx.BlockHeight() - 1
- power := int64(100)
-
- // create evidence
- e := &evidencetypes.Equivocation{
- Height: infractionHeight,
- Power: power,
- Time: time.Now().UTC(),
- ConsensusAddress: consAddr.String(),
- }
-
- // add validator signing-info to the store
- suite.consumerApp.GetTestSlashingKeeper().SetValidatorSigningInfo(ctx, consAddr, slashingtypes.ValidatorSigningInfo{
- Address: consAddr.String(),
- Tombstoned: false,
- })
-
- // save next sequence before sending a slash packet
- seq, ok := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctx, ccv.ConsumerPortID, channelID)
- suite.Require().True(ok)
-
- // construct slash packet data and get the expected commit hash
- packetData := ccv.NewSlashPacketData(
- abci.Validator{Address: consAddr.Bytes(), Power: power},
- // get VSC ID mapping to the infraction height with the TM delay subtracted
- suite.consumerApp.GetConsumerKeeper().GetHeightValsetUpdateID(ctx, uint64(infractionHeight-sdk.ValidatorUpdateDelay)),
- stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN,
- )
- expCommit := suite.commitSlashPacket(ctx, *packetData)
-
- suite.consumerChain.NextBlock()
- // // expect to send slash packet when handling double-sign evidence
- // // NOTE: using IBCKeeper Authority as msg submitter (equal to gov module addr)
- addr, err := sdk.AccAddressFromBech32(suite.consumerApp.GetIBCKeeper().GetAuthority())
- suite.Require().NoError(err)
- evidenceMsg, err := evidencetypes.NewMsgSubmitEvidence(addr, e)
- suite.Require().NoError(err)
- suite.Require().NotEmpty(evidenceMsg)
-
- // this was previously done using suite.consumerApp.GetTestEvidenceKeeper().HandleEquivocationEvidence(ctx, e)
- // HandleEquivocationEvidence is not exposed in the evidencekeeper interface starting cosmos-sdk v0.50.x
- // suite.consumerApp.GetTestEvidenceKeeper().SubmitEvidence(ctx, e)
- handleEquivocationEvidence(ctx, suite.consumerApp, e)
-
- // check slash packet is queued
- pendingPackets := suite.consumerApp.GetConsumerKeeper().GetPendingPackets(ctx)
- suite.Require().NotEmpty(pendingPackets, "pending packets empty")
- suite.Require().Len(pendingPackets, 1, "pending packets len should be 1 is %d", len(pendingPackets))
-
- // clear queue, commit packets
- suite.consumerApp.GetConsumerKeeper().SendPackets(ctx)
-
- // Check slash record is created
- slashRecord, found := suite.consumerApp.GetConsumerKeeper().GetSlashRecord(suite.consumerCtx())
- suite.Require().True(found, "slash record not found")
- suite.Require().True(slashRecord.WaitingOnReply)
- suite.Require().Equal(slashRecord.SendTime, suite.consumerCtx().BlockTime())
-
- // check queue is not cleared, since no ack has been received from provider
- pendingPackets = suite.consumerApp.GetConsumerKeeper().GetPendingPackets(ctx)
- suite.Require().Len(pendingPackets, 1, "pending packets len should be 1 is %d", len(pendingPackets))
-
- // check slash packet is sent
- gotCommit := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(ctx, ccv.ConsumerPortID, channelID, seq)
- suite.NotNil(gotCommit)
-
- suite.Require().EqualValues(expCommit, gotCommit)
-}
-
// TestQueueAndSendSlashPacket tests the integration of QueueSlashPacket with SendPackets.
// In normal operation slash packets are queued in BeginBlock and sent in EndBlock.
// @Long Description@
From 5f1b1feb014d7d77f416458e9256b836fcad94aa Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Thu, 3 Oct 2024 14:49:02 +0200
Subject: [PATCH 85/88] Added TODOs in slashing.go
---
tests/integration/slashing.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go
index a8c9f1edc0..fe622afbdf 100644
--- a/tests/integration/slashing.go
+++ b/tests/integration/slashing.go
@@ -279,6 +279,7 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() {
// * After the correct channelID is added to the packet, a panic shouldn't occur anymore.
// * Create an instance of SlashPacketData and then verify correct processing and error handling
// for slashing packets received by the provider chain.
+// TODO: Move to unit tests.
func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() {
providerKeeper := suite.providerApp.GetProviderKeeper()
firstBundle := suite.getFirstBundle()
@@ -507,6 +508,7 @@ func (suite *CCVTestSuite) TestValidatorDowntime() {
// * Send the slash packets and check that the outstanding downtime flags are correctly set for validators that were slashed
// for downtime infractions.
// * Ensure that the pending data packets queue is empty.
+// TODO: Move to unit tests.
func (suite *CCVTestSuite) TestQueueAndSendSlashPacket() {
suite.SetupCCVChannel(suite.path)
From 0e70d6e02bd005603381c298851ea17dba39b576 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Thu, 3 Oct 2024 15:56:10 +0200
Subject: [PATCH 86/88] Added panics and a TODO for unexpected errors in
key_assignment.go.
---
tests/integration/key_assignment.go | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go
index 1b39a3bef7..a7614a7063 100644
--- a/tests/integration/key_assignment.go
+++ b/tests/integration/key_assignment.go
@@ -31,6 +31,7 @@ import (
// For each scenario where the key assignment does not produce an error,
// the test also checks that VSCPackets are relayed to the consumer chain and that the clients on
// the provider and consumer chain can be updated.
+// TODO: Remove panics when unexpected error occurs.
func (s *CCVTestSuite) TestKeyAssignment() {
testCases := []struct {
name string
@@ -106,7 +107,7 @@ func (s *CCVTestSuite) TestKeyAssignment() {
validator, consumerKey := generateNewConsumerKey(s, 0)
err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey)
if err != nil {
- return err
+ panic(err)
}
// same key assignment, but different validator
@@ -129,7 +130,7 @@ func (s *CCVTestSuite) TestKeyAssignment() {
validator, consumerKey := generateNewConsumerKey(s, 0)
err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey)
if err != nil {
- return err
+ panic(err)
}
// same key assignment, but different validator
@@ -175,7 +176,7 @@ func (s *CCVTestSuite) TestKeyAssignment() {
validator, consumerKey := generateNewConsumerKey(s, 0)
err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey)
if err != nil {
- return err
+ panic(err)
}
s.nextEpoch()
From 29478fca394182bf80772326729efa8c9bdaf805 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 9 Oct 2024 10:41:57 +0200
Subject: [PATCH 87/88] Implement security check for file path in
extract_docstrings.go
---
scripts/test_doc/extract_docstrings.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index ce939a646a..f3e9cd940f 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -62,6 +62,12 @@ func main() {
// in a markdown table format.
// It returns a list of test functions that are missing docstrings.
func extractDocstrings(filePath string, out *os.File) []string {
+ // Check if the file exists and is within the allowed directory
+ allowedDir := "../../tests/integration/" // Adjust this to your specific allowed directory
+ if !strings.HasPrefix(filePath, allowedDir) {
+ log.Fatalf("Error: File path %s is outside the allowed directory\n", filePath)
+ }
+
// Read the Go source file
src, err := os.ReadFile(filePath)
if err != nil {
From 23d8853f35414e2c2e71aa05efe91a96e22e2b93 Mon Sep 17 00:00:00 2001
From: kirdatatjana
Date: Wed, 9 Oct 2024 11:12:04 +0200
Subject: [PATCH 88/88] Removed security check for file path in
extract_docstrings.go
---
scripts/test_doc/extract_docstrings.go | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/scripts/test_doc/extract_docstrings.go b/scripts/test_doc/extract_docstrings.go
index f3e9cd940f..88c4498a79 100644
--- a/scripts/test_doc/extract_docstrings.go
+++ b/scripts/test_doc/extract_docstrings.go
@@ -62,14 +62,8 @@ func main() {
// in a markdown table format.
// It returns a list of test functions that are missing docstrings.
func extractDocstrings(filePath string, out *os.File) []string {
- // Check if the file exists and is within the allowed directory
- allowedDir := "../../tests/integration/" // Adjust this to your specific allowed directory
- if !strings.HasPrefix(filePath, allowedDir) {
- log.Fatalf("Error: File path %s is outside the allowed directory\n", filePath)
- }
-
// Read the Go source file
- src, err := os.ReadFile(filePath)
+ src, err := os.ReadFile(filePath) // #nosec G304
if err != nil {
log.Fatalf("Error reading file %s: %v\n", filePath, err)
}