-
Notifications
You must be signed in to change notification settings - Fork 4
use []any instead of []uint8 for messageId and messageHash in synth events #318
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
| "encoding/hex" | ||
| "fmt" | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
|
|
@@ -226,7 +227,16 @@ func TestTransactionsIndexer(t *testing.T) { | |
| pollingInterval := 4 * time.Second | ||
| syncTimeout := 3 * time.Second | ||
|
|
||
| type OfframpExecutionStateChanged struct { | ||
| SourceChainSelector uint64 `json:"sourceChainSelector"` | ||
| SequenceNumber uint64 `json:"sequenceNumber"` | ||
| MessageId string `json:"messageId"` | ||
| MessageHash string `json:"messageHash"` | ||
| State int `json:"state"` | ||
| } | ||
|
|
||
| readerConfig := config.ChainReaderConfig{ | ||
| IsLoopPlugin: false, | ||
| Modules: map[string]*config.ChainReaderModule{ | ||
| "OffRamp": { | ||
| Name: "offramp", | ||
|
|
@@ -240,6 +250,7 @@ func TestTransactionsIndexer(t *testing.T) { | |
| Module: "offramp", | ||
| Event: "ExecutionStateChanged", | ||
| }, | ||
| ExpectedEventType: &OfframpExecutionStateChanged{}, | ||
| }, | ||
| "SourceChainConfigSet": { | ||
| Name: "offramp", | ||
|
|
@@ -277,7 +288,6 @@ func TestTransactionsIndexer(t *testing.T) { | |
| }, | ||
| }, | ||
| }, | ||
| IsLoopPlugin: false, | ||
| EventsIndexer: config.EventsIndexerConfig{ | ||
| PollingInterval: pollingInterval, | ||
| SyncTimeout: syncTimeout, | ||
|
|
@@ -354,15 +364,16 @@ func TestTransactionsIndexer(t *testing.T) { | |
|
|
||
| // helper: returns true if at least one event with the given key exists for the contract | ||
| hasEvent := func(contract types.BoundContract, key string) bool { | ||
| events, err := cReader.QueryKey(ctx, contract, query.KeyFilter{Key: key}, query.LimitAndSort{}, &database.EventRecord{}) | ||
| dataType := map[string]any{} | ||
| events, err := cReader.QueryKey(ctx, contract, query.KeyFilter{Key: key}, query.LimitAndSort{}, &dataType) | ||
| if err != nil { | ||
| log.Errorw("Error querying events", "contract", contract.Name, "key", key, "error", err) | ||
| return false | ||
| } | ||
| found := len(events) > 0 | ||
|
|
||
| if found { | ||
| log.Debugw("Event found") | ||
| log.Debugw("Event found (hasEvent)", "events", events) | ||
| } else { | ||
| log.Debugw("Event not found", events) | ||
| } | ||
|
|
@@ -380,7 +391,7 @@ func TestTransactionsIndexer(t *testing.T) { | |
| found := len(events) > 0 | ||
|
|
||
| if found { | ||
| log.Debugw("Event found") | ||
| log.Debugw("Event found (hasEventDBOnlyCheck)", "events", events) | ||
| } else { | ||
| log.Debugw("Event not found", events) | ||
| } | ||
|
|
@@ -450,6 +461,15 @@ func TestTransactionsIndexer(t *testing.T) { | |
| require.Eventually(t, func() bool { | ||
| return hasEvent(boundContracts[0], "ExecutionStateChanged") | ||
| }, 90*time.Second, 5*time.Second) | ||
|
|
||
| events, err := cReader.QueryKey(ctx, boundContracts[0], query.KeyFilter{Key: "ExecutionStateChanged"}, query.LimitAndSort{}, &OfframpExecutionStateChanged{}) | ||
| require.NoError(t, err) | ||
| require.NotEmpty(t, events) | ||
|
|
||
| executionStateChanged := events[0].Data.(*OfframpExecutionStateChanged) | ||
|
|
||
| require.True(t, strings.HasPrefix(executionStateChanged.MessageId, "0x")) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not check the exact
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we could parse The check just needs to verify that the type was read correctly. Given that it's a new contract being published, we can be fairly certain it's the same event we're looking for.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the exact messageId value check here: #301 |
||
| require.True(t, strings.HasPrefix(executionStateChanged.MessageHash, "0x")) | ||
| }) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we decode these values first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are already
[]byteor[32]bytenot strings. The issue here is that when inserting them as those types, the DB SDK auto-converts it tobase64, all we're doing here is going from[]byteto[]anyto match the JSON-friendly types that are inserted with regular events (comes fromparsedJson).This conversion effectively tells the DB SDK, we want to insert this slice as-is.