Skip to content

Dev#121

Merged
JaCoderX merged 2 commits into
mainfrom
dev
Mar 11, 2026
Merged

Dev#121
JaCoderX merged 2 commits into
mainfrom
dev

Conversation

@JaCoderX
Copy link
Copy Markdown
Member

@JaCoderX JaCoderX commented Mar 11, 2026

Summary by CodeRabbit

  • Tests
    • Enhanced test reliability for broadcaster update transaction verification with improved search logic across pending transactions and more robust transaction matching.

…UpdateTests

This commit improves the logic for retrieving broadcaster update requests from pending transactions within the BroadcasterUpdateTests class. The updated implementation ensures that the correct operation type is checked against pending transactions, allowing for more robust identification of broadcaster update requests. This enhancement addresses potential issues with unrelated pending transactions and improves the clarity of the test's output when a broadcaster update request is created.
feat: enhance broadcaster update transaction retrieval in Broadcaster…
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

A test utility for broadcaster updates now robustly searches across all pending transactions to locate BROADCASTER_UPDATE operations using case-insensitive matching, replacing simplistic transaction handling in two test flows.

Changes

Cohort / File(s) Summary
Pending Transaction Lookup Enhancement
scripts/sanity/secure-ownable/broadcaster-update-tests.cjs
Replaced basic transaction retrieval with comprehensive iteration through all pending transactions, introducing expectedOpType constant and case-insensitive operation type matching. Updated both createBroadcasterRequestAndDeriveTxId and createBroadcasterRequestForTimeDelayApproval flows to poll until matching transaction is found or failure occurs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through pending queues,
Finding broadcasters with improved views,
No more simple searches—now we scan with care,
Case-insensitive matching floating through the air! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Dev' is vague and generic, providing no meaningful information about the actual changes made to the broadcaster update tests. Use a descriptive title that clearly summarizes the main change, such as 'Improve broadcaster update transaction detection with robust pending transaction search'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/sanity/secure-ownable/broadcaster-update-tests.cjs`:
- Around line 482-495: The current loop over pending transactions returns the
first BROADCASTER_UPDATE matching expectedOpType, which may pick a stale
request; modify the search in the block that calls
this.callContractMethod(this.contract.methods.getTransaction(txId)) so it
filters transactions by the same requester identity used by
createBroadcasterRequestAndDeriveTxId() and iterates newest-first (reverse the
pending array) before returning; specifically ensure you check
txRecord.params.requester (or the equivalent requester field) matches the
requester used when creating the request and only then return the txRecord when
op matches expectedOpType.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4790b4e9-779f-4185-88ff-2f0060850e44

📥 Commits

Reviewing files that changed from the base of the PR and between e3fde1b and cf73007.

📒 Files selected for processing (1)
  • scripts/sanity/secure-ownable/broadcaster-update-tests.cjs

Comment on lines +482 to +495
if (pending && pending.length > 0) {
for (const txId of pending) {
const txRecord = await this.callContractMethod(this.contract.methods.getTransaction(txId));
const op = txRecord && txRecord.params && txRecord.params.operationType;
if (
op &&
(op === expectedOpType ||
(typeof op === 'string' &&
typeof expectedOpType === 'string' &&
op.toLowerCase() === expectedOpType.toLowerCase()))
) {
console.log(` ✅ Broadcaster update request created (txId: ${txRecord.txId || txId})`);
return txRecord;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don’t return the first matching broadcaster-update tx.

This helper creates a new request immediately above, but Lines 483-494 return the first pending BROADCASTER_UPDATE they find. If another broadcaster-update request is already pending, the test can attach to the stale tx instead of the one it just created. createBroadcasterRequestAndDeriveTxId() already scopes its fallback by requester and searches newest-first; this helper should apply the same constraint here.

💡 Proposed fix
         for (let i = 0; i < 5; i++) {
             const pending = await this.callContractMethod(this.contract.methods.getPendingTransactions());
             if (pending && pending.length > 0) {
-                for (const txId of pending) {
+                let newestMatch = null;
+                for (const txId of pending) {
                     const txRecord = await this.callContractMethod(this.contract.methods.getTransaction(txId));
                     const op = txRecord && txRecord.params && txRecord.params.operationType;
+                    const requester = txRecord && txRecord.params && txRecord.params.requester;
                     if (
                         op &&
                         (op === expectedOpType ||
                             (typeof op === 'string' &&
                                 typeof expectedOpType === 'string' &&
-                                op.toLowerCase() === expectedOpType.toLowerCase()))
+                                op.toLowerCase() === expectedOpType.toLowerCase())) &&
+                        requester &&
+                        requester.toLowerCase() === this.roles.owner.toLowerCase()
                     ) {
-                        console.log(`  ✅ Broadcaster update request created (txId: ${txRecord.txId || txId})`);
-                        return txRecord;
+                        if (!newestMatch || BigInt(txRecord.txId) > BigInt(newestMatch.txId)) {
+                            newestMatch = txRecord;
+                        }
                     }
                 }
+                if (newestMatch) {
+                    console.log(`  ✅ Broadcaster update request created (txId: ${newestMatch.txId})`);
+                    return newestMatch;
+                }
             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (pending && pending.length > 0) {
for (const txId of pending) {
const txRecord = await this.callContractMethod(this.contract.methods.getTransaction(txId));
const op = txRecord && txRecord.params && txRecord.params.operationType;
if (
op &&
(op === expectedOpType ||
(typeof op === 'string' &&
typeof expectedOpType === 'string' &&
op.toLowerCase() === expectedOpType.toLowerCase()))
) {
console.log(` ✅ Broadcaster update request created (txId: ${txRecord.txId || txId})`);
return txRecord;
}
if (pending && pending.length > 0) {
let newestMatch = null;
for (const txId of pending) {
const txRecord = await this.callContractMethod(this.contract.methods.getTransaction(txId));
const op = txRecord && txRecord.params && txRecord.params.operationType;
const requester = txRecord && txRecord.params && txRecord.params.requester;
if (
op &&
(op === expectedOpType ||
(typeof op === 'string' &&
typeof expectedOpType === 'string' &&
op.toLowerCase() === expectedOpType.toLowerCase())) &&
requester &&
requester.toLowerCase() === this.roles.owner.toLowerCase()
) {
if (!newestMatch || BigInt(txRecord.txId) > BigInt(newestMatch.txId)) {
newestMatch = txRecord;
}
}
}
if (newestMatch) {
console.log(` ✅ Broadcaster update request created (txId: ${newestMatch.txId})`);
return newestMatch;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/sanity/secure-ownable/broadcaster-update-tests.cjs` around lines 482
- 495, The current loop over pending transactions returns the first
BROADCASTER_UPDATE matching expectedOpType, which may pick a stale request;
modify the search in the block that calls
this.callContractMethod(this.contract.methods.getTransaction(txId)) so it
filters transactions by the same requester identity used by
createBroadcasterRequestAndDeriveTxId() and iterates newest-first (reverse the
pending array) before returning; specifically ensure you check
txRecord.params.requester (or the equivalent requester field) matches the
requester used when creating the request and only then return the txRecord when
op matches expectedOpType.

@JaCoderX JaCoderX merged commit 95f3ee5 into main Mar 11, 2026
3 checks passed
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.

1 participant