From 9c5ac32f821ea77b3fa8be4ef3e555fced41f4a2 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Thu, 6 Oct 2022 21:15:47 +0200 Subject: [PATCH] chore(ipld/plugin): multiple cleanups for linter and removal of dead code --- nodebuilder/tests/fraud_test.go | 2 +- nodebuilder/tests/swamp/swamp.go | 6 ++---- nodebuilder/tests/swamp/swamp_tx.go | 21 +-------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/nodebuilder/tests/fraud_test.go b/nodebuilder/tests/fraud_test.go index 7dd45160df..102eb86897 100644 --- a/nodebuilder/tests/fraud_test.go +++ b/nodebuilder/tests/fraud_test.go @@ -64,7 +64,7 @@ func TestFraudProofBroadcasting(t *testing.T) { // If we cannot get a height header within a timeframe it means the syncer was stopped // FIXME: Eventually, this should be a check on service registry managing and keeping // lifecycles of each Module. - syncCtx, syncCancel := context.WithTimeout(context.Background(), time.Millisecond*600) + syncCtx, syncCancel := context.WithTimeout(context.Background(), time.Millisecond*100) _, err = full.HeaderServ.GetByHeight(syncCtx, 100) require.ErrorIs(t, err, context.DeadlineExceeded) syncCancel() diff --git a/nodebuilder/tests/swamp/swamp.go b/nodebuilder/tests/swamp/swamp.go index 152b6e6344..efec7a0266 100644 --- a/nodebuilder/tests/swamp/swamp.go +++ b/nodebuilder/tests/swamp/swamp.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/bytes" tmrand "github.com/tendermint/tendermint/libs/rand" - "github.com/tendermint/tendermint/types" "go.uber.org/fx" "github.com/celestiaorg/celestia-app/testutil/testnode" @@ -32,8 +31,6 @@ import ( var blackholeIP6 = net.ParseIP("100::") -var queryEvent string = types.QueryForEvent(types.EventNewBlock).String() - // Swamp represents the main functionality that is needed for the test-case: // - Network to link the nodes // - CoreClient to share between Bridge nodes @@ -66,7 +63,7 @@ func NewSwamp(t *testing.T, options ...Option) *Swamp { var err error ctx := context.Background() - // we create an arbitray number of funded accounts + // we create an arbitrary number of funded accounts accounts := make([]string, 100) for i := 0; i < 10; i++ { accounts = append(accounts, tmrand.Str(9)) @@ -83,6 +80,7 @@ func NewSwamp(t *testing.T, options ...Option) *Swamp { require.NoError(t, err) cctx, cleanupGRPCServer, err := testnode.StartGRPCServer(app, testnode.DefaultAppConfig(), cctx) + require.NoError(t, err) swp := &Swamp{ t: t, diff --git a/nodebuilder/tests/swamp/swamp_tx.go b/nodebuilder/tests/swamp/swamp_tx.go index d6e78e7628..6ff89eaca5 100644 --- a/nodebuilder/tests/swamp/swamp_tx.go +++ b/nodebuilder/tests/swamp/swamp_tx.go @@ -2,31 +2,12 @@ package swamp import ( "context" - "fmt" "time" - "github.com/tendermint/tendermint/pkg/consts" - "github.com/celestiaorg/celestia-app/testutil/testnode" - - "github.com/celestiaorg/celestia-app/x/payment" - paytypes "github.com/celestiaorg/celestia-app/x/payment/types" ) -// SubmitData submits given data in the block. -// TODO(@Wondertan): This must be a real PFD using celestia-app, once we can run App in the Swamp. -func (s *Swamp) SubmitData(ctx context.Context, data []byte) error { - signer := paytypes.NewKeyringSigner(s.ClientContext.Keyring, s.accounts[0], s.ClientContext.ChainID) - resp, err := payment.SubmitPayForData(ctx, signer, s.ClientContext.GRPCClient, data[:consts.NamespaceSize], data, 10000000000) - if err != nil { - return err - } - if resp.Code != 0 { - return fmt.Errorf("invalid status code: %d", resp.Code) - } - return nil -} - +// FillBlocks produces the given amount of contiguous blocks with customizable size. func (s *Swamp) FillBlocks(_ context.Context, bsize, blocks int) error { btime := s.comps.CoreCfg.Consensus.CreateEmptyBlocksInterval timer := time.NewTimer(btime)