mineflayer-pathfinder icon indicating copy to clipboard operation
mineflayer-pathfinder copied to clipboard

Add more tests

Open rom1504 opened this issue 3 years ago • 4 comments

There have been a few issues of specific cases that were broken and could now serve as test cases. mineflayer-pathfinder can be used on a simulated world. I think it would be great to have some tests.

For example it could make sense to define a simple fake chunk/world section, and to make pathfinder generate a path from A to B, check it manages to find one, that it seems correct (basic consistency test on it), then execute it and check that the state produce is what is expected.

It might not be 100% what would be observed on an actual server, but may already be interesting to test issues.

What do you think ?

rom1504 avatar Jul 14 '20 20:07 rom1504

ah I see there's quite a few calls to bot in https://github.com/Karang/mineflayer-pathfinder/blob/master/index.js actually, might not work as well as I thought.

Could always go the route of fully starting a server and all end to end test, but it's much heavier

rom1504 avatar Jul 14 '20 20:07 rom1504

Another way to frame this is not as classical unit/integration tests but as a metric. For example, given a known world and a given time (say during the day) (we could load this as anvil using the vanilla server) and a given position, how much time does mineflayer-pathfinder take in average (do 10 tries) ? log the information each commit and if the value has a big change (+- 10%) make it fail, or just display that curve somewhere

rom1504 avatar Jul 14 '20 21:07 rom1504

You could mock the bot for the purpose of tests to make it a bit easier. Basically calling bot.dig(...) would set an internal flag that the bot had mined something on this tick. Etc. That just chart and make sure the bot followed an intended set of actions for a controlled environment.

TheDudeFromCI avatar Jul 15 '20 04:07 TheDudeFromCI

Related https://github.com/PrismarineJS/mineflayer-pathfinder/pull/201

IceTank avatar Sep 24 '21 19:09 IceTank