Skip to content

Commit

Permalink
remove unused lines (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Dec 2, 2023
1 parent aa69d15 commit b2e53aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 62 deletions.
61 changes: 3 additions & 58 deletions integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
chain_selectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/wasp"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
Expand All @@ -31,35 +30,23 @@ import (
type CCIPE2ELoad struct {
t *testing.T
Lane *actions.CCIPLane
NoOfReq int64 // no of Request fired - required for balance assertion at the end
totalGEFee *big.Int
BalanceStats BalanceStats // balance assertion details
NoOfReq int64 // approx no of Request fired
CurrentMsgSerialNo *atomic.Int64 // current msg serial number in the load sequence
InitialSourceBlockNum uint64
InitialDestBlockNum uint64 // blocknumber before the first message is fired in the load sequence
CallTimeOut time.Duration // max time to wait for various on-chain events
reports *testreporters.CCIPLaneStats
msg router.ClientEVM2AnyMessage
MaxDataBytes uint32
SendMaxDataIntermittently bool
LastFinalizedTxBlock atomic.Uint64
LastFinalizedTimestamp atomic.Time
}
type BalanceStats struct {
SourceBalanceReq map[string]*big.Int
SourceBalanceAssertions []testhelpers.BalanceAssertion
DestBalanceReq map[string]*big.Int
DestBalanceAssertions []testhelpers.BalanceAssertion
}

func NewCCIPLoad(t *testing.T, lane *actions.CCIPLane, timeout time.Duration, noOfReq int64, reporter *testreporters.CCIPLaneStats) *CCIPE2ELoad {
func NewCCIPLoad(t *testing.T, lane *actions.CCIPLane, timeout time.Duration, noOfReq int64) *CCIPE2ELoad {
return &CCIPE2ELoad{
t: t,
Lane: lane,
CurrentMsgSerialNo: atomic.NewInt64(1),
CallTimeOut: timeout,
NoOfReq: noOfReq,
reports: reporter,
SendMaxDataIntermittently: false,
}
}
Expand All @@ -81,22 +68,6 @@ func (c *CCIPE2ELoad) BeforeAllCall(msgType string) {
err := sourceCCIP.Common.ChainClient.WaitForEvents()
require.NoError(c.t, err, "Failed to wait for events")

// save the current block numbers to use in various filter log requests
currentBlockOnSource, err := sourceCCIP.Common.ChainClient.LatestBlockNumber(context.Background())
require.NoError(c.t, err, "failed to fetch latest source block num")
currentBlockOnDest, err := destCCIP.Common.ChainClient.LatestBlockNumber(context.Background())
require.NoError(c.t, err, "failed to fetch latest dest block num")
c.InitialDestBlockNum = currentBlockOnDest
c.InitialSourceBlockNum = currentBlockOnSource
// collect the balance requirement to verify balances after transfer
sourceBalances, err := testhelpers.GetBalances(c.t, sourceCCIP.CollectBalanceRequirements())
require.NoError(c.t, err, "fetching source balance")
destBalances, err := testhelpers.GetBalances(c.t, destCCIP.CollectBalanceRequirements())
require.NoError(c.t, err, "fetching dest balance")
c.BalanceStats = BalanceStats{
SourceBalanceReq: sourceBalances,
DestBalanceReq: destBalances,
}
extraArgsV1, err := testhelpers.GetEVMExtraArgsV1(big.NewInt(100_000), false)
require.NoError(c.t, err, "Failed encoding the options field")

Expand Down Expand Up @@ -127,19 +98,6 @@ func (c *CCIPE2ELoad) BeforeAllCall(msgType string) {

sourceCCIP.Common.ChainClient.ParallelTransactions(false)
destCCIP.Common.ChainClient.ParallelTransactions(false)
// close all header subscriptions for dest chains
queuedEvents := destCCIP.Common.ChainClient.GetHeaderSubscriptions()
for subName := range queuedEvents {
destCCIP.Common.ChainClient.DeleteHeaderEventSubscription(subName)
}
// close all header subscriptions for source chains except for finalized header
queuedEvents = sourceCCIP.Common.ChainClient.GetHeaderSubscriptions()
for subName := range queuedEvents {
if subName == blockchain.FinalizedHeaderKey {
continue
}
sourceCCIP.Common.ChainClient.DeleteHeaderEventSubscription(subName)
}
}

func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.CallResult {
Expand All @@ -150,7 +108,7 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.CallResult {

lggr := c.Lane.Logger.With().Int("msg Number", int(msgSerialNo)).Logger()
stats := testreporters.NewCCIPRequestStats(msgSerialNo)
defer c.reports.UpdatePhaseStatsForReq(stats)
defer c.Lane.Reports.UpdatePhaseStatsForReq(stats)
// form the message for transfer
msgStr := fmt.Sprintf("new message with Id %d", msgSerialNo)

Expand Down Expand Up @@ -323,16 +281,3 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.CallResult {
res.Data = stats.StatusByPhase
return res
}

func (c *CCIPE2ELoad) ReportAcceptedLog() {
c.Lane.Logger.Info().Msg("Commit Report stats")
it, err := c.Lane.Dest.CommitStore.Instance.FilterReportAccepted(&bind.FilterOpts{Start: c.InitialDestBlockNum})
require.NoError(c.t, err, "report committed result")
i := 1
event := c.Lane.Logger.Info()
for it.Next() {
event.Interface(fmt.Sprintf("%d Report Intervals", i), it.Event.Report.Interval)
i++
}
event.Msgf("CommitStore-Reports Accepted")
}
5 changes: 1 addition & 4 deletions integration-tests/ccip-tests/load/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (l *loadArgs) Start() {
Str("Destination Network", lane.DestNetworkName).
Msg("Starting load for lane")

ccipLoad := NewCCIPLoad(l.TestCfg.Test, lane, l.TestCfg.TestGroupInput.PhaseTimeout.Duration(), 100000, lane.Reports)
ccipLoad := NewCCIPLoad(l.TestCfg.Test, lane, l.TestCfg.TestGroupInput.PhaseTimeout.Duration(), 100000)
ccipLoad.BeforeAllCall(l.TestCfg.TestGroupInput.MsgType)
if lane.TestEnv != nil && lane.TestEnv.K8Env != nil && lane.TestEnv.K8Env.Cfg != nil {
namespace = lane.TestEnv.K8Env.Cfg.Namespace
Expand Down Expand Up @@ -270,9 +270,6 @@ func (l *loadArgs) ApplyChaos() {

func (l *loadArgs) TearDown() {
if l.TestSetupArgs.TearDown != nil {
for i := range l.ccipLoad {
l.ccipLoad[i].ReportAcceptedLog()
}
require.NoError(l.t, l.TestSetupArgs.TearDown())
}
}
Expand Down

0 comments on commit b2e53aa

Please sign in to comment.