122: Fix attribute index key collision #123
@ -79,6 +79,24 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
false,
|
false,
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)",
|
||||||
|
®istrytypes.QueryListRecordsRequest{
|
||||||
|
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||||
|
{
|
||||||
|
Key: "typ",
|
||||||
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||||
|
Type: "string",
|
||||||
|
String_: "eWebsiteRegistrationRecord",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
All: true,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Filter with attributes ServiceProviderRegistration",
|
"Filter with attributes ServiceProviderRegistration",
|
||||||
®istrytypes.QueryListRecordsRequest{
|
®istrytypes.QueryListRecordsRequest{
|
||||||
@ -123,7 +141,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
} else {
|
} else {
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Equal(test.noOfRecords, len(resp.GetRecords()))
|
sr.Equal(test.noOfRecords, len(resp.GetRecords()))
|
||||||
if test.createRecords {
|
if test.createRecords && test.noOfRecords > 0 {
|
||||||
recordId = resp.GetRecords()[0].GetId()
|
recordId = resp.GetRecords()[0].GetId()
|
||||||
sr.NotZero(resp.GetRecords())
|
sr.NotZero(resp.GetRecords())
|
||||||
sr.Equal(resp.GetRecords()[0].GetBondId(), suite.bond.GetId())
|
sr.Equal(resp.GetRecords()[0].GetBondId(), suite.bond.GetId())
|
||||||
|
@ -367,7 +367,7 @@ func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAttributesIndexKey(key string, value interface{}) []byte {
|
func GetAttributesIndexKey(key string, value interface{}) []byte {
|
||||||
keyString := fmt.Sprintf("%s%s", key, value)
|
keyString := fmt.Sprintf("%s=%s", key, value)
|
||||||
return append(PrefixAttributesIndex, []byte(keyString)...)
|
return append(PrefixAttributesIndex, []byte(keyString)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user