-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add testRandBlob CLI for testground tests (#1311)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview ATM, `test-infra` repo is using my fork of celestia-app, which is not ok. We need a CLI command for tests to trigger PFBs from apps' side, hence we have added another command named `TestRandBlob` This PR contains another renaming, touching removal of `Wire` prefixes Ref: celestiaorg/test-infra#159 <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords --------- Co-authored-by: Rootul P <[email protected]> Co-authored-by: Evan Forbes <[email protected]>
- Loading branch information
1 parent
422be7f
commit 852a229
Showing
4 changed files
with
88 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/celestiaorg/celestia-app/testutil/namespace" | ||
"github.com/celestiaorg/celestia-app/testutil/testfactory" | ||
"github.com/celestiaorg/celestia-app/x/blob/types" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
) | ||
|
||
// CmdTestRandBlob is triggered by testground's tests as part of apps' node scenario | ||
// to increase the block size by user-defined amount. | ||
// | ||
// CAUTION: This func should not be used in production env! | ||
func CmdTestRandBlob() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "TestRandBlob [blobSize]", | ||
Short: "Generates a random blob for a random namespace to be published to the Celestia blockchain", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
// decode the blob size | ||
size, err := strconv.Atoi(args[0]) | ||
if err != nil { | ||
return fmt.Errorf("failure to decode blob size: %w", err) | ||
} | ||
|
||
nid := namespace.RandomBlobNamespace() | ||
coreBlob := testfactory.GenerateBlobsWithNamespace(1, size, nid) | ||
blob, err := types.NewBlob(coreBlob[0].NamespaceID, coreBlob[0].Data) | ||
if err != nil { | ||
return fmt.Errorf("failure on generating random blob: %w", err) | ||
} | ||
|
||
return broadcastPFB(cmd, blob) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters