Skip to content

Commit

Permalink
Support multiple keys with AvailableSethKeyNum
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl committed May 15, 2024
1 parent d7ada9b commit ef712a0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) {
}

if b.hasSeth {
seth, err := actions_seth.GetChainClientWithConfigFunction(b.testConfig, networkConfig, actions_seth.OneEphemeralKeysLiveTestnetAutoFixFn)
seth, err := actions_seth.GetChainClient(b.testConfig, networkConfig)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions integration-tests/load/vrfv2/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
vrfcommon "github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/common"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2"
vrfv2_config "github.com/smartcontractkit/chainlink/integration-tests/testconfig/vrfv2"
"github.com/smartcontractkit/chainlink/integration-tests/utils"
)

const RootKeyNum = 0

type BHSTestGun struct {
contracts *vrfcommon.VRFContracts
subIDs []uint64
Expand Down Expand Up @@ -54,7 +53,7 @@ func (m *BHSTestGun) Call(_ *wasp.Generator) *wasp.Response {
*m.testConfig.General.NumberOfWords,
*m.testConfig.General.RandomnessRequestCountPerRequest,
*m.testConfig.General.RandomnessRequestCountPerRequestDeviation,
RootKeyNum,
utils.AvailableSethKeyNum(m.sethClient),
)
//todo - might need to store randRequestBlockNumber and blockhash to verify that it was stored in BHS contract at the end of the test
if err != nil {
Expand Down Expand Up @@ -111,7 +110,7 @@ func (m *SingleHashGun) Call(_ *wasp.Generator) *wasp.Response {
randomnessRequestCountPerRequest,
*vrfv2Config.RandomnessRequestCountPerRequestDeviation,
vrfv2Config.RandomWordsFulfilledEventTimeout.Duration,
RootKeyNum,
utils.AvailableSethKeyNum(m.sethClient),
)
if err != nil {
return &wasp.Response{Error: err.Error(), Failed: true}
Expand Down
7 changes: 3 additions & 4 deletions integration-tests/load/vrfv2plus/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (
vrfcommon "github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/common"
"github.com/smartcontractkit/chainlink/integration-tests/actions/vrf/vrfv2plus"
vrfv2plus_config "github.com/smartcontractkit/chainlink/integration-tests/testconfig/vrfv2plus"
"github.com/smartcontractkit/chainlink/integration-tests/utils"
)

const RootKeyNum = 0

type BHSTestGun struct {
contracts *vrfcommon.VRFContracts
keyHash [32]byte
Expand Down Expand Up @@ -60,7 +59,7 @@ func (m *BHSTestGun) Call(_ *wasp.Generator) *wasp.Response {
billingType,
vrfv2PlusConfig,
m.logger,
RootKeyNum,
utils.AvailableSethKeyNum(m.sethClient),
)
//todo - might need to store randRequestBlockNumber and blockhash to verify that it was stored in BHS contract at the end of the test
if err != nil {
Expand Down Expand Up @@ -119,7 +118,7 @@ func (m *SingleHashGun) Call(_ *wasp.Generator) *wasp.Response {
billingType,
vrfv2PlusConfig,
m.logger,
RootKeyNum,
utils.AvailableSethKeyNum(m.sethClient),
)
if err != nil {
return &wasp.Response{Error: err.Error(), Failed: true}
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/utils/seth.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,15 @@ func ValidateSethNetworkConfig(cfg *seth.Network) error {

return nil
}

const RootKeyNum = 0

// AvailableSethKeyNum returns the available Seth address index
// If there are multiple addresses, it will return any synced key
// Otherwise it will return the root key
func AvailableSethKeyNum(client *seth.Client) int {
if len(client.Addresses) > 1 {
return client.AnySyncedKey()
}
return RootKeyNum
}

0 comments on commit ef712a0

Please sign in to comment.