Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trigger id is generated from core repo, clean it up from plugin #214

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions pkg/basetypes.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package ocr2keepers

import (
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/crypto"
)

type UpkeepIdentifier []byte
Expand Down Expand Up @@ -205,7 +202,6 @@ func NewUpkeepPayload(uid *big.Int, tp int, block BlockKey, trigger Trigger, che
Trigger: trigger,
CheckData: checkData,
}
p.ID = p.GenerateID()
return p
}

Expand All @@ -221,12 +217,6 @@ func ValidateUpkeepPayload(p UpkeepPayload) error {
return ValidateTrigger(p.Trigger)
}

func (p UpkeepPayload) GenerateID() string {
id := fmt.Sprintf("%s:%s", p.Upkeep.ID, p.Trigger)
idh := crypto.Keccak256([]byte(id))
return hex.EncodeToString(idh[:])
}

type Trigger struct {
// BlockNumber is the block number in which the event occurred
BlockNumber int64
Expand Down
15 changes: 0 additions & 15 deletions pkg/basetypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,11 @@ package ocr2keepers

import (
"encoding/json"
"math/big"
"testing"

"github.com/stretchr/testify/assert"
)

func TestUpkeepPayload_GenerateID(t *testing.T) {
payload := NewUpkeepPayload(big.NewInt(111), 1, BlockKey("4"), Trigger{
BlockNumber: 11,
BlockHash: "0x11111",
Extension: "extension111",
}, []byte("check-data-111"))
assert.Equal(t, "0a73a5fd0fc265416da897fa9d08509c336c847f80236389426ef0b95506912b", payload.ID)

t.Run("empty payload id", func(t *testing.T) {
payload = UpkeepPayload{}
assert.Equal(t, "20c9c9e789a8e576ba9d58b1324869aefcd92545f80a5ee3834ac29b2531a8aa", payload.GenerateID())
})
}

func TestTriggerUnmarshal(t *testing.T) {
input := Trigger{
BlockNumber: 5,
Expand Down