Skip to content

Commit 89e6d79

Browse files
authored
add families and types for blockchains as constants (#1794)
* add families and types for blockchains as constants * pin tron image * changeset * docs
1 parent 7f71e19 commit 89e6d79

File tree

9 files changed

+45
-15
lines changed

9 files changed

+45
-15
lines changed

book/src/framework/components/blockchains/tron.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
```toml
55
[blockchain_a]
66
type = "tron"
7-
# image = "tronbox/tre" is default image
7+
# image = "tronbox/tre:1.0.3" is default image
88
```
99
Default port is `9090`
1010

framework/.changeset/v0.7.5.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Add chain type to output
2+
- Expose constants for types and families
3+
- Pin tronbox/tre image, recent changes do not work on amd64

framework/components/blockchain/aptos.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ func newAptos(in *Input) (*Output, error) {
127127
}
128128
return &Output{
129129
UseCache: true,
130-
Family: "aptos",
130+
Type: in.Type,
131+
Family: FamilyAptos,
131132
ContainerName: containerName,
132133
Nodes: []*Node{
133134
{

framework/components/blockchain/blockchain.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ import (
88
"github.com/smartcontractkit/chainlink-testing-framework/framework"
99
)
1010

11+
// Blockchain node type
12+
const (
13+
TypeAnvil = "anvil"
14+
TypeAnvilZKSync = "anvil-zksync"
15+
TypeGeth = "geth"
16+
TypeBesu = "besu"
17+
TypeSolana = "solana"
18+
TypeAptos = "aptos"
19+
TypeSui = "sui"
20+
TypeTron = "tron"
21+
)
22+
23+
// Blockchain node family
24+
const (
25+
FamilyEVM = "evm"
26+
FamilySolana = "solana"
27+
FamilyAptos = "aptos"
28+
FamilySui = "sui"
29+
FamilyTron = "tron"
30+
)
31+
1132
// Input is a blockchain network configuration params
1233
type Input struct {
1334
// Common EVM fields
@@ -36,6 +57,7 @@ type Input struct {
3657
// Output is a blockchain network output, ChainID and one or more nodes that forms the network
3758
type Output struct {
3859
UseCache bool `toml:"use_cache"`
60+
Type string `toml:"type"`
3961
Family string `toml:"family"`
4062
ContainerName string `toml:"container_name"`
4163
NetworkSpecificData *NetworkSpecificData `toml:"network_specific_data"`
@@ -61,21 +83,21 @@ func NewBlockchainNetwork(in *Input) (*Output, error) {
6183
var out *Output
6284
var err error
6385
switch in.Type {
64-
case "anvil":
86+
case TypeAnvil:
6587
out, err = newAnvil(in)
66-
case "geth":
88+
case TypeGeth:
6789
out, err = newGeth(in)
68-
case "besu":
90+
case TypeBesu:
6991
out, err = newBesu(in)
70-
case "solana":
92+
case TypeSolana:
7193
out, err = newSolana(in)
72-
case "aptos":
94+
case TypeAptos:
7395
out, err = newAptos(in)
74-
case "sui":
96+
case TypeSui:
7597
out, err = newSui(in)
76-
case "tron":
98+
case TypeTron:
7799
out, err = newTron(in)
78-
case "anvil-zksync":
100+
case TypeAnvilZKSync:
79101
out, err = newAnvilZksync(in)
80102
default:
81103
return nil, fmt.Errorf("blockchain type is not supported or empty, must be 'anvil' or 'geth'")

framework/components/blockchain/containers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ func createGenericEvmContainer(in *Input, req testcontainers.ContainerRequest, u
6969

7070
output := Output{
7171
UseCache: true,
72-
Family: "evm",
72+
Type: in.Type,
73+
Family: FamilyEVM,
7374
ChainID: in.ChainID,
7475
ContainerName: containerName,
7576
Container: c,

framework/components/blockchain/solana.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ func newSolana(in *Input) (*Output, error) {
144144

145145
return &Output{
146146
UseCache: true,
147-
Family: "solana",
147+
Type: in.Type,
148+
Family: FamilySolana,
148149
ContainerName: containerName,
149150
Container: c,
150151
Nodes: []*Node{

framework/components/blockchain/sui.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ func newSui(in *Input) (*Output, error) {
152152
}
153153
return &Output{
154154
UseCache: true,
155-
Family: "sui",
155+
Type: in.Type,
156+
Family: FamilySui,
156157
ContainerName: containerName,
157158
NetworkSpecificData: &NetworkSpecificData{SuiAccount: suiAccount},
158159
Nodes: []*Node{

framework/components/blockchain/tron.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ func newTron(in *Input) (*Output, error) {
115115
return &Output{
116116
UseCache: true,
117117
ChainID: in.ChainID,
118-
Family: "tron",
118+
Type: in.Type,
119+
Family: FamilyTron,
119120
ContainerName: containerName,
120121
Nodes: []*Node{
121122
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[blockchain_a]
22
type = "tron"
3-
image = "tronbox/tre"
3+
image = "tronbox/tre:1.0.3"

0 commit comments

Comments
 (0)