122: Fix attribute index key collision
Some checks failed
Build / cleanup-runs (pull_request) Failing after 3s
Build / build (pull_request) Failing after 57s
CodeQL / Analyze (go) (pull_request) Failing after 13s
Deploy Contract / cleanup-runs (pull_request) Failing after 2s
Deploy Contract / deploy (pull_request) Failing after 36s
Pull Request Labeler / triage (pull_request) Successful in 4s
Dependency Review / dependency-review (pull_request) Failing after 44s
Lint / Run flake8 on python integration tests (pull_request) Failing after 44s
Semgrep / Scan (pull_request) Failing after 5s
Lint / Run golangci-lint (pull_request) Failing after 47s
Tests / cleanup-runs (pull_request) Failing after 3s
Run Gosec / Gosec (pull_request) Failing after 23s
Tests / test-unit-cover (pull_request) Failing after 1m16s
Tests / test-importer (pull_request) Failing after 1m15s
Tests / test-rpc (pull_request) Failing after 1m24s
Tests / sdk_tests (pull_request) Failing after 1m46s

This commit is contained in:
Thomas E Lackey 2023-11-28 14:44:37 -06:00
parent 84308726be
commit 113c9125e4
2 changed files with 20 additions and 2 deletions

View File

@ -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)",
&registrytypes.QueryListRecordsRequest{
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
{
Key: "typ",
Value: &registrytypes.QueryListRecordsRequest_ValueInput{
Type: "string",
String_: "eWebsiteRegistrationRecord",
},
},
},
All: true,
},
true,
false,
0,
},
{ {
"Filter with attributes ServiceProviderRegistration", "Filter with attributes ServiceProviderRegistration",
&registrytypes.QueryListRecordsRequest{ &registrytypes.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())

View File

@ -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)...)
} }