Skip to content

Add artifact to create post event#93

Merged
JesseAbram merged 2 commits intodevfrom
Add-artifact-to-post-event
Jan 23, 2026
Merged

Add artifact to create post event#93
JesseAbram merged 2 commits intodevfrom
Add-artifact-to-post-event

Conversation

@JesseAbram
Copy link
Contributor

Adds an artifact for event tracking to Create Post in bulletin see https://github.com/sourcenetwork/orbis-rs/issues/22 for more details on why this was needed

@JesseAbram JesseAbram requested review from Lodek and iverc January 22, 2026 18:27
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds an artifact string field to post creation and post-created event messages, updates keeper logic and tests to pass and emit the artifact, and expands go.mod with many indirect dependencies and a tools block.

Changes

Cohort / File(s) Summary
Dependency & Tool Configuration
go.mod
Adds many indirect dependencies to the require block and appends a tool block listing codegen and linting tools (e.g., buf, protoc-gen-*, golangci-lint).
Protocol Buffer Definitions
proto/sourcehub/bulletin/events.proto, proto/sourcehub/bulletin/tx.proto
Adds string artifact = 5 to EventPostCreated and MsgCreatePost.
Module Implementation & Tests
x/bulletin/keeper/msg_server.go, x/bulletin/keeper/grpc_query_test.go, x/bulletin/keeper/msg_server_test.go
CreatePost now includes artifact in emitted EventPostCreated; tests updated/added to create posts with Artifact and assert the event contains it; a test typo was fixed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.84%. Comparing base (6f52d93) to head (61c402a).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #93      +/-   ##
==========================================
+ Coverage   47.75%   47.84%   +0.09%     
==========================================
  Files         276      276              
  Lines       16194    16195       +1     
==========================================
+ Hits         7733     7749      +16     
+ Misses       7657     7642      -15     
  Partials      804      804              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Lodek Lodek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope you came out the other side stronger after coding some Go 🫡

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
x/bulletin/keeper/msg_server_test.go (1)

208-212: Test name was fixed but expected error message still has typo.

The test case name on line 208 was corrected to "invalid creator address", but the expErrMsg on line 212 still contains "nvalid creator address" (missing the leading 'i'). This inconsistency suggests the fix was incomplete.

Proposed fix
 		{
 			name:      "create post (error: invalid creator address)",
 			input:     &types.MsgCreatePost{},
 			setup:     func() {},
 			expErr:    true,
-			expErrMsg: "nvalid creator address",
+			expErrMsg: "invalid creator address",
 		},
🧹 Nitpick comments (1)
x/bulletin/keeper/msg_server_test.go (1)

391-400: Consider more robust event attribute assertions.

Accessing event attributes by hardcoded index (ev.Attributes[0], [1], [2]) is fragile. If the event attribute order changes in the proto definition or emission logic, this test will fail with confusing messages or silently pass incorrect assertions.

Consider also verifying:

  1. The event type (ev.Type)
  2. Attribute keys alongside values for self-documenting assertions
Suggested improvement
 	ev := evs[0]
+	require.Equal(t, "sourcehub.bulletin.EventPostCreated", ev.Type)
-	require.Equal(t, `"session-id"`, ev.Attributes[0].Value)
-	require.Equal(t, eventDid, ev.Attributes[1].Value)
-	require.Equal(t, `"bulletin/ns1"`, ev.Attributes[2].Value)
+	// Assert attribute keys and values for robustness
+	require.Equal(t, "artifact", ev.Attributes[0].Key)
+	require.Equal(t, `"session-id"`, ev.Attributes[0].Value)
+	require.Equal(t, "creator", ev.Attributes[1].Key)
+	require.Equal(t, eventDid, ev.Attributes[1].Value)
+	require.Equal(t, "namespace", ev.Attributes[2].Key)
+	require.Equal(t, `"bulletin/ns1"`, ev.Attributes[2].Value)

Alternatively, create a helper that finds attributes by key:

func findEventAttr(ev sdk.Event, key string) string {
    for _, attr := range ev.Attributes {
        if attr.Key == key {
            return attr.Value
        }
    }
    return ""
}
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30ef670 and 61c402a.

📒 Files selected for processing (1)
  • x/bulletin/keeper/msg_server_test.go
🧰 Additional context used
🧬 Code graph analysis (1)
x/bulletin/keeper/msg_server_test.go (3)
testutil/sample/sample.go (1)
  • AccAddress (10-14)
x/bulletin/keeper/acp_utils.go (1)
  • RegisterNamespace (83-93)
x/bulletin/types/tx.pb.go (6)
  • MsgRegisterNamespace (239-242)
  • MsgRegisterNamespace (246-246)
  • MsgRegisterNamespace (247-249)
  • MsgCreatePost (127-133)
  • MsgCreatePost (137-137)
  • MsgCreatePost (138-140)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (1)
x/bulletin/keeper/msg_server_test.go (1)

361-401: Good test coverage for artifact in event emission.

The test properly:

  • Resets the event manager to isolate the test
  • Sets up the required policy and namespace
  • Creates a post with the new Artifact field
  • Verifies the artifact appears in the emitted event

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@JesseAbram JesseAbram merged commit 989f677 into dev Jan 23, 2026
2 of 8 checks passed
@Lodek Lodek deleted the Add-artifact-to-post-event branch January 28, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants