Skip to content

Commit 5f1e716

Browse files
committed
Add Getters
1 parent 9df5562 commit 5f1e716

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

chain/blockchain.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"slices"
99

1010
"github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos"
11+
"github.com/smartcontractkit/chainlink-deployments-framework/chain/canton"
1112
"github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
1213
"github.com/smartcontractkit/chainlink-deployments-framework/chain/solana"
1314
"github.com/smartcontractkit/chainlink-deployments-framework/chain/sui"
@@ -135,6 +136,10 @@ func (b BlockChains) TronChains() map[uint64]tron.Chain {
135136
return getChainsByType[tron.Chain, *tron.Chain](b)
136137
}
137138

139+
func (b BlockChains) CantonChains() map[uint64]canton.Chain {
140+
return getChainsByType[canton.Chain, *canton.Chain](b)
141+
}
142+
138143
// ChainSelectorsOption defines a function type for configuring ChainSelectors
139144
type ChainSelectorsOption func(*chainSelectorsOptions)
140145

chain/blockchain_test.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/smartcontractkit/chainlink-deployments-framework/chain"
1313
"github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos"
14+
"github.com/smartcontractkit/chainlink-deployments-framework/chain/canton"
1415
"github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
1516
"github.com/smartcontractkit/chainlink-deployments-framework/chain/solana"
1617
"github.com/smartcontractkit/chainlink-deployments-framework/chain/sui"
@@ -25,6 +26,7 @@ var aptosChain1 = aptos.Chain{Selector: chainsel.APTOS_LOCALNET.Selector}
2526
var suiChain1 = sui.Chain{ChainMetadata: sui.ChainMetadata{Selector: chainsel.SUI_LOCALNET.Selector}}
2627
var tonChain1 = ton.Chain{ChainMetadata: ton.ChainMetadata{Selector: chainsel.TON_LOCALNET.Selector}}
2728
var tronChain1 = tron.Chain{ChainMetadata: tron.ChainMetadata{Selector: chainsel.TRON_MAINNET.Selector}}
29+
var cantonChain1 = canton.Chain{Selector: chainsel.CANTON_LOCALNET.Selector}
2830

2931
func TestNewBlockChains(t *testing.T) {
3032
t.Parallel()
@@ -162,7 +164,7 @@ func TestBlockChainsAllChains(t *testing.T) {
162164
evmChain1.Selector, evmChain2.Selector,
163165
solanaChain1.Selector, aptosChain1.Selector,
164166
suiChain1.Selector, tonChain1.Selector,
165-
tronChain1.Selector,
167+
tronChain1.Selector, cantonChain1.Selector,
166168
}
167169

168170
assert.Len(t, allChains, len(expectedSelectors))
@@ -280,6 +282,21 @@ func TestBlockChainsGetters(t *testing.T) {
280282
},
281283
description: "should return all Tron chains",
282284
},
285+
{
286+
name: "CantonChains",
287+
runTest: func(t *testing.T, chains chain.BlockChains) {
288+
t.Helper()
289+
cantonChains := chains.CantonChains()
290+
expectedSelectors := []uint64{cantonChain1.Selector}
291+
292+
assert.Len(t, cantonChains, len(expectedSelectors), "unexpected number of Canton chains")
293+
294+
for _, selector := range expectedSelectors {
295+
_, exists := cantonChains[selector]
296+
assert.True(t, exists, "expected Canton chain with selector %d", selector)
297+
}
298+
},
299+
},
283300
}
284301

285302
// Run tests for both value and pointer chains
@@ -319,7 +336,7 @@ func TestBlockChainsListChainSelectors(t *testing.T) {
319336
evmChain1.ChainSelector(), evmChain2.ChainSelector(),
320337
solanaChain1.ChainSelector(), aptosChain1.ChainSelector(),
321338
suiChain1.ChainSelector(), tonChain1.ChainSelector(),
322-
tronChain1.ChainSelector(),
339+
tronChain1.ChainSelector(), cantonChain1.ChainSelector(),
323340
},
324341
description: "expected all chain selectors",
325342
},
@@ -359,6 +376,12 @@ func TestBlockChainsListChainSelectors(t *testing.T) {
359376
expectedIDs: []uint64{tronChain1.Selector},
360377
description: "expected Tron chain selectors",
361378
},
379+
{
380+
name: "with family filter - Canton",
381+
options: []chain.ChainSelectorsOption{chain.WithFamily(chainsel.FamilyCanton)},
382+
expectedIDs: []uint64{cantonChain1.Selector},
383+
description: "expected Canton chain selectors",
384+
},
362385
{
363386
name: "with multiple families",
364387
options: []chain.ChainSelectorsOption{chain.WithFamily(chainsel.FamilyEVM), chain.WithFamily(chainsel.FamilySolana)},
@@ -370,7 +393,7 @@ func TestBlockChainsListChainSelectors(t *testing.T) {
370393
options: []chain.ChainSelectorsOption{chain.WithChainSelectorsExclusion(
371394
[]uint64{evmChain1.Selector, aptosChain1.Selector}),
372395
},
373-
expectedIDs: []uint64{evmChain2.Selector, solanaChain1.Selector, suiChain1.Selector, tonChain1.Selector, tronChain1.Selector},
396+
expectedIDs: []uint64{evmChain2.Selector, solanaChain1.Selector, suiChain1.Selector, tonChain1.Selector, tronChain1.Selector, cantonChain1.Selector},
374397
description: "expected chain selectors excluding 1 and 4",
375398
},
376399
{
@@ -405,6 +428,7 @@ func buildBlockChains() chain.BlockChains {
405428
suiChain1.ChainSelector(): suiChain1,
406429
tonChain1.ChainSelector(): tonChain1,
407430
tronChain1.ChainSelector(): tronChain1,
431+
cantonChain1.ChainSelector(): cantonChain1,
408432
})
409433

410434
return chains
@@ -428,6 +452,8 @@ func buildBlockChainsPointers() chain.BlockChains {
428452
pointerChains[selector] = &c
429453
case tron.Chain:
430454
pointerChains[selector] = &c
455+
case canton.Chain:
456+
pointerChains[selector] = &c
431457
default:
432458
continue // skip unsupported chains
433459
}

0 commit comments

Comments
 (0)