8000 test: composed contract with start date by MicBun · Pull Request #667 · trufnetwork/node · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: composed contract with start date #667

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

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

MicBun
Copy link
Member
@MicBun MicBun commented Oct 10, 2024

Description

  • added test for set taxonomy with start date

Related Problem

resolves: #666

How Has This Been Tested?

run go test

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new tasks for local certificate management and debugging builds.
    • Added a new procedure to disable taxonomies based on their version.
    • Enhanced the ability to manage taxonomies with start dates.
  • Bug Fixes

    • Updated unit testing tasks to focus on the correct directory.
  • Improvements

    • Streamlined taxonomy definitions and improved test suite organization.
    • Updated dependency versions for improved performance and stability.
  • Chores

    • Modified a script for downloading binaries with an updated URL.

@MicBun MicBun self-assigned this Oct 10, 2024
@MicBun MicBun linked an issue Oct 10, 2024 that may be closed by this pull request
@MicBun MicBun force-pushed the test/composedStartDate branch from 9a5e786 to 78aa227 Compare October 10, 2024 08:16
@MicBun MicBun requested a review from outerlook October 10, 2024 08:16
@MicBun MicBun marked this pull request as ready for review October 10, 2024 08:17
Copy link
coderabbitai bot commented Oct 10, 2024

Walkthrough

The pull request introduces several modifications across multiple files, primarily focusing on enhancing the testing framework and managing taxonomies within the codebase. Key changes include updates to the Taskfile.yml for improved task organization and the addition of new tasks, such as build:debug and local certificate management tasks. The go.mod file reflects an updated dependency version. Significant schema enhancements to the taxonomies table and related procedures are made in composed_stream_template.kf, along with corresponding updates to testing files to accommodate these changes.

Changes

File Path Change Summary
Taskfile.yml Updated test:unit command, added build:debug, setup:new-local-cert, and setup:local-cert tasks; modified compose-dev task; redefined benchmark task.
go.mod Updated github.com/truflation/tsn-sdk dependency version.
internal/contracts/composed_stream_template.kf Added taxonomy_id and start_date columns to taxonomies table; updated set_taxonomy and describe_taxonomies procedures; added disable_taxonomy procedure.
internal/contracts/tests/composed_test.go Added testSetTaxonomyWithStartDate; updated existing tests to use types.Taxonomy structure.
internal/contracts/tests/utils/procedure/execute.go Introduced DescribeTaxonomies function and DescribeTaxonomiesInput structure for handling taxonomy descriptions.
internal/contracts/tests/utils/setup/composed.go Changed TaxonomyDefinitions from slice to single types.Taxonomy; updated related processing logic.
scripts/download-binaries-dev.sh Modified download URL for a binary file.

Assessment against linked issues

Objective Addressed Explanation
Test composed contract with start date (#666)

Possibly related PRs

🐰 "In the garden where taxonomies grow,
A start date now helps us know,
With tests that spring up, bright and new,
Our code will flourish, that's true!
So hop along, let’s build and play,
With each new task, we’ll seize the day!" 🐇


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 4

🧹 Outside diff range and nitpick comments (3)
internal/contracts/tests/utils/procedure/execute.go (1)

137-159: LGTM: New function is well-implemented, with a minor suggestion.

The DescribeTaxonomies function is well-structured and consistent with other functions in the file. It correctly handles errors and follows the established patterns for procedure execution.

However, there's one minor point to consider:

The Height field in TransactionData is hardcoded to 0 (line 151). Consider parameterizing this value by adding a Height field to the DescribeTaxonomiesInput struct, similar to other input structs in the file. This would make the function more flexible and consistent with the existing pattern.

Here's a suggested change:

 type DescribeTaxonomiesInput struct {
 	Platform      *kwilTesting.Platform
 	DBID          string
 	LatestVersion bool
+	Height        uint64
 }

 // In the DescribeTaxonomies function:
 		TransactionData: common.TransactionData{
 			Signer: input.Platform.Deployer,
 			Caller: deployer.Address(),
 			TxID:   input.Platform.Txid(),
-			Height: 0,
+			Height: input.Height,
 		},

This change would align the DescribeTaxonomies function more closely with the other functions in the file.

internal/contracts/composed_stream_template.kf (2)

812-813: Ensure consistent inclusion of version and start_date in describe_taxonomies

In the describe_taxonomies procedure, the fields version and start_date are added to the return table definition and the SELECT statements. Verify that these fields are consistently included in all parts of the procedure to prevent discrepancies between the defined return structure and the actual output.

Also applies to: 823-824, 834-835


842-842: Implement disabling taxonomy by taxonomy_id

There's a TODO comment indicating the need to disable a taxonomy by taxonomy_id. Implementing this functionality would allow more granular control over individual taxonomies.

Would you like assistance in drafting the implementation for this feature? I can help generate the necessary code or open a GitHub issue to track this task.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f660c53 and 78aa227.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • Taskfile.yml (1 hunks)
  • go.mod (1 hunks)
  • internal/contracts/composed_stream_template.kf (7 hunks)
  • internal/contracts/tests/composed_test.go (10 hunks)
  • internal/contracts/tests/utils/procedure/execute.go (1 hunks)
  • internal/contracts/tests/utils/setup/composed.go (5 hunks)
  • scripts/download-binaries-dev.sh (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🧰 Additional context used
📓 Learnings (1)
internal/contracts/tests/composed_test.go (3)
Learnt from: outerlook
PR: truflation/tsn#629
File: internal/contracts/tests/composed_test.go:447-501
Timestamp: 2024-09-24T19:06:30.810Z
Learning: In the `internal/contracts/tests` package, test helper functions like `setTaxonomy` are used only within tests and may not require the same validation checks as production code.
Learnt from: outerlook
PR: truflation/tsn#629
File: internal/contracts/tests/composed_test.go:447-501
Timestamp: 2024-10-08T15:59:14.905Z
Learning: In the `internal/contracts/tests` package, test helper functions like `setTaxonomy` are used only within tests and may not require the same validation checks as production code.
Learnt from: outerlook
PR: truflation/tsn#629
File: internal/contracts/tests/composed_test.go:447-501
Timestamp: 2024-10-08T15:59:14.952Z
Learning: In the `internal/contracts/tests` package, test helper functions like `setTaxonomy` are used only within tests and may not require the same validation checks as production code.
🔇 Additional comments (11)
Taskfile.yml (1)

134-136: Verify test coverage after directory change.

The change from ./internal/extensions/... to ./internal/contracts/tests/... aligns with the PR objective of adding a test for setting a taxonomy with a start date. This reorganization of the test structure is a good practice for better code organization.

However, please ensure that this change doesn't inadvertently exclude any important unit tests that were previously covered.

To verify the test coverage, please run the following commands:

Please review the output to ensure all necessary tests are included in the new directory structure.

✅ Verification successful

[/run_scripts]


Test coverage verified after directory change.

All unit tests have been successfully moved to ./internal/contracts/tests/, and the old ./internal/extensions/ directory has been removed. No necessary tests have been excluded from the new directory structure.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare the test files covered before and after the change

# Test: List all test files in the old directory
echo "Test files in ./internal/extensions/:"
fd -e go -e test.go . ./internal/extensions

# Test: List all test files in the new directory
echo "Test files in ./internal/contracts/tests/:"
fd -e go -e test.go . ./internal/contracts/tests

# Test: Check if there are any test files left in the old directory
echo "Checking for any remaining test files in ./internal/extensions/:"
fd -e go -e test.go . ./internal/extensions

Length of output: 1405


Script:

#!/bin/bash
# Description: Verify that all test files have been moved to ./internal/contracts/tests/ and no tests are missing.

# Search for test files outside the new directory
echo "Searching for test files outside ./internal/contracts/tests/:"
fd -e go -e test.go . --exclude ./internal/contracts/tests/

# Verify that the old directory ./internal/extensions/ does not exist
echo "Checking if ./internal/extensions/ directory exists:"
if [ -d "./internal/extensions/" ]; then
    echo "Directory ./internal/extensions/ still exists. Listing remaining test files:"
    fd -e go -e test.go . ./internal/extensions
else
    echo "Directory ./internal/extensions/ has been removed."
fi

# List all test files in the new directory
echo "Listing test files in ./internal/contracts/tests/:"
fd -e go -e test.go . ./internal/contracts/tests/

Length of output: 5497

internal/contracts/tests/utils/procedure/execute.go (2)

130-134: LGTM: New input struct is well-defined and consistent.

The DescribeTaxonomiesInput struct is well-structured and follows the existing patterns in the file. The inclusion of the LatestVersion boolean field appropriately captures the specific requirements for this operation.


129-159: Overall, the changes look good and align with the PR objectives.

The new DescribeTaxonomies function and its input struct have been successfully implemented to address the need for testing composed contracts with start dates. This addition aligns well with the PR objectives and the linked issue (#666).

The implementation follows the existing patterns in the file, making it consistent and easy to understand. The only minor suggestion is to consider parameterizing the Height field in the DescribeTaxonomies function for better flexibility and consistency.

These changes effectively contribute to enhancing the testing framework for taxonomies within the codebase, as outlined in the PR summary.

internal/contracts/tests/utils/setup/composed.go (5)

22-22: LGTM: TaxonomyDefinitions field type updated appropriately

The change from a slice of TaxonomyItem to the Taxonomy struct for the TaxonomyDefinitions field aligns with the updated data model and encapsulates taxonomy information effectively.


158-158: Correct initialization of TaxonomyDefinitions

The TaxonomyDefinitions field is properly initialized as an empty types.Taxonomy struct, preparing it for taxonomy item additions.


Line range hint 176-182: Appending TaxonomyItems correctly to TaxonomyDefinitions

The code correctly appends TaxonomyItem instances to TaxonomyDefinitions.TaxonomyItems, ensuring that each primitive stream is associated with the composed stream along with its weight.


215-219: Updated iteration over TaxonomyItems in setTaxonomy

The loop accurately iterates over TaxonomyDefinitions.TaxonomyItems, extracting necessary fields for the set_taxonomy procedure call.


222-226: Ensure 'set_taxonomy' procedure handles 'startDate' parameter

The set_taxonomy procedure is now being called with an additional startDate argument. Please verify that the procedure definition in the schema has been updated to accept this new parameter and that it handles it correctly. This ensures that the taxonomy start date is properly recorded and utilized in the system.

Run the following script to verify that the set_taxonomy procedure includes the startDate parameter:

Also applies to: 236-236

internal/contracts/tests/composed_test.go (2)

33-33: Test case for setting taxonomy with start date added correctly

The new test function testSetTaxonomyWithStartDate is appropriately added to the test suite.


Line range hint 543-562: Ensure startDate is correctly handled when nil in setTaxonomy

In the setTaxonomy function, when taxonomies.StartDate is nil, the variable startDate remains an empty string. Please confirm that passing an empty string as startDate to the set_taxonomy procedure is acceptable and that the procedure can handle it correctly without causing unexpected behavior.

internal/contracts/composed_stream_template.kf (1)

782-782: Ensure all calls to set_taxonomy include the new $start_date parameter

The set_taxonomy procedure now includes an additional $start_date parameter. Please verify that all existing calls to this procedure have been updated accordingly to prevent runtime errors due to missing arguments.

Run the following script to identify calls to set_taxonomy that might be missing the $start_date parameter:

@pr-time-tracker 8000 PR Time Tracker
Copy link

@outerlook
⚠️⚠️⚠️
You must submit the time spent on this PR.
⚠️⚠️⚠️

@MicBun MicBun merged commit 8d8b2c4 into main Oct 10, 2024
8 of 9 checks passed
@MicBun MicBun deleted the test/composedStartDate branch October 10, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: composed contract with start date is not tested
2 participants
0