Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Feb 7, 2025
1 parent 7530d52 commit a3b7251
Showing 1 changed file with 9 additions and 52 deletions.
61 changes: 9 additions & 52 deletions integration-tests/relayinterface/chain_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import (
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/gagliardetto/solana-go/rpc/ws"
"github.com/gagliardetto/solana-go/text"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec"
Expand Down Expand Up @@ -112,7 +110,7 @@ func RunChainComponentsSolanaTests[T WrappedTestingT[T]](t T, it *SolanaChainCom
Name: "Test address groups where first namespace shares address with second namespace",
Test: func(t T) {
ctx := tests.Context(t)
cfg := it.contractReaderConfig
cfg := it.buildContractReaderConfig(t)
cfg.AddressShareGroups = [][]string{{AnyContractNameWithSharedAddress1, AnyContractNameWithSharedAddress2, AnyContractNameWithSharedAddress3}}
cr := it.GetContractReaderWithCustomCfg(t, cfg)

Expand All @@ -123,7 +121,7 @@ func RunChainComponentsSolanaTests[T WrappedTestingT[T]](t T, it *SolanaChainCom
require.Error(t, cr.Bind(ctx, bound1))
})

addressToBeShared := it.Helper.CreateAccount(t, AnyValueToReadWithoutAnArgument).String()
addressToBeShared := it.Helper.CreateAccount(t, *it, AnyContractName, AnyValueToReadWithoutAnArgument, TestStruct{}).String()
t.Run("Namespace is part of an address share group that doesn't have a registered address and provides an address during Bind", func(t T) {
bound1 := []types.BoundContract{{Name: AnyContractNameWithSharedAddress1, Address: addressToBeShared}}

Expand Down Expand Up @@ -227,46 +225,6 @@ type SolanaChainComponentsInterfaceTester[T WrappedTestingT[T]] struct {
// so that a test index can be injected as a PDA seed for each test
func (it *SolanaChainComponentsInterfaceTester[T]) Setup(t T) {
t.Cleanup(func() {})

anyContractReadDef := config.ChainContractReader{
IDL: mustUnmarshalIDL(t, string(it.Helper.GetJSONEncodedIDL(t))),
Reads: map[string]config.ReadDefinition{
MethodReturningUint64: {
ChainSpecificName: "DataAccount",
ReadType: config.Account,
OutputModifications: commoncodec.ModifiersConfig{
&commoncodec.PropertyExtractorConfig{FieldName: "U64Value"},
},
},
MethodReturningUint64Slice: {
ChainSpecificName: "DataAccount",
OutputModifications: commoncodec.ModifiersConfig{
&commoncodec.PropertyExtractorConfig{FieldName: "U64Slice"},
},
},
},
}

it.contractReaderConfig = config.ContractReader{
Namespaces: map[string]config.ChainContractReader{
AnyContractName: anyContractReadDef,
AnySecondContractName: {
IDL: mustUnmarshalIDL(t, string(it.Helper.GetJSONEncodedIDL(t))),
Reads: map[string]config.ReadDefinition{
MethodReturningUint64: {
ChainSpecificName: "DataAccount",
OutputModifications: commoncodec.ModifiersConfig{
&commoncodec.PropertyExtractorConfig{FieldName: "U64Value"},
},
},
},
},
// these are for testing shared address groups
AnyContractNameWithSharedAddress1: anyContractReadDef,
AnyContractNameWithSharedAddress2: anyContractReadDef,
AnyContractNameWithSharedAddress3: anyContractReadDef,
},
}
}

func (it *SolanaChainComponentsInterfaceTester[T]) Name() string {
Expand Down Expand Up @@ -301,23 +259,22 @@ func (it *SolanaChainComponentsInterfaceTester[T]) GetContractReader(t T) types.
return svc
}

func (it *SolanaChainComponentsInterfaceTester[T]) GetContractReaderWithCustomCfg(t T, cfg config.ContractReader) types.ContractReader {
func (it *SolanaChainComponentsInterfaceTester[T]) GetContractReaderWithCustomCfg(t T, contractReaderConfig config.ContractReader) types.ContractReader {
ctx := it.Helper.Context(t)
if it.cr != nil {
return it.cr
}
var events chainreader.EventsReader

svc, err := chainreader.NewContractReaderService(it.Helper.Logger(t), it.Helper.RPCClient(), cfg, nil)
svc, err := chainreader.NewContractReaderService(
it.Helper.Logger(t),
it.Helper.RPCClient(),
contractReaderConfig,
events)

require.NoError(t, err)
require.NoError(t, svc.Start(ctx))

it.cr = svc

return svc
}


func (it *SolanaChainComponentsInterfaceTester[T]) GetContractWriter(t T) types.ContractWriter {
chainWriterConfig := it.buildContractWriterConfig(t)
cw, err := chainwriter.NewSolanaChainWriterService(it.Helper.Logger(t), it.Helper.SolanaClient(), *it.Helper.TXM(), nil, chainWriterConfig)
Expand Down

0 comments on commit a3b7251

Please sign in to comment.