Skip to content

Commit d22e314

Browse files
authored
Merge pull request #103 from smartcontractkit/keeper_soak
Keeper soak test
2 parents 9965cc9 + e2af942 commit d22e314

File tree

5 files changed

+467
-1
lines changed

5 files changed

+467
-1
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ test_ocr: ## run ocr tests
6868
test_ocr_soak: ## run OCR soak test
6969
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@soak-ocr"
7070

71+
.PHONY: test_keeper_soak
72+
test_keeper_soak: ## run Keeper soak/performance test
73+
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@performance-keeper"
74+
7175
.PHONY: test_vrf_soak
7276
test_vrf_soak: ## run VRF soak test
7377
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@soak-vrf"

config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,5 @@ contracts:
239239
commit: 19ba7cfbe7b7c6ca7621b090e229b4ba1147e2e1
240240
ocr:
241241
path: ocr/artifacts/contract/src
242-
commit: f27c14a905c5735abbb6e0c9699e9d0e3e9b7217
242+
commit: f27c14a905c5735abbb6e0c9699e9d0e3e9b7217
243+

contracts/ethereum_contracts.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,63 @@ func (o *OffchainAggregatorRoundConfirmer) Wait() error {
789789
}
790790
}
791791

792+
// KeeperConsumerRoundConfirmer is a header subscription that awaits for a round of upkeeps
793+
type KeeperConsumerRoundConfirmer struct {
794+
instance KeeperConsumer
795+
upkeepsValue int
796+
doneChan chan struct{}
797+
context context.Context
798+
cancel context.CancelFunc
799+
}
800+
801+
// NewKeeperConsumerRoundConfirmer provides a new instance of a KeeperConsumerRoundConfirmer
802+
func NewKeeperConsumerRoundConfirmer(
803+
contract KeeperConsumer,
804+
counterValue int,
805+
timeout time.Duration,
806+
) *KeeperConsumerRoundConfirmer {
807+
ctx, ctxCancel := context.WithTimeout(context.Background(), timeout)
808+
return &KeeperConsumerRoundConfirmer{
809+
instance: contract,
810+
upkeepsValue: counterValue,
811+
doneChan: make(chan struct{}),
812+
context: ctx,
813+
cancel: ctxCancel,
814+
}
815+
}
816+
817+
// ReceiveBlock will query the latest Keeper round and check to see whether the round has confirmed
818+
func (o *KeeperConsumerRoundConfirmer) ReceiveBlock(_ client.NodeBlock) error {
819+
upkeeps, err := o.instance.Counter(context.Background())
820+
if err != nil {
821+
return err
822+
}
823+
l := log.Info().
824+
Str("Contract Address", o.instance.Address()).
825+
Int64("Upkeeps", upkeeps.Int64()).
826+
Int("Required upkeeps", o.upkeepsValue)
827+
if upkeeps.Int64() == int64(o.upkeepsValue) {
828+
l.Msg("Upkeep completed")
829+
o.doneChan <- struct{}{}
830+
} else {
831+
l.Msg("Waiting for upkeep round")
832+
}
833+
return nil
834+
}
835+
836+
// Wait is a blocking function that will wait until the round has confirmed, and timeout if the deadline has passed
837+
func (o *KeeperConsumerRoundConfirmer) Wait() error {
838+
for {
839+
select {
840+
case <-o.doneChan:
841+
o.cancel()
842+
return nil
843+
case <-o.context.Done():
844+
return fmt.Errorf("timeout waiting for upkeeps to confirm: %d", o.upkeepsValue)
845+
}
846+
}
847+
}
848+
792849
// EthereumStorage acts as a conduit for the ethereum version of the storage contract
793850
type EthereumStorage struct {
794851
client *client.EthereumClient

0 commit comments

Comments
 (0)