Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenfactory: Mutation test issue (July 17th) #2105

Closed
ValarDragon opened this issue Jul 17, 2022 · 0 comments · Fixed by #2504
Closed

Tokenfactory: Mutation test issue (July 17th) #2105

ValarDragon opened this issue Jul 17, 2022 · 0 comments · Fixed by #2504
Assignees
Milestone

Comments

@ValarDragon
Copy link
Member

ValarDragon commented Jul 17, 2022

cref #2069

The mutation score is 0.400000 (22 passed, 27 failed, 0 duplicated, 6 skipped, total is 55)
Mutation testing score below desired level (0.400000 < 0.75)

1:

--- ./x/tokenfactory/keeper/createdenom.go	2022-07-17 12:29:15.308755888 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/keeper/createdenom.go.0	2022-07-17 12:37:07.011614397 -0500
@@ -77,7 +77,7 @@
-	if len(creationFee) > 0 {
+	if len(creationFee) >= 0 {
 		if err := k.distrKeeper.FundCommunityPool(ctx, creationFee, accAddr); err != nil {
 			return err
 		}

2: Deleting Create Module Account in InitGenesis

+++ /tmp/go-mutesting-332867003/./x/tokenfactory/keeper/genesis.go.0	2022-07-17 12:37:23.927441249 -0500
@@ -9,7 +9,7 @@
 // InitGenesis initializes the tokenfactory module's state from a provided genesis
 // state.
 func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
-	k.CreateModuleAccount(ctx)
+	_, _ = k.CreateModuleAccount, ctx

3 - 7: - Probably noise, deleting returning on err

+++ /tmp/go-mutesting-332867003/./x/tokenfactory/keeper/genesis.go.5	2022-07-17 12:37:29.591383397 -0500
@@ -19,7 +19,8 @@
 	for _, genDenom := range genState.GetFactoryDenoms() {
 		creator, _, err := types.DeconstructDenom(genDenom.GetDenom())
 		if err != nil {
-			panic(err)
+			_ = err
+
 		}

8: - Not sure if noise, deleting set module account. Why isn't a test failing?

+++ /tmp/go-mutesting-332867003/./x/tokenfactory/keeper/keeper.go.1	2022-07-17 12:37:36.423313694 -0500
@@ -81,5 +81,5 @@
 // and sends to the relevant address.
 func (k Keeper) CreateModuleAccount(ctx sdk.Context) {
 	moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner)
-	k.accountKeeper.SetModuleAccount(ctx, moduleAcc)
+	_, _, _ = k.accountKeeper.SetModuleAccount, ctx, moduleAcc
 }

9-13: - True issue, deleting event line untested

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/keeper/keeper.go.1" with checksum c27c4077d183a015fc02ef62d588370d
--- ./x/tokenfactory/keeper/msg_server.go	2022-07-14 21:33:23.461619695 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/keeper/msg_server.go.0	2022-07-17 12:37:38.015297465 -0500
@@ -27,14 +27,11 @@
 	if err != nil {
 		return nil, err
 	}
-
-	ctx.EventManager().EmitEvents(sdk.Events{
-		sdk.NewEvent(
-			types.TypeMsgCreateDenom,
-			sdk.NewAttribute(types.AttributeCreator, msg.Sender),
-			sdk.NewAttribute(types.AttributeNewTokenDenom, denom),
-		),
-	})
+	_, _, _, _, _, _, _, _, _ = sdk.Events{},
+		sdk.NewEvent,
+		types.TypeMsgCreateDenom,
+		sdk.NewAttribute, types.AttributeCreator, msg.Sender,
+		sdk.NewAttribute, types.AttributeNewTokenDenom, denom

14-18: True issue, codec regirstration untested

 func RegisterCodec(cdc *codec.LegacyAmino) {
-	cdc.RegisterConcrete(&MsgCreateDenom{}, "osmosis/tokenfactory/create-denom", nil)
+	_ = cdc.RegisterConcrete
 	cdc.RegisterConcrete(&MsgMint{}, "osmosis/tokenfactory/mint", nil)
 	cdc.RegisterConcrete(&MsgBurn{}, "osmosis/tokenfactory/burn", nil)
 	// cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil)

19-20: True issue, edge cases of Validation don't have regression tests:

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/codec.go.5" with checksum 1607bed1a9b9a2831adfe700afd51c2f
--- ./x/tokenfactory/types/denoms.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/denoms.go.0	2022-07-17 12:37:54.875125872 -0500
@@ -24,7 +24,7 @@
 // based on an input creator address and a subdenom
 // The denom constructed is factory/{creator}/{subdenom}
 func GetTokenDenom(creator, subdenom string) (string, error) {
-	if len(subdenom) > MaxSubdenomLength {
+	if len(subdenom) >= MaxSubdenomLength {
 		return "", ErrSubdenomTooLong
 	}
 	if len(subdenom) > MaxCreatorLength {

(Same for MaxCreatorLength)

21: No test covering deconstruct denom with sender not being correctly formatted address

--- ./x/tokenfactory/types/denoms.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/denoms.go.5	2022-07-17 12:37:58.663087391 -0500
@@ -56,7 +56,7 @@
 	}
 
 	creator = strParts[1]
-	_, err = sdk.AccAddressFromBech32(creator)
+	_, _, _ = err, sdk.AccAddressFromBech32, creator
 	if err != nil {
 		return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "Invalid creator address (%s)", err)
 	}

22-27: Just copying directly, not yest synthesized

+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/denoms.go.6	2022-07-17 12:37:58.959084384 -0500
@@ -60,11 +60,12 @@
 	if err != nil {
 		return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "Invalid creator address (%s)", err)
 	}
+	_, _,
 
-	// Handle the case where a denom has a slash in its subdenom. For example,
-	// when we did the split, we'd turn factory/accaddr/atomderivative/sikka into ["factory", "accaddr", "atomderivative", "sikka"]
-	// So we have to join [2:] with a "/" as the delimiter to get back the correct subdenom which should be "atomderivative/sikka"
-	subdenom = strings.Join(strParts[2:], "/")
+		// Handle the case where a denom has a slash in its subdenom. For example,
+		// when we did the split, we'd turn factory/accaddr/atomderivative/sikka into ["factory", "accaddr", "atomderivative", "sikka"]
+		// So we have to join [2:] with a "/" as the delimiter to get back the correct subdenom which should be "atomderivative/sikka"
+		_ = subdenom, strings.Join, strParts
 
 	return creator, subdenom, nil
 }

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/denoms.go.6" with checksum 741ce7e51a943eee33426fbbf460da58
PASS "/tmp/go-mutesting-332867003/./x/tokenfactory/types/genesis.go.0" with checksum b2de0da0ecafe5b1762bcc6af013a63d
PASS "/tmp/go-mutesting-332867003/./x/tokenfactory/types/genesis.go.1" with checksum ac5d2e5d2fc7d34a6e837ba99fc91176
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.0	2022-07-17 12:38:08.222990385 -0500
@@ -67,7 +67,7 @@
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
 
-	if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) {
+	if false || m.Amount.Amount.Equal(sdk.ZeroInt()) {
 		return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String())
 	}
 

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.0" with checksum bd947dd8f998e7d6d87cbbc9c3217982
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.1	2022-07-17 12:38:08.514987424 -0500
@@ -67,7 +67,7 @@
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
 
-	if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) {
+	if !m.Amount.IsValid() || false {
 		return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String())
 	}
 

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.1" with checksum 2ca9aa1a650a5bc97d354299bf7c4a38
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.2	2022-07-17 12:38:08.814984383 -0500
@@ -101,7 +101,7 @@
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
 
-	if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) {
+	if false || m.Amount.Amount.Equal(sdk.ZeroInt()) {
 		return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String())
 	}
 

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.2" with checksum 083b542d82d2e9a560f733d21d66ef0f
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.3	2022-07-17 12:38:09.102981463 -0500
@@ -101,7 +101,7 @@
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
 
-	if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) {
+	if !m.Amount.IsValid() || false {
 		return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String())
 	}
 

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.3" with checksum 24e0e501f1d6010b2d1220d90516cbb5
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.4	2022-07-17 12:38:09.402978422 -0500
@@ -31,8 +31,7 @@
 	if err != nil {
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
-
-	_, err = GetTokenDenom(m.Sender, m.Subdenom)
+	_, _, _ = err, m.Sender, m.Subdenom
 	if err != nil {
 		return sdkerrors.Wrap(ErrInvalidDenom, err.Error())
 	}

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.4" with checksum 319cdd04a86d6e13f2b3f9174512c8d9
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.5	2022-07-17 12:38:09.762974773 -0500
@@ -180,8 +180,7 @@
 	if err != nil {
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
 	}
-
-	_, err = sdk.AccAddressFromBech32(m.NewAdmin)
+	_, _, _ = err, sdk.AccAddressFromBech32, m.NewAdmin
 	if err != nil {
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err)
 	}

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.5" with checksum 609d055a7f81b7c2fcdef5207f7680e9
--- ./x/tokenfactory/types/msgs.go	2022-07-12 10:22:46.139965414 -0500
+++ /tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.6	2022-07-17 12:38:10.086971489 -0500
@@ -185,8 +185,7 @@
 	if err != nil {
 		return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err)
 	}
-
-	_, _, err = DeconstructDenom(m.Denom)
+	_, _ = err, m.Denom
 	if err != nil {
 		return err
 	}

FAIL "/tmp/go-mutesting-332867003/./x/tokenfactory/types/msgs.go.6" with checksum b87358083ade30ba425591525bb40da6
The mutation score is 0.400000 (22 passed, 27 failed, 0 duplicated, 6 skipped, total is 55)
@alexanderbez alexanderbez self-assigned this Jul 18, 2022
@p0mvn p0mvn added this to the Mutation Testing milestone Jul 19, 2022
@czarcas7ic czarcas7ic self-assigned this Aug 18, 2022
@czarcas7ic czarcas7ic changed the title Weekly mutation test issue (July 17th) Tokenfactory: Mutation test issue (July 17th) Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants