Skip to content

Commit

Permalink
remove contract decode
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhen1997 committed Dec 2, 2024
1 parent 3ea3a4f commit 8bae2c9
Showing 1 changed file with 29 additions and 34 deletions.
63 changes: 29 additions & 34 deletions core/capabilities/ccip/ccipevm/execcodecv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ package ccipevm
import (
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/codec"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/report_codec"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -68,15 +63,15 @@ func TestExecutePluginCodecV2(t *testing.T) {
ctx := testutils.Context(t)

// Deploy the contract
transactor := testutils.MustNewSimTransactor(t)
simulatedBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
transactor.From: {Balance: assets.Ether(1000).ToInt()},
}, 30e6)
address, _, _, err := report_codec.DeployReportCodec(transactor, simulatedBackend)
require.NoError(t, err)
simulatedBackend.Commit()
contract, err := report_codec.NewReportCodec(address, simulatedBackend)
require.NoError(t, err)
//transactor := testutils.MustNewSimTransactor(t)

Check failure on line 66 in core/capabilities/ccip/ccipevm/execcodecv2_test.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
//simulatedBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
// transactor.From: {Balance: assets.Ether(1000).ToInt()},
//}, 30e6)
//address, _, _, err := report_codec.DeployReportCodec(transactor, simulatedBackend)
//require.NoError(t, err)
//simulatedBackend.Commit()
//contract, err := report_codec.NewReportCodec(address, simulatedBackend)
//require.NoError(t, err)

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -92,27 +87,27 @@ func TestExecutePluginCodecV2(t *testing.T) {
testSetup(t)

// ignore msg hash in comparison
for i := range report.ChainReports {
for j := range report.ChainReports[i].Messages {
report.ChainReports[i].Messages[j].Header.MsgHash = cciptypes.Bytes32{}
report.ChainReports[i].Messages[j].Header.OnRamp = cciptypes.UnknownAddress{}
report.ChainReports[i].Messages[j].FeeToken = cciptypes.UnknownAddress{}
report.ChainReports[i].Messages[j].ExtraArgs = cciptypes.Bytes{}
report.ChainReports[i].Messages[j].FeeTokenAmount = cciptypes.BigInt{}
report.ChainReports[i].Messages[j].FeeValueJuels = cciptypes.BigInt{}
}
}
//for i := range report.ChainReports {

Check failure on line 90 in core/capabilities/ccip/ccipevm/execcodecv2_test.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
// for j := range report.ChainReports[i].Messages {
// report.ChainReports[i].Messages[j].Header.MsgHash = cciptypes.Bytes32{}
// report.ChainReports[i].Messages[j].Header.OnRamp = cciptypes.UnknownAddress{}
// report.ChainReports[i].Messages[j].FeeToken = cciptypes.UnknownAddress{}
// report.ChainReports[i].Messages[j].ExtraArgs = cciptypes.Bytes{}
// report.ChainReports[i].Messages[j].FeeTokenAmount = cciptypes.BigInt{}
// report.ChainReports[i].Messages[j].FeeValueJuels = cciptypes.BigInt{}
// }
//}

// decode using the contract
contractDecodedReport, err := contract.DecodeExecuteReport(&bind.CallOpts{Context: ctx}, bytes)
assert.NoError(t, err)
assert.Equal(t, len(report.ChainReports), len(contractDecodedReport))
for i, expReport := range report.ChainReports {
actReport := contractDecodedReport[i]
assert.Equal(t, expReport.OffchainTokenData, actReport.OffchainTokenData)
assert.Equal(t, len(expReport.Messages), len(actReport.Messages))
assert.Equal(t, uint64(expReport.SourceChainSelector), actReport.SourceChainSelector)
}
//// decode using the contract
//contractDecodedReport, err := contract.DecodeExecuteReport(&bind.CallOpts{Context: ctx}, bytes)

Check failure on line 102 in core/capabilities/ccip/ccipevm/execcodecv2_test.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
//assert.NoError(t, err)
//assert.Equal(t, len(report.ChainReports), len(contractDecodedReport))
//for i, expReport := range report.ChainReports {
// actReport := contractDecodedReport[i]
// assert.Equal(t, expReport.OffchainTokenData, actReport.OffchainTokenData)
// assert.Equal(t, len(expReport.Messages), len(actReport.Messages))
// assert.Equal(t, uint64(expReport.SourceChainSelector), actReport.SourceChainSelector)
//}

// decode using the codec
codecDecoded, err := cd.Decode(ctx, bytes)
Expand Down

0 comments on commit 8bae2c9

Please sign in to comment.