@@ -12,7 +12,7 @@ import (
1212
1313 "github.com/smartcontractkit/chainlink-common/pkg/logger"
1414 pb "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/pb/securemint"
15- "github.com/smartcontractkit/chainlink-common/pkg/types/core"
15+ sm "github.com/smartcontractkit/chainlink-common/pkg/types/core/securemint "
1616 "github.com/stretchr/testify/assert"
1717 "github.com/stretchr/testify/mock"
1818)
@@ -27,29 +27,29 @@ func (m *mockExternalAdapterClient) GetPayload(ctx context.Context, in *pb.Block
2727 return args .Get (0 ).(* pb.ExternalAdapterPayload ), args .Error (1 )
2828}
2929
30- // mockExternalAdapter is a mock implementation of core .ExternalAdapter
30+ // mockExternalAdapter is a mock implementation of securemint .ExternalAdapter
3131type mockExternalAdapter struct {
3232 mock.Mock
3333}
3434
35- func (m * mockExternalAdapter ) GetPayload (ctx context.Context , blocks core .Blocks ) (core .ExternalAdapterPayload , error ) {
35+ func (m * mockExternalAdapter ) GetPayload (ctx context.Context , blocks sm .Blocks ) (sm .ExternalAdapterPayload , error ) {
3636 args := m .Called (ctx , blocks )
37- return args .Get (0 ).(core .ExternalAdapterPayload ), args .Error (1 )
37+ return args .Get (0 ).(sm .ExternalAdapterPayload ), args .Error (1 )
3838}
3939
4040func TestExternalAdapterClient_GetPayload (t * testing.T ) {
4141 tests := []struct {
4242 name string
43- inputBlocks core .Blocks
43+ inputBlocks sm .Blocks
4444 mockResponse * pb.ExternalAdapterPayload
4545 mockError error
46- expectedResult core .ExternalAdapterPayload
46+ expectedResult sm .ExternalAdapterPayload
4747 expectedError bool
4848 }{
4949 {
5050 name : "successful request with single chain" ,
51- inputBlocks : core .Blocks {
52- core .ChainSelector (1 ): core .BlockNumber (100 ),
51+ inputBlocks : sm .Blocks {
52+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
5353 },
5454 mockResponse : & pb.ExternalAdapterPayload {
5555 Mintables : map [uint64 ]* pb.BlockMintablePair {
@@ -68,28 +68,28 @@ func TestExternalAdapterClient_GetPayload(t *testing.T) {
6868 },
6969 },
7070 },
71- expectedResult : core .ExternalAdapterPayload {
72- Mintables : map [core .ChainSelector ]core .BlockMintablePair {
73- core .ChainSelector (1 ): {
74- Block : core .BlockNumber (100 ),
71+ expectedResult : sm .ExternalAdapterPayload {
72+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {
73+ sm .ChainSelector (1 ): {
74+ Block : sm .BlockNumber (100 ),
7575 Mintable : big .NewInt (1000 ),
7676 },
7777 },
78- ReserveInfo : core .ReserveInfo {
78+ ReserveInfo : sm .ReserveInfo {
7979 ReserveAmount : big .NewInt (5000 ),
8080 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
8181 },
82- LatestBlocks : core .Blocks {
83- core .ChainSelector (1 ): core .BlockNumber (100 ),
82+ LatestBlocks : sm .Blocks {
83+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
8484 },
8585 },
8686 expectedError : false ,
8787 },
8888 {
8989 name : "successful request with multiple chains" ,
90- inputBlocks : core .Blocks {
91- core .ChainSelector (1 ): core .BlockNumber (100 ),
92- core .ChainSelector (2 ): core .BlockNumber (200 ),
90+ inputBlocks : sm .Blocks {
91+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
92+ sm .ChainSelector (2 ): sm .BlockNumber (200 ),
9393 },
9494 mockResponse : & pb.ExternalAdapterPayload {
9595 Mintables : map [uint64 ]* pb.BlockMintablePair {
@@ -113,31 +113,31 @@ func TestExternalAdapterClient_GetPayload(t *testing.T) {
113113 },
114114 },
115115 },
116- expectedResult : core .ExternalAdapterPayload {
117- Mintables : map [core .ChainSelector ]core .BlockMintablePair {
118- core .ChainSelector (1 ): {
119- Block : core .BlockNumber (100 ),
116+ expectedResult : sm .ExternalAdapterPayload {
117+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {
118+ sm .ChainSelector (1 ): {
119+ Block : sm .BlockNumber (100 ),
120120 Mintable : big .NewInt (1000 ),
121121 },
122- core .ChainSelector (2 ): {
123- Block : core .BlockNumber (200 ),
122+ sm .ChainSelector (2 ): {
123+ Block : sm .BlockNumber (200 ),
124124 Mintable : big .NewInt (2000 ),
125125 },
126126 },
127- ReserveInfo : core .ReserveInfo {
127+ ReserveInfo : sm .ReserveInfo {
128128 ReserveAmount : big .NewInt (5000 ),
129129 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
130130 },
131- LatestBlocks : core .Blocks {
132- core .ChainSelector (1 ): core .BlockNumber (100 ),
133- core .ChainSelector (2 ): core .BlockNumber (200 ),
131+ LatestBlocks : sm .Blocks {
132+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
133+ sm .ChainSelector (2 ): sm .BlockNumber (200 ),
134134 },
135135 },
136136 expectedError : false ,
137137 },
138138 {
139139 name : "empty input blocks" ,
140- inputBlocks : core .Blocks {},
140+ inputBlocks : sm .Blocks {},
141141 mockResponse : & pb.ExternalAdapterPayload {
142142 Mintables : map [uint64 ]* pb.BlockMintablePair {},
143143 ReserveInfo : & pb.ReserveInfo {
@@ -148,29 +148,29 @@ func TestExternalAdapterClient_GetPayload(t *testing.T) {
148148 Value : map [uint64 ]uint64 {},
149149 },
150150 },
151- expectedResult : core .ExternalAdapterPayload {
152- Mintables : map [core .ChainSelector ]core .BlockMintablePair {},
153- ReserveInfo : core .ReserveInfo {
151+ expectedResult : sm .ExternalAdapterPayload {
152+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {},
153+ ReserveInfo : sm .ReserveInfo {
154154 ReserveAmount : big .NewInt (0 ),
155155 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
156156 },
157- LatestBlocks : core .Blocks {},
157+ LatestBlocks : sm .Blocks {},
158158 },
159159 expectedError : false ,
160160 },
161161 {
162162 name : "grpc error" ,
163- inputBlocks : core .Blocks {
164- core .ChainSelector (1 ): core .BlockNumber (100 ),
163+ inputBlocks : sm .Blocks {
164+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
165165 },
166166 mockResponse : nil ,
167167 mockError : errors .New ("grpc error" ),
168168 expectedError : true ,
169169 },
170170 {
171171 name : "invalid mintable string" ,
172- inputBlocks : core .Blocks {
173- core .ChainSelector (1 ): core .BlockNumber (100 ),
172+ inputBlocks : sm .Blocks {
173+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
174174 },
175175 mockResponse : & pb.ExternalAdapterPayload {
176176 Mintables : map [uint64 ]* pb.BlockMintablePair {
@@ -193,8 +193,8 @@ func TestExternalAdapterClient_GetPayload(t *testing.T) {
193193 },
194194 {
195195 name : "invalid reserve amount string" ,
196- inputBlocks : core .Blocks {
197- core .ChainSelector (1 ): core .BlockNumber (100 ),
196+ inputBlocks : sm .Blocks {
197+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
198198 },
199199 mockResponse : & pb.ExternalAdapterPayload {
200200 Mintables : map [uint64 ]* pb.BlockMintablePair {
@@ -239,7 +239,7 @@ func TestExternalAdapterClient_GetPayload(t *testing.T) {
239239 // Assertions
240240 if tt .expectedError {
241241 assert .Error (t , err )
242- assert .Equal (t , core .ExternalAdapterPayload {}, result )
242+ assert .Equal (t , sm .ExternalAdapterPayload {}, result )
243243 } else {
244244 assert .NoError (t , err )
245245 assert .Equal (t , tt .expectedResult , result )
@@ -255,7 +255,7 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
255255 tests := []struct {
256256 name string
257257 inputRequest * pb.Blocks
258- mockResponse core .ExternalAdapterPayload
258+ mockResponse sm .ExternalAdapterPayload
259259 mockError error
260260 expectedResult * pb.ExternalAdapterPayload
261261 expectedError bool
@@ -267,19 +267,19 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
267267 1 : 100 ,
268268 },
269269 },
270- mockResponse : core .ExternalAdapterPayload {
271- Mintables : map [core .ChainSelector ]core .BlockMintablePair {
272- core .ChainSelector (1 ): {
273- Block : core .BlockNumber (100 ),
270+ mockResponse : sm .ExternalAdapterPayload {
271+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {
272+ sm .ChainSelector (1 ): {
273+ Block : sm .BlockNumber (100 ),
274274 Mintable : big .NewInt (1000 ),
275275 },
276276 },
277- ReserveInfo : core .ReserveInfo {
277+ ReserveInfo : sm .ReserveInfo {
278278 ReserveAmount : big .NewInt (5000 ),
279279 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
280280 },
281- LatestBlocks : core .Blocks {
282- core .ChainSelector (1 ): core .BlockNumber (100 ),
281+ LatestBlocks : sm .Blocks {
282+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
283283 },
284284 },
285285 expectedResult : & pb.ExternalAdapterPayload {
@@ -309,24 +309,24 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
309309 2 : 200 ,
310310 },
311311 },
312- mockResponse : core .ExternalAdapterPayload {
313- Mintables : map [core .ChainSelector ]core .BlockMintablePair {
314- core .ChainSelector (1 ): {
315- Block : core .BlockNumber (100 ),
312+ mockResponse : sm .ExternalAdapterPayload {
313+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {
314+ sm .ChainSelector (1 ): {
315+ Block : sm .BlockNumber (100 ),
316316 Mintable : big .NewInt (1000 ),
317317 },
318- core .ChainSelector (2 ): {
319- Block : core .BlockNumber (200 ),
318+ sm .ChainSelector (2 ): {
319+ Block : sm .BlockNumber (200 ),
320320 Mintable : big .NewInt (2000 ),
321321 },
322322 },
323- ReserveInfo : core .ReserveInfo {
323+ ReserveInfo : sm .ReserveInfo {
324324 ReserveAmount : big .NewInt (5000 ),
325325 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
326326 },
327- LatestBlocks : core .Blocks {
328- core .ChainSelector (1 ): core .BlockNumber (100 ),
329- core .ChainSelector (2 ): core .BlockNumber (200 ),
327+ LatestBlocks : sm .Blocks {
328+ sm .ChainSelector (1 ): sm .BlockNumber (100 ),
329+ sm .ChainSelector (2 ): sm .BlockNumber (200 ),
330330 },
331331 },
332332 expectedResult : & pb.ExternalAdapterPayload {
@@ -358,13 +358,13 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
358358 inputRequest : & pb.Blocks {
359359 Value : map [uint64 ]uint64 {},
360360 },
361- mockResponse : core .ExternalAdapterPayload {
362- Mintables : map [core .ChainSelector ]core .BlockMintablePair {},
363- ReserveInfo : core .ReserveInfo {
361+ mockResponse : sm .ExternalAdapterPayload {
362+ Mintables : map [sm .ChainSelector ]sm .BlockMintablePair {},
363+ ReserveInfo : sm .ReserveInfo {
364364 ReserveAmount : big .NewInt (0 ),
365365 Timestamp : time .Unix (1640995200 , 0 ).UTC (),
366366 },
367- LatestBlocks : core .Blocks {},
367+ LatestBlocks : sm .Blocks {},
368368 },
369369 expectedResult : & pb.ExternalAdapterPayload {
370370 Mintables : map [uint64 ]* pb.BlockMintablePair {},
@@ -385,7 +385,7 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
385385 1 : 100 ,
386386 },
387387 },
388- mockResponse : core .ExternalAdapterPayload {},
388+ mockResponse : sm .ExternalAdapterPayload {},
389389 mockError : errors .New ("external adapter error" ),
390390 expectedError : true ,
391391 },
@@ -396,7 +396,7 @@ func TestExternalAdapterServer_GetPayload(t *testing.T) {
396396 // Create mock external adapter
397397 mockAdapter := new (mockExternalAdapter )
398398 if tt .mockError != nil {
399- mockAdapter .On ("GetPayload" , mock .Anything , mock .Anything ).Return (core .ExternalAdapterPayload {}, tt .mockError )
399+ mockAdapter .On ("GetPayload" , mock .Anything , mock .Anything ).Return (sm .ExternalAdapterPayload {}, tt .mockError )
400400 } else {
401401 mockAdapter .On ("GetPayload" , mock .Anything , mock .Anything ).Return (tt .mockResponse , nil )
402402 }
0 commit comments