(t *testing.T)
| 165 | } |
| 166 | |
| 167 | func TestProviderDeleteAttribute(t *testing.T) { |
| 168 | suite := setupTestSuite(t) |
| 169 | |
| 170 | owner := testutil.AccAddress(t) |
| 171 | |
| 172 | msg := &types.MsgSignProviderAttributes{ |
| 173 | Owner: owner.String(), |
| 174 | Auditor: testutil.AccAddress(t).String(), |
| 175 | Attributes: testutil.Attributes(t), |
| 176 | } |
| 177 | |
| 178 | // add one more attribute in case prev call to testutil.Attributes generated only one entry |
| 179 | msg.Attributes = append(msg.Attributes, testutil.Attribute(t)) |
| 180 | |
| 181 | sort.SliceStable(msg.Attributes, func(i, j int) bool { |
| 182 | return msg.Attributes[i].Key < msg.Attributes[j].Key |
| 183 | }) |
| 184 | |
| 185 | res, err := suite.handler(suite.ctx, msg) |
| 186 | require.NoError(t, err) |
| 187 | require.NotNil(t, res) |
| 188 | |
| 189 | res, err = suite.handler(suite.ctx, &types.MsgDeleteProviderAttributes{ |
| 190 | Auditor: msg.Auditor, |
| 191 | Owner: msg.Owner, |
| 192 | Keys: []string{msg.Attributes[0].Key}, // remove first attribute |
| 193 | }) |
| 194 | require.NoError(t, err) |
| 195 | require.NotNil(t, res) |
| 196 | |
| 197 | msg.Attributes = msg.Attributes[1:] |
| 198 | prov, exists := suite.keeper.GetProviderAttributes(suite.ctx, owner) |
| 199 | require.True(t, exists) |
| 200 | require.Equal(t, prov, msgSignProviderAttributesToResponse(msg)) |
| 201 | } |
| 202 | |
| 203 | func msgSignProviderAttributesToResponse(msg *types.MsgSignProviderAttributes) types.AuditedProviders { |
| 204 | // create handler sorts attributes, so do we to ensure same order |
nothing calls this directly
no test coverage detected