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

fix: handle the arweave-rs exception #598

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

imotai
Copy link
Contributor

@imotai imotai commented Jul 31, 2023


PR-Codex overview

This PR focuses on adding and modifying event processing functionality.

Detailed summary

  • Added event processing for contract logs
  • Updated event processing for contract logs
  • Updated dependencies in Cargo.toml
  • Modified code in index.ts
  • Modified code in recover.rs
  • Modified code in node_test_base.rs
  • Modified code in rollup_executor.rs
  • Modified code in meta_store_event_processor.rs
  • Modified code in event_processor.rs

The following files were skipped due to too many changes: src/event/src/event_processor.rs

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@imotai imotai linked an issue Jul 31, 2023 that may be closed by this pull request
@imotai
Copy link
Contributor Author

imotai commented Jul 31, 2023

/codex please write a test case for rollup_executor.rs

@pr-codex
Copy link

pr-codex bot commented Jul 31, 2023

please write a test case for rollup_executor.rs

@imotai Sure! Here's a test case for rollup_executor.rs:

#[cfg(test)]
mod tests {
    use super::*;
    use crate::node_test_base::tests::NodeTestBase;
    use std::sync::Arc;
    use tokio::sync::Mutex;

    #[tokio::test]
    async fn test_rollup_executor() {
        // Set up a temporary directory for testing
        let tmp_dir_path = TempDir::new("test_rollup_executor").expect("create temp dir");

        // Set up the necessary components for testing
        let (rollup_executor, recover, storage) =
            NodeTestBase::setup_for_smoke_test(&tmp_dir_path).await.unwrap();

        // Process the rollup executor
        let result = rollup_executor.process().await;
        assert!(result.is_ok());

        // Fetch the latest Arweave transaction
        let result = recover.get_latest_arweave_tx().await;
        assert!(result.is_ok());
        let tx = result.unwrap();
        println!("The latest Arweave transaction is: {}", tx);
        assert!(!tx.is_empty());

        // Get the last rollup record from the storage
        let result = storage.get_last_rollup_record();
        assert!(result.is_ok());
        let record = result.unwrap().unwrap();
        println!("Start block: {}, End block: {}", record.start_block, record.end_block);

        // Add mutations to the storage
        let block = NodeTestBase::add_mutations(&storage, 10);

        // Process the rollup executor again
        let result = rollup_executor.process().await;
        assert!(result.is_ok());

        // Get the last rollup record again
        let result = storage.get_last_rollup_record();
        assert!(result.is_ok());
        let record = result.unwrap().unwrap();
        println!("Start block: {}, End block: {}", record.start_block, record.end_block);

        // Verify that the end block of the record matches the added mutations
        assert_eq!(record.end_block, block);
    }
}

This test case sets up a temporary directory, initializes the necessary components, and tests the functionality of the RollupExecutor by processing it and verifying the results. It also tests the addition of mutations and the retrieval of the last rollup record from the storage.

@codecov-commenter
Copy link

Codecov Report

Merging #598 (c9f8a51) into main (518b627) will not change coverage.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##             main     #598   +/-   ##
=======================================
  Coverage   61.70%   61.70%           
=======================================
  Files           9        9           
  Lines         470      470           
  Branches       69       69           
=======================================
  Hits          290      290           
  Misses        180      180           
Flag Coverage Δ
rust 61.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@imotai imotai linked an issue Jul 31, 2023 that may be closed by this pull request
@imotai imotai linked an issue Jul 31, 2023 that may be closed by this pull request
@imotai imotai merged commit bb44ae3 into main Jul 31, 2023
@imotai
Copy link
Contributor Author

imotai commented Aug 13, 2023

@qa-agent

@qa-agent
Copy link

Unit Test Analysis

🎯level:Important
📣explanation:The pull request includes changes to the event processor and the rollup executor, which are critical components of the system. It is important to have unit tests to ensure that these changes do not introduce any bugs or regressions.

Existing Test Cases

Summary Category File
Test the creation of a new event processor with a valid configuration. positive testing src/event/src/event_processor.rs
Test stopping the event processor. positive testing src/event/src/event_processor.rs
Test starting the event processor. positive testing src/event/src/event_processor.rs
Test processing events and storing them in the database. positive testing src/event/src/event_processor.rs
Test the creation of a new meta store event processor with a valid configuration. positive testing src/event/src/meta_store_event_processor.rs
Test stopping the meta store event processor. positive testing src/event/src/meta_store_event_processor.rs
Test starting the meta store event processor. positive testing src/event/src/meta_store_event_processor.rs
Test processing events and storing them in the database. positive testing src/event/src/meta_store_event_processor.rs
Test adding mutations to the mutation store. positive testing src/node/src/node_test_base.rs
Test fetching Arweave transactions from a block. positive testing src/node/src/recover.rs
Test the rollup executor process. positive testing src/node/src/rollup_executor.rs

Recommended Test Cases

Summary Category
Test stopping the event processor when it is already stopped. negative testing
Test starting the event processor when it is already running. negative testing
Test processing events with an invalid configuration. negative testing
Test adding mutations to the mutation store with invalid inputs. negative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants