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

Group test blocks using t.Run() #423

Conversation

hackintoshrao
Copy link
Contributor

No description provided.

@hackintoshrao hackintoshrao requested a review from a team as a code owner December 1, 2022 03:25
@hackintoshrao hackintoshrao reopened this Dec 1, 2022
@hackintoshrao
Copy link
Contributor Author

hackintoshrao commented Dec 1, 2022

@AeonSw4n I just grouped the tests in #422 using t.Run(). Can you merge it into #422 if this looks good? I'll be adding more cases. Also looking into adding a state verification for before & after connect-disconnect to Postgres tests. Can you point me to the badger version of the connect-disconnect test?

- Calling AddInputsAndChangeToTransactionWithSubsidy with txnInputs.
- Expected to fail.
@AeonSw4n
Copy link
Contributor

AeonSw4n commented Dec 5, 2022

Sure thing, looks great! Happy to merge :)

That's cool you've looked into the state verification. The idea is to make sure that the blockchain state (as expressed in badger/postgres) reverts to its proper previous configuration after a block is disconnected. We could turn this concept into a generic sanity-check run by the testing framework, to automatically test that the transaction _disconnect logic was correctly coded. This feature already works for the RunBadgerTest() function. In the code, you can see that we call the GetAllStateDbEntries() method twice. First, we call it to fetch the entire state before a block is connected -- which is stored under dbEntriesBefore. Second, we fetch the state again after connecting and disconnecting a block and store it in dbEntriesAfter. We then call compareBeforeAfterDbEntries on those two state snapshots to verify that they are identical (which is the expected behavior).

It would be nice to have a similar functionality in RunPostgresTest(). I was planning on writing it at some point before merging my original PR. The tricky part is how do you get all tables in postgres to run a SELECT * FROM query, though we might just prefer to specify the affected tables explicitly through a field of transactionTestVector struct or something.

@AeonSw4n AeonSw4n merged commit a96b03f into deso-protocol:p/transaction-testing-framework Dec 5, 2022
@hackintoshrao
Copy link
Contributor Author

Thanks, @AeonSw4n for the explanation. Will keep you posted.

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.

2 participants