Skip to content

Commit

Permalink
[1834]: Fix the tests that broke because I changed the error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpicyLemon committed Feb 9, 2024
1 parent cae8522 commit 44d848f
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 161 deletions.
5 changes: 4 additions & 1 deletion internal/handlers/bank_send_restriction_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handlers_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -163,7 +164,9 @@ func TestBankSend(tt *testing.T) {

// On a restricted coin with required attributes using an admin that does not have TRANSFER permission, but the receiver DOES have the required attributes.
tranferRAMarker := markertypes.NewMsgTransferRequest(addr2, addr2, addr3, sdk.NewInt64Coin(restrictedAttrMarkerDenom, 25))
ConstructAndSendTx(tt, *app, ctx, acct2, priv2, tranferRAMarker, txFailureCode, addr2.String()+" is not allowed to broker transfers")
expErr := fmt.Sprintf("%s does not have ACCESS_TRANSFER on restrictedmarkerattr marker (%s)",
addr2.String(), raMarkerAcct.GetAddress().String())
ConstructAndSendTx(tt, *app, ctx, acct2, priv2, tranferRAMarker, txFailureCode, expErr)
addr2afterBalance = app.BankKeeper.GetAllBalances(ctx, addr2).String()
assert.Equal(tt, "50nonrestrictedmarker,125restrictedmarker,75restrictedmarkerattr,999400000stake", addr2afterBalance, "addr1afterBalance")
addr2afterBalance = app.BankKeeper.GetAllBalances(ctx, addr3).String()
Expand Down
15 changes: 11 additions & 4 deletions x/marker/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ func (s *HandlerTestSuite) containsMessage(result *sdk.Result, msg proto.Message
return false
}

// noAccessErr creates an expected error message for an address not having access on a marker.
func (s *HandlerTestSuite) noAccessErr(addr string, role types.Access, denom string) string {
mAddr, err := types.MarkerAddress(denom)
s.Require().NoError(err, "MarkerAddress(%q)", denom)
return fmt.Sprintf("%s does not have %s on %s marker (%s)", addr, role, denom, mAddr)
}

type CommonTest struct {
name string
msg sdk.Msg
Expand Down Expand Up @@ -460,9 +467,9 @@ func (s *HandlerTestSuite) TestMsgAddFinalizeActivateMarkerRequest() {
expectedEvent: types.NewEventMarkerMint("1000", denom, s.user1),
},
{
name: "should fail to burn denom, user doesn't have permissions",
name: "should fail to burn denom, user doesn't have permissions",
msg: types.NewMsgBurnRequest(s.user1Addr, sdk.NewInt64Coin(denom, 50)),
errorMsg: fmt.Sprintf("%s does not have ACCESS_BURN on hotdog markeraccount: invalid request", s.user1),
errorMsg: s.noAccessErr(s.user1, types.Access_Burn, denom) + ": invalid request",
},
}
s.runTests(cases)
Expand Down Expand Up @@ -543,7 +550,7 @@ func (s *HandlerTestSuite) TestMsgSetAccountDataRequest() {
Value: "This is some unrestricted coin data. This won't get used though.",
Signer: s.user1,
},
errorMsg: s.user1 + " does not have deposit access for " + denomU + " marker",
errorMsg: s.noAccessErr(s.user1, types.Access_Deposit, denomU),
},
{
name: "should successfully set account data on restricted marker via gov prop",
Expand All @@ -570,7 +577,7 @@ func (s *HandlerTestSuite) TestMsgSetAccountDataRequest() {
Value: "This is some restricted coin data. This won't get used though.",
Signer: s.user1,
},
errorMsg: s.user1 + " does not have deposit access for " + denomR + " marker",
errorMsg: s.noAccessErr(s.user1, types.Access_Deposit, denomR),
},
}
s.runTests(tests)
Expand Down
Loading

0 comments on commit 44d848f

Please sign in to comment.