Test cases balance checking
The book module, which holds the primary functionality of the order book, contains many test cases on order fullfillment. However, one aspect which could enhance testing is to check the balances on the fillable orders to ensure Quote
and Base
coins were swapped as well as the DEX
fee behavior. For instance, we added the following assert statements to test_fully_fillable_gtc_bid_is_filled
,
assert!(coin::balance<FakeBaseCoin>(bid_addr) == 1000000, 10);
assert!(coin::balance<FakeQuoteCoin>(ask_addr) == 1000000, 10);
assert!(coin::balance<FakeQuoteCoin>(@dex) == 1000, 10);
which confirm the bidder received the Base
coin, the asker received the Quote
coin, and the dex received its fees. Adding balance checks to the other unit tests further confirms the order book functionality and could be a helpful addition to testing.