@@ -11,6 +11,8 @@ import (
1111 "github.com/smartcontractkit/chainlink-deployments-framework/changeset/sequenceutils"
1212 cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1313 "github.com/smartcontractkit/chainlink-deployments-framework/operations"
14+
15+ "github.com/smartcontractkit/cld-changesets/internal/familyregistry"
1416)
1517
1618func testSequence (id string ) * Sequence {
@@ -24,19 +26,39 @@ func testSequence(id string) *Sequence {
2426 )
2527}
2628
29+ func newTestRegistry () * familyregistry.Registry [Sequence , ChainInput ] {
30+ return familyregistry.New [Sequence , ChainInput ]("test deploy-custom-topology" )
31+ }
32+
2733func TestSequenceForChainSelector (t * testing.T ) {
2834 t .Parallel ()
2935
30- _ , err := Sequences .SequenceForChainSelector (0 )
31- require .Error (t , err )
36+ reg := newTestRegistry ()
37+
38+ tests := []struct {
39+ name string
40+ chainSelector uint64
41+ }{
42+ {name : "invalid selector" , chainSelector : 0 },
43+ }
44+
45+ for _ , tt := range tests {
46+ t .Run (tt .name , func (t * testing.T ) {
47+ t .Parallel ()
48+
49+ _ , err := reg .SequenceForChainSelector (tt .chainSelector )
50+ require .Error (t , err )
51+ })
52+ }
3253}
3354
3455func TestRegister_andLookup (t * testing.T ) {
3556 t .Parallel ()
3657
37- const family = "test-topology-family-a"
58+ reg := newTestRegistry ()
59+ const family = "test-deploy-custom-topology-family-a"
3860
39- Sequences .Register (Registration {
61+ reg .Register (Registration {
4062 Family : family ,
4163 Sequence : testSequence ("test-topology-seq-a" ),
4264 Verify : func (_ cldf.Environment , chains []ChainInput ) error {
@@ -48,9 +70,9 @@ func TestRegister_andLookup(t *testing.T) {
4870 },
4971 })
5072
51- require .Contains (t , Sequences .RegisteredFamilies (), family )
73+ require .Contains (t , reg .RegisteredFamilies (), family )
5274
53- seq , err := Sequences .SequenceForFamily (family )
75+ seq , err := reg .SequenceForFamily (family )
5476 require .NoError (t , err )
5577 require .NotNil (t , seq )
5678
@@ -67,7 +89,7 @@ func TestRegister_andLookup(t *testing.T) {
6789 t .Run (tt .name , func (t * testing.T ) {
6890 t .Parallel ()
6991
70- err := Sequences .VerifyForFamily (family , cldf.Environment {}, tt .chains )
92+ err := reg .VerifyForFamily (family , cldf.Environment {}, tt .chains )
7193 if tt .wantErr {
7294 require .Error (t , err )
7395 return
@@ -81,49 +103,68 @@ func TestRegister_andLookup(t *testing.T) {
81103func TestRegister_validationPanics (t * testing.T ) {
82104 t .Parallel ()
83105
106+ reg := newTestRegistry ()
107+
84108 tests := []struct {
85109 name string
86110 reg Registration
87111 }{
88112 {name : "empty family" , reg : Registration {Family : "" , Sequence : testSequence ("empty-family" )}},
89- {name : "nil sequence" , reg : Registration {Family : "test-topology-family-b" , Sequence : nil }},
113+ {name : "nil sequence" , reg : Registration {Family : "test-deploy-custom- topology-family-b" , Sequence : nil }},
90114 }
91115
92116 for _ , tt := range tests {
93117 t .Run (tt .name , func (t * testing.T ) {
94118 t .Parallel ()
95- require .Panics (t , func () { Sequences .Register (tt .reg ) })
119+ require .Panics (t , func () { reg .Register (tt .reg ) })
96120 })
97121 }
98122}
99123
100124func TestRegister_duplicatePanics (t * testing.T ) {
101125 t .Parallel ()
102126
103- const family = "test-topology-family-c"
104- Sequences .Register (Registration {Family : family , Sequence : testSequence ("test-topology-seq-c" )})
127+ reg := newTestRegistry ()
128+ const family = "test-deploy-custom-topology-family-c"
129+ reg .Register (Registration {Family : family , Sequence : testSequence ("test-topology-seq-c" )})
105130
106131 require .Panics (t , func () {
107- Sequences .Register (Registration {Family : family , Sequence : testSequence ("test-topology-seq-c-dup" )})
132+ reg .Register (Registration {Family : family , Sequence : testSequence ("test-topology-seq-c-dup" )})
108133 })
109134}
110135
111136func TestSequenceForFamily_errors (t * testing.T ) {
112137 t .Parallel ()
113138
114- const family = "test-topology-family-missing"
115- _ , err := Sequences .SequenceForFamily (family )
116- require .ErrorContains (t , err , fmt .Sprintf (`no sequence registered for family %q` , family ))
139+ reg := newTestRegistry ()
140+
141+ tests := []struct {
142+ name string
143+ family string
144+ }{
145+ {name : "missing family" , family : "test-deploy-custom-topology-family-missing" },
146+ }
147+
148+ for _ , tt := range tests {
149+ t .Run (tt .name , func (t * testing.T ) {
150+ t .Parallel ()
151+
152+ _ , err := reg .SequenceForFamily (tt .family )
153+ require .ErrorContains (t , err , fmt .Sprintf (`no sequence registered for family %q` , tt .family ))
154+ })
155+ }
117156}
118157
119158func TestVerifyForFamily (t * testing.T ) {
120159 t .Parallel ()
121160
122- const nilHookFamily = "test-topology-family-d"
123- Sequences .Register (Registration {Family : nilHookFamily , Sequence : testSequence ("test-topology-seq-d" )})
161+ reg := newTestRegistry ()
162+
163+ const nilHookFamily = "test-deploy-custom-topology-family-d"
164+ reg .Register (Registration {Family : nilHookFamily , Sequence : testSequence ("test-topology-seq-d" )})
124165
125- const wrapFamily = "test-topology-family-e"
126- Sequences .Register (Registration {
166+ const wrapFamily = "test-deploy-custom- topology-family-e"
167+ reg .Register (Registration {
127168 Family : wrapFamily ,
128169 Sequence : testSequence ("test-topology-seq-e" ),
129170 Verify : func (_ cldf.Environment , _ []ChainInput ) error {
@@ -137,7 +178,7 @@ func TestVerifyForFamily(t *testing.T) {
137178 chains []ChainInput
138179 wantErr string
139180 }{
140- {name : "missing family" , family : "test-topology-family-missing-verify" , wantErr : "no sequence registered for family" },
181+ {name : "missing family" , family : "test-deploy-custom- topology-family-missing-verify" , wantErr : "no sequence registered for family" },
141182 {name : "nil verify hook" , family : nilHookFamily },
142183 {name : "wrapped verify error" , family : wrapFamily , chains : []ChainInput {{ChainSelector : 1 }}, wantErr : "boom" },
143184 }
@@ -146,7 +187,7 @@ func TestVerifyForFamily(t *testing.T) {
146187 t .Run (tt .name , func (t * testing.T ) {
147188 t .Parallel ()
148189
149- err := Sequences .VerifyForFamily (tt .family , cldf.Environment {}, tt .chains )
190+ err := reg .VerifyForFamily (tt .family , cldf.Environment {}, tt .chains )
150191 if tt .wantErr == "" {
151192 require .NoError (t , err )
152193 return
0 commit comments