Skip to content

Commit 92c0881

Browse files
test(mcms): optimise container startups
The original tests which include spinning up solana containers take up a good chunk of time ``` github.com/smartcontractkit/cld-changesets/legacy/mcms/changesets 112.753s coverage: 67.1% of statements github.com/smartcontractkit/cld-changesets/mcms/changesets/set-config 133.902s coverage: 91.2% of statements github.com/smartcontractkit/cld-changesets/mcms/solana/changesets/fund-mcm-pdas 60.253s coverage: 89.7% of statements ``` I have since optimised it by doing: - reduce container startups by having multple tests share the same container if there are no conflicts - reduce duplicate tests in the sequence or operation tests when the same flow has been covered by the integration test at changeset_test.go
1 parent 06e4c39 commit 92c0881

9 files changed

Lines changed: 830 additions & 1286 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Package solanatest provides test utilities for Solana MCMS integration tests.
2+
package solanatest
3+
4+
import (
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
9+
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
10+
mcmscontracts "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/contracts/mcms"
11+
12+
"github.com/smartcontractkit/cld-changesets/internal/semvers"
13+
"github.com/smartcontractkit/cld-changesets/legacy/pkg/family/solana/solutils"
14+
)
15+
16+
// NewDataStoreWithMCMSPrograms seeds a datastore with canonical MCMS program IDs.
17+
// The test validator preloads the same programs via WithSolanaContainer; program
18+
// deploy is skipped because artifacts lack -keypair.json files required by
19+
// solana program deploy for fixed program IDs.
20+
func NewDataStoreWithMCMSPrograms(t *testing.T, selector uint64) datastore.DataStore {
21+
t.Helper()
22+
23+
v := semvers.V1_0_0
24+
ds := datastore.NewMemoryDataStore()
25+
for _, entry := range []struct {
26+
addr string
27+
ct datastore.ContractType
28+
}{
29+
{solutils.GetProgramID(solutils.ProgAccessController), datastore.ContractType(mcmscontracts.AccessControllerProgram)},
30+
{solutils.GetProgramID(solutils.ProgMCM), datastore.ContractType(mcmscontracts.ManyChainMultisigProgram)},
31+
{solutils.GetProgramID(solutils.ProgTimelock), datastore.ContractType(mcmscontracts.RBACTimelockProgram)},
32+
} {
33+
require.NoError(t, ds.Addresses().Add(datastore.AddressRef{
34+
ChainSelector: selector,
35+
Address: entry.addr,
36+
Type: entry.ct,
37+
Version: &v,
38+
}))
39+
}
40+
41+
return ds.Seal()
42+
}

0 commit comments

Comments
 (0)