@@ -20,33 +20,51 @@ func TestBurn(t *testing.T) {
2020 testCases := []struct {
2121 name string
2222 sender sdk.AccAddress
23+ mintCoin sdk.Coin
2324 burnCoin sdk.Coin
2425 expectedErr error
2526 }{
2627 {
2728 name : "pass" ,
2829 sender : testutil .AccAddress (),
29- burnCoin : sdk .NewCoin ("nibiru" , sdk .NewInt (100 )),
30+ mintCoin : sdk .NewCoin ("unibi" , sdk .NewInt (100 )),
31+ burnCoin : sdk .NewCoin ("unibi" , sdk .NewInt (100 )),
3032 expectedErr : nil ,
3133 },
34+ {
35+ name : "not enough coins" ,
36+ sender : testutil .AccAddress (),
37+ mintCoin : sdk .NewCoin ("unibi" , sdk .NewInt (100 )),
38+ burnCoin : sdk .NewCoin ("unibi" , sdk .NewInt (101 )),
39+ expectedErr : fmt .Errorf ("spendable balance 100unibi is smaller than 101unibi: insufficient funds" ),
40+ },
3241 }
42+
3343 for _ , tc := range testCases {
3444 t .Run (fmt .Sprintf ("Case %s" , tc .name ), func (t * testing.T ) {
3545 nibiruApp , ctx := testapp .NewNibiruTestAppAndContext ()
46+
47+ // mint and send money to the sender
3648 require .NoError (t ,
3749 nibiruApp .BankKeeper .MintCoins (
38- ctx , types .ModuleName , sdk .NewCoins (tc .burnCoin )))
50+ ctx , types .ModuleName , sdk .NewCoins (tc .mintCoin )))
3951 require .NoError (t ,
4052 nibiruApp .BankKeeper .SendCoinsFromModuleToAccount (
41- ctx , types .ModuleName , tc .sender , sdk .NewCoins (tc .burnCoin )),
53+ ctx , types .ModuleName , tc .sender , sdk .NewCoins (tc .mintCoin )),
4254 )
4355
56+ supply := nibiruApp .BankKeeper .GetSupply (ctx , "unibi" )
57+ require .Equal (t , tc .mintCoin .Amount , supply .Amount )
58+
4459 // Burn coins
4560 err := nibiruApp .InflationKeeper .Burn (ctx , sdk .NewCoins (tc .burnCoin ), tc .sender )
61+ supply = nibiruApp .BankKeeper .GetSupply (ctx , "unibi" )
4662 if tc .expectedErr != nil {
4763 require .EqualError (t , err , tc .expectedErr .Error ())
64+ require .Equal (t , tc .mintCoin .Amount , supply .Amount )
4865 } else {
4966 require .NoError (t , err )
67+ require .Equal (t , sdk .ZeroInt (), supply .Amount )
5068 }
5169 })
5270 }
0 commit comments