JoshOrndorff / recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
378 stars 187 forks source link

Clean and standardize test harnesses #277 #343

Closed herou closed 4 years ago

herou commented 4 years ago

I renamed ExtBuilder to ExternalityBuilder and made ExtBuilder private. @JoshOrndorff Please take a look and tell me if the first two points are done correctly. I ran all the tests locally after I made those changes.

JoshOrndorff commented 4 years ago

This is a great start. If all the tests pass, you're ready to continue. I think the best next step is to tackle point number 4 from #777. Test that events come in the proper order, not just that they exist.

Here is an example of a line that tests that an event exists but doesn't check that it's the first event emitted. There are many of these cases in the recipes. The idea is that we want to test not only tha tsome events exist but that no additional events exist ad the events come in the correct order.

herou commented 4 years ago

Hi @JoshOrndorff I got your idea and I am trying to solve it. To check if the events come in the correct order we should use .next() method, so it is going to be something like this: assert_eq!(System::events().iter().next(), Some(& /excpected event/ ));

Give me a hint, what should be instead of /expected event/ ?

herou commented 4 years ago

@JoshOrndorff Do you have any suggestions?

herou commented 4 years ago

@JoshOrndorff I made the required changes for only the charity pallet tests. Please take a look and let me know if it is okay, so I can go further with the other pallets as well.

JoshOrndorff commented 4 years ago

You're doing great @herou Make these changes throughout all of the pallets. Let me know if you have more questions.

herou commented 4 years ago

@JoshOrndorff , I made the required changes by you and all the tests passed. Please take a look.