Skip to content

Commit

Permalink
refactor: refactor mebibyte in the test files
Browse files Browse the repository at this point in the history
  • Loading branch information
ZwangaMukwevho committed Jan 14, 2025
1 parent df0dee1 commit 7cf298a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
9 changes: 4 additions & 5 deletions app/default_overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"
"time"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/cosmos/cosmos-sdk/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down Expand Up @@ -65,8 +66,7 @@ func TestDefaultAppConfig(t *testing.T) {
assert.Equal(t, uint32(2), cfg.StateSync.SnapshotKeepRecent)
assert.Equal(t, "0.002utia", cfg.MinGasPrices)

mebibyte := 1048576
assert.Equal(t, 20*mebibyte, cfg.GRPC.MaxRecvMsgSize)
assert.Equal(t, 20*app.Mebibyte, cfg.GRPC.MaxRecvMsgSize)
}

func TestDefaultConsensusConfig(t *testing.T) {
Expand All @@ -93,9 +93,8 @@ func TestDefaultConsensusConfig(t *testing.T) {
assert.Equal(t, want, *got.Mempool)
})
t.Run("p2p overrides", func(t *testing.T) {
const mebibyte = 1048576
assert.Equal(t, int64(10*mebibyte), got.P2P.SendRate)
assert.Equal(t, int64(10*mebibyte), got.P2P.RecvRate)
assert.Equal(t, int64(10*app.Mebibyte), got.P2P.SendRate)
assert.Equal(t, int64(10*app.Mebibyte), got.P2P.RecvRate)
})
}

Expand Down
4 changes: 2 additions & 2 deletions app/test/big_blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (s *BigBlobSuite) SetupSuite() {
s.accounts = testfactory.GenerateAccounts(1)

tmConfig := testnode.DefaultTendermintConfig()
tmConfig.Mempool.MaxTxBytes = 10 * mebibyte
tmConfig.Mempool.MaxTxBytes = 10 * app.Mebibyte

cParams := testnode.DefaultConsensusParams()
cParams.Block.MaxBytes = 10 * mebibyte
cParams.Block.MaxBytes = 10 * app.Mebibyte

cfg := testnode.DefaultConfig().
WithFundedAccounts(s.accounts...).
Expand Down
2 changes: 1 addition & 1 deletion app/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (s *IntegrationTestSuite) TestMaxBlockSize() {
for i, tx := range txs {
// The default CometBFT mempool MaxTxBytes is 1 MiB so the generators in
// this test must create transactions that are smaller than that.
require.LessOrEqual(t, len(tx), 1*mebibyte)
require.LessOrEqual(t, len(tx), 1*app.Mebibyte)

res, err := s.cctx.Context.BroadcastTxSync(tx)
require.NoError(t, err)
Expand Down
1 change: 0 additions & 1 deletion app/test/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ package app_test

const (
kibibyte = 1024
mebibyte = 1024 * kibibyte
)
2 changes: 1 addition & 1 deletion test/util/testnode/comet_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func customTendermintConfig() *tmconfig.Config {
// Override the MaxBodyBytes to allow the testnode to accept very large
// transactions and respond to queries with large responses (200 MiB was
// chosen only as an arbitrary large number).
tmCfg.RPC.MaxBodyBytes = 200 * mebibyte
tmCfg.RPC.MaxBodyBytes = 200 * Mebibyte

tmCfg.RPC.TimeoutBroadcastTxCommit = time.Minute
return tmCfg
Expand Down
2 changes: 1 addition & 1 deletion test/util/testnode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

const (
kibibyte = 1024 // bytes
mebibyte = 1_048_576 // bytes
Mebibyte = 1_048_576 // bytes
DefaultValidatorAccountName = "validator"
DefaultInitialBalance = genesis.DefaultInitialBalance
)
Expand Down
9 changes: 4 additions & 5 deletions x/blob/ante/blob_share_decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
)

const (
mebibyte = 1_048_576 // 1 MiB
squareSize = 64
)

Expand All @@ -42,7 +41,7 @@ func TestBlobShareDecorator(t *testing.T) {
{
name: "want no error if appVersion v1 and 8 MiB blob",
blobsPerPFB: 1,
blobSize: 8 * mebibyte,
blobSize: 8 * testnode.Mebibyte,
appVersion: v1.Version,
},
{
Expand All @@ -54,13 +53,13 @@ func TestBlobShareDecorator(t *testing.T) {
{
name: "PFB with 1 blob that is 1 MiB",
blobsPerPFB: 1,
blobSize: 1 * mebibyte,
blobSize: 1 * testnode.Mebibyte,
appVersion: v2.Version,
},
{
name: "PFB with 1 blob that is 2 MiB",
blobsPerPFB: 1,
blobSize: 2 * mebibyte,
blobSize: 2 * testnode.Mebibyte,
appVersion: v2.Version,
// This test case should return an error because a square size of 64
// has exactly 2 MiB of total capacity so the total blob capacity
Expand All @@ -76,7 +75,7 @@ func TestBlobShareDecorator(t *testing.T) {
{
name: "PFB with 2 blobs that are 1 MiB each",
blobsPerPFB: 2,
blobSize: 1 * mebibyte,
blobSize: 1 * testnode.Mebibyte,
appVersion: v2.Version,
// This test case should return an error for the same reason a
// single blob that is 2 MiB returns an error.
Expand Down
7 changes: 4 additions & 3 deletions x/blob/ante/max_total_blob_size_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/celestiaorg/celestia-app/v3/app/encoding"
v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
ante "github.com/celestiaorg/celestia-app/v3/x/blob/ante"
blob "github.com/celestiaorg/celestia-app/v3/x/blob/types"
"github.com/celestiaorg/go-square/v2/share"
Expand Down Expand Up @@ -43,14 +44,14 @@ func TestMaxTotalBlobSizeDecorator(t *testing.T) {
{
name: "PFB with 1 blob that is 1 MiB",
pfb: &blob.MsgPayForBlobs{
BlobSizes: []uint32{mebibyte},
BlobSizes: []uint32{testnode.Mebibyte},
},
appVersion: v1.Version,
},
{
name: "PFB with 1 blob that is 2 MiB",
pfb: &blob.MsgPayForBlobs{
BlobSizes: []uint32{2 * mebibyte},
BlobSizes: []uint32{2 * testnode.Mebibyte},
},
appVersion: v1.Version,
// This test case should return an error because a square size of 64
Expand All @@ -68,7 +69,7 @@ func TestMaxTotalBlobSizeDecorator(t *testing.T) {
{
name: "PFB with 2 blobs that are 1 MiB each",
pfb: &blob.MsgPayForBlobs{
BlobSizes: []uint32{mebibyte, mebibyte},
BlobSizes: []uint32{testnode.Mebibyte, testnode.Mebibyte},
},
appVersion: v1.Version,
// This test case should return an error for the same reason a
Expand Down

0 comments on commit 7cf298a

Please sign in to comment.