Skip to content

Commit 31bac06

Browse files
authored
fix(canton): register split MCMS api/core encoders in proposal decoder (#782)
## Summary - Add registry tests for the chainlink-canton MCMS bindings split (`mcms/api` vs `mcms/core`) - Ensures `ScheduleBatch`, `SetRoot`, and `ExecuteOp` resolve from the correct encoders after #781 ## Why `chore: bump chainlink-canton (#781)` does not trigger release-please; this `fix:` commit should bump to `0.47.1`.
1 parent 0b2bf69 commit 31bac06

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

sdk/canton/decoder_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import (
44
"encoding/hex"
55
"encoding/json"
66
"reflect"
7+
"strings"
78
"testing"
89

910
"github.com/stretchr/testify/require"
1011

1112
"github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/ccip/core"
1213
"github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/ccip/factory"
14+
mcmsapi "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/mcms/api"
15+
mcmscore "github.com/smartcontractkit/chainlink-canton/bindings/generated/latest/mcms/core"
1316
cantontypes "github.com/smartcontractkit/go-daml/pkg/types"
1417

1518
"github.com/smartcontractkit/mcms/types"
@@ -189,3 +192,66 @@ func TestRegistry_NoDrift(t *testing.T) {
189192
require.True(t, registered[enc], "encoderByContract[%q] is not in mcmsEncoders", name)
190193
}
191194
}
195+
196+
// TestRegistry_SplitMCMSEncoders guards the chainlink-canton bindings split where MCMS core
197+
// choices (SetRoot, ExecuteOp) and api choices (ScheduleBatch, …) live on separate encoders.
198+
func TestRegistry_SplitMCMSEncoders(t *testing.T) {
199+
t.Parallel()
200+
201+
apiEncoder := reflect.TypeFor[mcmsapi.MCMSEncoder]()
202+
coreEncoder := reflect.TypeFor[mcmscore.MCMSEncoder]()
203+
204+
require.Equal(t, apiEncoder, encoderByContract["MCMS"])
205+
require.Contains(t, mcmsEncoders, coreEncoder)
206+
require.Contains(t, mcmsEncoders, apiEncoder)
207+
208+
tests := []struct {
209+
name string
210+
choice string
211+
wantPkgSeg string
212+
}{
213+
{
214+
name: "timelock schedule batch",
215+
choice: "ScheduleBatch",
216+
wantPkgSeg: "/mcms/api",
217+
},
218+
{
219+
name: "set root",
220+
choice: "SetRoot",
221+
wantPkgSeg: "/mcms/core",
222+
},
223+
{
224+
name: "execute op",
225+
choice: "ExecuteOp",
226+
wantPkgSeg: "/mcms/core",
227+
},
228+
}
229+
230+
for _, tt := range tests {
231+
t.Run(tt.name, func(t *testing.T) {
232+
t.Parallel()
233+
234+
candidates := candidateArgTypes("MCMS", tt.choice)
235+
require.NotEmpty(t, candidates, "expected candidates for MCMS::%s", tt.choice)
236+
237+
found := false
238+
for _, c := range candidates {
239+
if strings.Contains(c.PkgPath(), tt.wantPkgSeg) {
240+
found = true
241+
break
242+
}
243+
}
244+
require.True(t, found, "expected a %s candidate from package %s, got %v",
245+
tt.choice, tt.wantPkgSeg, candidateTypeNames(candidates))
246+
})
247+
}
248+
}
249+
250+
func candidateTypeNames(candidateTypes []reflect.Type) []string {
251+
names := make([]string, len(candidateTypes))
252+
for i, t := range candidateTypes {
253+
names[i] = t.String()
254+
}
255+
256+
return names
257+
}

0 commit comments

Comments
 (0)