@@ -264,41 +264,24 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
264264 }
265265}
266266
267- func configWithChainSelector (t * testing.T , chainSelector string ) * values.Map {
268- m , err := values .NewMap (map [string ]any {
269- "targetChainSelector" : chainSelector ,
270- })
271- require .NoError (t , err )
272- return m
273- }
274-
275- func solConfig (t * testing.T , chainSelector string , meta solana.AccountMetaSlice ) * values.Map {
276- m , err := values .NewMap (map [string ]any {
277- "targetChainSelector" : chainSelector ,
278- "solana" : map [string ]any {
279- "remaining_accounts" : meta ,
280- },
281- })
282-
283- require .NoError (t , err )
284- return m
285- }
286-
287267func TestSecureMintAggregatorConfig_Validation (t * testing.T ) {
268+ acc1 := [32 ]byte {4 , 5 , 6 }
269+
288270 tests := []struct {
289271 name string
290272 chainSelector string
291273 dataID string
274+ solanaAccounts solana.AccountMetaSlice
292275 expectedChainSelector chainSelector
293276 expectedDataID [16 ]byte
294277 expectError bool
295278 errorMsg string
296279 }{
297280 {
298-
299- name : "valid chain selector and dataID" ,
281+ name : "valid chain selector, dataID and solana accounts" ,
300282 chainSelector : "1" ,
301283 dataID : "0x01c508f42b0201320000000000000000" ,
284+ solanaAccounts : solana.AccountMetaSlice {& solana.AccountMeta {PublicKey : acc1 , IsWritable : true , IsSigner : false }},
302285 expectedChainSelector : 1 ,
303286 expectedDataID : [16 ]byte {0x01 , 0xc5 , 0x08 , 0xf4 , 0x2b , 0x02 , 0x01 , 0x32 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 },
304287 expectError : false ,
@@ -359,16 +342,29 @@ func TestSecureMintAggregatorConfig_Validation(t *testing.T) {
359342 expectError : true ,
360343 errorMsg : "dataID must be 16 bytes" ,
361344 },
345+ {
346+ name : "solana account context with invalid public key" ,
347+ chainSelector : "1" ,
348+ dataID : "0x01c508f42b0201320000000000000000" ,
349+ solanaAccounts : solana.AccountMetaSlice {& solana.AccountMeta {PublicKey : [32 ]byte {}}},
350+ expectError : true ,
351+ errorMsg : "solana account context public key must not be all zeros" ,
352+ },
362353 }
363354
364- // TODO(gg): add tests for solana config?
365-
366355 for _ , tt := range tests {
367356 t .Run (tt .name , func (t * testing.T ) {
368- configMap , err := values . WrapMap ( map [string ]any {
357+ rawCfg := map [string ]any {
369358 "targetChainSelector" : tt .chainSelector ,
370359 "dataID" : tt .dataID ,
371- })
360+ }
361+ if len (tt .solanaAccounts ) > 0 {
362+ rawCfg ["solana" ] = map [string ]any {
363+ "remaining_accounts" : tt .solanaAccounts ,
364+ }
365+ }
366+
367+ configMap , err := values .WrapMap (rawCfg )
372368 require .NoError (t , err )
373369
374370 aggregator , err := NewSecureMintAggregator (* configMap )
@@ -383,6 +379,7 @@ func TestSecureMintAggregatorConfig_Validation(t *testing.T) {
383379 require .NoError (t , err )
384380 assert .Equal (t , tt .expectedChainSelector , aggregator .(* SecureMintAggregator ).config .TargetChainSelector )
385381 assert .Equal (t , tt .expectedDataID , aggregator .(* SecureMintAggregator ).config .DataID )
382+ assert .Equal (t , tt .solanaAccounts , aggregator .(* SecureMintAggregator ).config .Solana .AccountContext )
386383 })
387384 }
388385}
0 commit comments