Skip to content

Commit

Permalink
Updated PDALookup internal field to use codec
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Jan 28, 2025
1 parent 92d11d6 commit da75f6d
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 186 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/jackc/pgx/v4 v4.18.3
github.com/pelletier/go-toml/v2 v2.2.3
github.com/prometheus/client_golang v1.20.5
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250121205514-f73e2f86c23b
github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db h1:W5r1QLevaqmbGimB9F3JMJyiw/qTXRATFi5DbmzEVNc=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90 h1:zLARR/tDnpp471QWvDCnUFB5WK9XzP7dZTqIBQjUMNM=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f h1:u09xYqvXIikqspsnTba8EDyif1eoWuFbZG+iCFCj118=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f h1:6YomtETcLQzuAWOYwsWkApmEV6Wj1q0fTHJe/WRAJgE=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92 h1:9zmJi4TctSNvmVdmRh2UpbNRDnrWKYn4o+PZDAIhqqc=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92/go.mod h1:V3BHfvLnQNBUoZ4bGjD29ZPhyzPE++DkYkhvPb9tcRs=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250121205514-f73e2f86c23b h1:TO1pwFeQKDOmv3loFiLJvYhtymuTgQUw9WgtwK1rueg=
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ require (
github.com/slack-go/slack v0.15.0 // indirect
github.com/smartcontractkit/chain-selectors v1.0.36 // indirect
github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f // indirect
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e // indirect
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250115135646-ac859d85e7e3 // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1227,10 +1227,10 @@ github.com/smartcontractkit/chain-selectors v1.0.36 h1:KSpO8I+JOiuyN4FuXsV471sPo
github.com/smartcontractkit/chain-selectors v1.0.36/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db h1:W5r1QLevaqmbGimB9F3JMJyiw/qTXRATFi5DbmzEVNc=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250122132616-0b8ae69756db/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90 h1:zLARR/tDnpp471QWvDCnUFB5WK9XzP7dZTqIBQjUMNM=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250122150024-c1b7ba41ee90/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f h1:u09xYqvXIikqspsnTba8EDyif1eoWuFbZG+iCFCj118=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250127195852-3ea463336e7f/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f h1:6YomtETcLQzuAWOYwsWkApmEV6Wj1q0fTHJe/WRAJgE=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250127195852-3ea463336e7f/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92 h1:9zmJi4TctSNvmVdmRh2UpbNRDnrWKYn4o+PZDAIhqqc=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250121163309-3e179a73cb92/go.mod h1:V3BHfvLnQNBUoZ4bGjD29ZPhyzPE++DkYkhvPb9tcRs=
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0=
Expand Down
45 changes: 23 additions & 22 deletions integration-tests/relayinterface/lookups_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package relayinterface

import (
"reflect"
"testing"
"time"

Expand Down Expand Up @@ -30,6 +29,8 @@ type TestAccountArgs struct {
Inner InnerAccountArgs
}

var testContractIDL = chainwriter.FetchTestContractIDL()

func TestAccountContant(t *testing.T) {
t.Run("AccountConstant resolves valid address", func(t *testing.T) {
expectedAddr := chainwriter.GetRandomPubKey(t)
Expand All @@ -46,7 +47,7 @@ func TestAccountContant(t *testing.T) {
IsSigner: true,
IsWritable: true,
}
result, err := constantConfig.Resolve(tests.Context(t), nil, nil, nil)
result, err := constantConfig.Resolve(tests.Context(t), nil, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -74,7 +75,7 @@ func TestAccountLookups(t *testing.T) {
IsSigner: chainwriter.MetaBool{Value: true},
IsWritable: chainwriter.MetaBool{Value: true},
}
result, err := lookupConfig.Resolve(ctx, testArgs, nil, nil)
result, err := lookupConfig.Resolve(ctx, testArgs, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -108,7 +109,7 @@ func TestAccountLookups(t *testing.T) {
IsSigner: chainwriter.MetaBool{Value: true},
IsWritable: chainwriter.MetaBool{Value: true},
}
result, err := lookupConfig.Resolve(ctx, testArgs, nil, nil)
result, err := lookupConfig.Resolve(ctx, testArgs, nil, nil, testContractIDL)
require.NoError(t, err)
for i, meta := range result {
require.Equal(t, expectedMeta[i], meta)
Expand All @@ -129,7 +130,7 @@ func TestAccountLookups(t *testing.T) {
IsSigner: chainwriter.MetaBool{Value: true},
IsWritable: chainwriter.MetaBool{Value: true},
}
_, err := lookupConfig.Resolve(ctx, testArgs, nil, nil)
_, err := lookupConfig.Resolve(ctx, testArgs, nil, nil, testContractIDL)
require.Error(t, err)
})

Expand Down Expand Up @@ -159,7 +160,7 @@ func TestAccountLookups(t *testing.T) {
},
}

result, err := lookupConfig.Resolve(ctx, args, nil, nil)
result, err := lookupConfig.Resolve(ctx, args, nil, nil, testContractIDL)
require.NoError(t, err)

for i, meta := range result {
Expand Down Expand Up @@ -197,7 +198,7 @@ func TestAccountLookups(t *testing.T) {
Bitmaps: []uint64{5, 3},
}

_, err := lookupConfig.Resolve(ctx, args, nil, nil)
_, err := lookupConfig.Resolve(ctx, args, nil, nil, testContractIDL)
require.Contains(t, err.Error(), "bitmap value is not a single value")
})

Expand All @@ -224,7 +225,7 @@ func TestAccountLookups(t *testing.T) {
},
}

_, err := lookupConfig.Resolve(ctx, args, nil, nil)
_, err := lookupConfig.Resolve(ctx, args, nil, nil, testContractIDL)
require.Contains(t, err.Error(), "error reading bitmap from location")
})

Expand All @@ -251,7 +252,7 @@ func TestAccountLookups(t *testing.T) {
},
}

_, err := lookupConfig.Resolve(ctx, args, nil, nil)
_, err := lookupConfig.Resolve(ctx, args, nil, nil, testContractIDL)
require.Contains(t, err.Error(), "invalid value format at path")
})
}
Expand Down Expand Up @@ -284,7 +285,7 @@ func TestPDALookups(t *testing.T) {
IsWritable: true,
}

result, err := pdaLookup.Resolve(ctx, nil, nil, nil)
result, err := pdaLookup.Resolve(ctx, nil, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -319,7 +320,7 @@ func TestPDALookups(t *testing.T) {
"another_seed": seed2,
}

result, err := pdaLookup.Resolve(ctx, args, nil, nil)
result, err := pdaLookup.Resolve(ctx, args, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand All @@ -339,7 +340,7 @@ func TestPDALookups(t *testing.T) {
"test_seed": []byte("data"),
}

_, err := pdaLookup.Resolve(ctx, args, nil, nil)
_, err := pdaLookup.Resolve(ctx, args, nil, nil, testContractIDL)
require.Error(t, err)
require.Contains(t, err.Error(), "key not found")
})
Expand Down Expand Up @@ -375,7 +376,7 @@ func TestPDALookups(t *testing.T) {
"another_seed": seed2,
}

result, err := pdaLookup.Resolve(ctx, args, nil, nil)
result, err := pdaLookup.Resolve(ctx, args, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -413,7 +414,7 @@ func TestPDALookups(t *testing.T) {
"array_seed": arraySeed,
}

result, err := pdaLookup.Resolve(ctx, args, nil, nil)
result, err := pdaLookup.Resolve(ctx, args, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -453,7 +454,7 @@ func TestPDALookups(t *testing.T) {
"seed2": arraySeed2,
}

result, err := pdaLookup.Resolve(ctx, args, nil, nil)
result, err := pdaLookup.Resolve(ctx, args, nil, nil, testContractIDL)
require.NoError(t, err)
require.Equal(t, expectedMeta, result)
})
Expand Down Expand Up @@ -489,7 +490,7 @@ func TestLookupTables(t *testing.T) {
DerivedLookupTables: nil,
StaticLookupTables: []solana.PublicKey{table},
}
_, staticTableMap, resolveErr := cw.ResolveLookupTables(ctx, nil, lookupConfig)
_, staticTableMap, resolveErr := cw.ResolveLookupTables(ctx, nil, lookupConfig, testContractIDL)
require.NoError(t, resolveErr)
require.Equal(t, pubKeys, staticTableMap[table])
})
Expand All @@ -510,7 +511,7 @@ func TestLookupTables(t *testing.T) {
},
StaticLookupTables: nil,
}
derivedTableMap, _, resolveErr := cw.ResolveLookupTables(ctx, nil, lookupConfig)
derivedTableMap, _, resolveErr := cw.ResolveLookupTables(ctx, nil, lookupConfig, testContractIDL)
require.NoError(t, resolveErr)

addresses, ok := derivedTableMap["DerivedTable"][table.String()]
Expand Down Expand Up @@ -538,7 +539,7 @@ func TestLookupTables(t *testing.T) {
StaticLookupTables: nil,
}

_, _, err = cw.ResolveLookupTables(ctx, nil, lookupConfig)
_, _, err = cw.ResolveLookupTables(ctx, nil, lookupConfig, testContractIDL)
require.Error(t, err)
require.Contains(t, err.Error(), "error fetching account info for table") // Example error message
})
Expand All @@ -551,7 +552,7 @@ func TestLookupTables(t *testing.T) {
StaticLookupTables: []solana.PublicKey{invalidTable},
}

_, _, err = cw.ResolveLookupTables(ctx, nil, lookupConfig)
_, _, err = cw.ResolveLookupTables(ctx, nil, lookupConfig, testContractIDL)
require.Error(t, err)
require.Contains(t, err.Error(), "error fetching account info for table") // Example error message
})
Expand Down Expand Up @@ -579,7 +580,7 @@ func TestLookupTables(t *testing.T) {
},
}

derivedTableMap, _, err := cw.ResolveLookupTables(ctx, testArgs, lookupConfig)
derivedTableMap, _, err := cw.ResolveLookupTables(ctx, testArgs, lookupConfig, testContractIDL)
require.NoError(t, err)

addresses, ok := derivedTableMap["DerivedTable"][table.String()]
Expand Down Expand Up @@ -615,7 +616,7 @@ func TestLookupTables(t *testing.T) {
IsSigner: false,
IsWritable: false,
InternalField: chainwriter.InternalField{
Type: reflect.TypeOf(chainwriter.DataAccount{}),
TypeName: "LookupTableDataAccount",
Location: "LookupTable",
},
},
Expand All @@ -624,7 +625,7 @@ func TestLookupTables(t *testing.T) {
StaticLookupTables: nil,
}

derivedTableMap, _, err := cw.ResolveLookupTables(ctx, args, lookupConfig)
derivedTableMap, _, err := cw.ResolveLookupTables(ctx, args, lookupConfig, testContractIDL)
require.NoError(t, err)

addresses, ok := derivedTableMap["DerivedTable"][lookupTable.String()]
Expand Down
Loading

0 comments on commit da75f6d

Please sign in to comment.