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

add a test for find after save #1519

Closed
wants to merge 1 commit into from
Closed

Conversation

lostman
Copy link
Contributor

@lostman lostman commented Dec 15, 2023

Description

Work in progress PR to deal with #1518 issue.

An example indexer to see the problem in isolation.

type Block @entity {
    id: ID!
    height: U64!
    hash: Bytes32! @unique
    memo: String!
}
extern crate alloc;
use fuel_indexer_utils::prelude::*;

#[indexer(manifest = "find_after_save.manifest.yaml")]
pub mod find_after_save_index_mod {

    fn find_after_save_handler(block_data: BlockData) {
        if block_data.header.height == 1 {
            info!("Processing Block#{}. (>'.')>", block_data.header.height);

            let mut block = Block::new(
                block_data.header.height.into(),
                block_data.id,
                "one".to_string(),
            );
            block.save();
            info!("Saved: {block:#?}");

            let b = Block::find(Block::height().eq(block.height)).unwrap();
            info!("Found: {b:#?}");

            block.memo = "two".to_string();
            block.save();

            let b = Block::find(Block::height().eq(block.height)).unwrap();
            info!("Found (expecting modified): {b:#?}");

            assert_eq!(&b.memo, "two");
        }
    }
}

Testing steps

Please provide the exact testing steps for the reviewer(s) if this PR requires testing.

Changelog

Please add neat Changelog info here, according to our Contributor's Guide.

@lostman lostman self-assigned this Dec 15, 2023
@deekerno deekerno closed this Feb 6, 2024
@lostman lostman removed their assignment Mar 16, 2024
@lostman lostman deleted the maciej/1518-find-after-save branch March 16, 2024 05:13
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.

None yet

2 participants