Skip to content

Conversation

@utkarshg6
Copy link
Collaborator

No description provided.

let txs = vec![tx1, tx2, tx3];
let txs = vec![tx1, tx2];

let result = subject.insert_new_records(&txs);
Copy link
Contributor

Choose a reason for hiding this comment

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

We were discussing that maybe the code should actually panic if an already confirmed transaction (having the block field populated) is supplied.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it would be too restrictive, maybe we want to insert confirmed transactions too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe yes, but please don't write unrealistic tests.
We know exactly, that our algorithm will always put in a transaction that is not confirmed at the time we are creating the record.

If I were writing this, I wouldn't hesitate and include the panic constraint. What we are writing is a complex system where every little mistake can break something. I wish I could know of each behavior that we didn't consider as possible. That's why use unreachable!() so much these days. Those are border lines for me, which I don't think we step over but if we do then the code need a serious fix.
That's my take.

"0x2345678901234567890123456789012345678901234567890123456789012345",
rusqlite::types::Null,
])
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be simpler if you used the normal insert_new_records() fn and then used the update sql statement just to null out the single cell? I'd expect much less code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm doing it because of the wrapped_conn, it's complex to reuse it later.

Copy link
Contributor

@bertllll bertllll Jun 5, 2025

Choose a reason for hiding this comment

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

There is no conflict though.

If you can call .prepare() and then .execute() on it, then you can do whatever you want.
It would allow you to run the update statement.
Really, try it.

 subject
            .insert_new_records(&vec![tx.clone()])
 wrapped_conn
            .prepare("UPDATE failed_payable (block_number) values (null)")
            .unwrap()
            .execute([])
            .unwrap();

It should work... but my brain has its circuits in flames at the moment 🤷‍♂️

let faulty_insert_stmt = { setup_conn.prepare("SELECT id FROM example").unwrap() };
let wrapped_conn = ConnectionWrapperMock::default()
.prepare_result(Ok(get_tx_identifiers_stmt))
.prepare_result(Ok(faulty_insert_stmt));
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you are preparing for two transactions but eventually the test performs over just one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It'll require both of them. Since, we need to check for unique hashes.

@utkarshg6 utkarshg6 merged commit c3aed7a into GH-598 Jun 19, 2025
0 of 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.

3 participants