This repository was archived by the owner on Mar 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.go
More file actions
204 lines (173 loc) · 5.8 KB
/
setup.go
File metadata and controls
204 lines (173 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package cheqd_interchaintest
import (
"context"
_ "embed"
"testing"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
ibclocalhost "github.com/cosmos/ibc-go/v7/modules/light-clients/09-localhost"
"github.com/docker/docker/client"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
testutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testreporter"
didtypes "github.com/cheqd/cheqd-node/x/did/types"
resourcetypes "github.com/cheqd/cheqd-node/x/resource/types"
clocktypes "github.com/CosmosContracts/juno/v22/x/clock/types"
feepaytypes "github.com/CosmosContracts/juno/v22/x/feepay/types"
feesharetypes "github.com/CosmosContracts/juno/v22/x/feeshare/types"
globalfeetypes "github.com/CosmosContracts/juno/v22/x/globalfee/types"
tokenfactorytypes "github.com/CosmosContracts/juno/v22/x/tokenfactory/types"
)
func cheqdEncoding() *testutil.TestEncodingConfig {
cfg := cosmos.DefaultEncoding()
didtypes.RegisterInterfaces(cfg.InterfaceRegistry)
resourcetypes.RegisterInterfaces(cfg.InterfaceRegistry)
return &cfg
}
//go:embed artifacts/jwk.json
var jwk []byte
const (
userFunds = int64(10_000_000_000_000)
cheqdDenom = "ncheq"
junoDenom = "ujuno"
haltHeightDelta = uint64(20) // will propose upgrade this many blocks in the future
blocksAfterUpgrade = uint64(10)
ssiPath = "ssi-cheqd-juno-path"
path = "cheqd-juno-path"
relayerName = "relayer"
collectionId = "5rjaLzcffhGUH4nt4fyfAg"
resourceId = "9fbb1b86-91f8-4942-97b9-725b7714131c"
contractPath = "contracts_wasm/avida_sdjwt_verifier.wasm"
)
func GetJunoEncoding() *testutil.TestEncodingConfig {
cfg := cosmos.DefaultEncoding()
// register custom types
ibclocalhost.RegisterInterfaces(cfg.InterfaceRegistry)
wasmtypes.RegisterInterfaces(cfg.InterfaceRegistry)
feesharetypes.RegisterInterfaces(cfg.InterfaceRegistry)
tokenfactorytypes.RegisterInterfaces(cfg.InterfaceRegistry)
feepaytypes.RegisterInterfaces(cfg.InterfaceRegistry)
globalfeetypes.RegisterInterfaces(cfg.InterfaceRegistry)
clocktypes.RegisterInterfaces(cfg.InterfaceRegistry)
return &cfg
}
func GetCheqdConfig(cheqd_version string, repository string) ibc.ChainConfig {
return ibc.ChainConfig{
Type: "cosmos",
Name: "cheqd",
ChainID: "cheqd-mainnet-1",
Images: []ibc.DockerImage{
{
Repository: repository, // FOR LOCAL IMAGE USE: Docker Image Name
//Repository: "ghcr.io/strangelove-ventures/heighliner/cheqd", // FOR LOCAL IMAGE USE: Docker Image Name
Version: cheqd_version, // FOR LOCAL IMAGE USE: Docker Image Tag
UidGid: "1000:1000",
},
},
Bin: "cheqd-noded",
Bech32Prefix: "cheqd",
Denom: cheqdDenom,
CoinType: "118",
GasPrices: "50ncheq",
GasAdjustment: 1.3,
TrustingPeriod: "508h",
NoHostMount: false,
ConfigFileOverrides: nil,
EncodingConfig: cheqdEncoding(),
}
}
func GetJunoConfig() ibc.ChainConfig {
return ibc.ChainConfig{
Type: "cosmos",
Name: "juno",
ChainID: "juno-mainnet-1",
Images: []ibc.DockerImage{
{
Repository: "ghcr.io/cosmoscontracts/juno",
Version: "v22.0.0",
UidGid: "1025:1025",
},
},
Bin: "junod",
Bech32Prefix: "juno",
Denom: junoDenom,
CoinType: "118",
GasPrices: "50 ujuno",
GasAdjustment: 1.3,
TrustingPeriod: "508h",
NoHostMount: false,
ConfigFileOverrides: nil,
EncodingConfig: GetJunoEncoding(),
}
}
func CreateCheqdChain(
t *testing.T,
ctx context.Context,
numVals, numFull int,
cheqd_version string,
repository string,
) (*interchaintest.Interchain, *cosmos.CosmosChain, *client.Client, string) {
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "cheqd",
ChainName: "cheqd",
Version: cheqd_version,
ChainConfig: GetCheqdConfig(cheqd_version, repository),
NoHostMount: &[]bool{false}[0], // specify no mount
NumValidators: &numVals,
NumFullNodes: &numFull,
},
})
chains, err := cf.Chains(t.Name())
require.NoError(t, err)
ic := interchaintest.NewInterchain().AddChain(chains[0])
client, network := interchaintest.DockerSetup(t)
err = ic.Build(
ctx,
testreporter.NewNopReporter().RelayerExecReporter(t),
interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: true,
},
)
require.NoError(t, err)
return ic, chains[0].(*cosmos.CosmosChain), client, network
}
func CreateJunoChain(
t *testing.T,
ctx context.Context,
numVals, numFull int,
) (*interchaintest.Interchain, *cosmos.CosmosChain, *client.Client, string) {
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "juno",
ChainName: "juno",
Version: "v22.0.0",
ChainConfig: GetJunoConfig(),
NoHostMount: &[]bool{false}[0], // specify no mount
NumValidators: &numVals,
NumFullNodes: &numFull,
},
})
chains, err := cf.Chains(t.Name())
require.NoError(t, err)
ic := interchaintest.NewInterchain().AddChain(chains[0])
client, network := interchaintest.DockerSetup(t)
err = ic.Build(
ctx,
testreporter.NewNopReporter().RelayerExecReporter(t),
interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: true,
},
)
require.NoError(t, err)
return ic, chains[0].(*cosmos.CosmosChain), client, network
}