From e3b2c1ca64a5ba43859f996e124983c2808633ab Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 29 Feb 2024 11:55:51 +0530 Subject: [PATCH] Add tests to get records filtered on attributes --- .../registry/keeper/query_server_test.go | 151 +++++++++--------- 1 file changed, 75 insertions(+), 76 deletions(-) diff --git a/tests/integration/registry/keeper/query_server_test.go b/tests/integration/registry/keeper/query_server_test.go index 542f4a5e..0c527dd8 100644 --- a/tests/integration/registry/keeper/query_server_test.go +++ b/tests/integration/registry/keeper/query_server_test.go @@ -62,24 +62,23 @@ func (kts *KeeperTestSuite) TestGrpcGetRecordLists() { false, 3, }, - // TODO: Uncomment after implementing filtering by attributes - // { - // "Filter with type", - // &types.QueryRecordsRequest{ - // Attributes: []*types.QueryRecordsRequest_KeyValueInput{ - // { - // Key: "type", - // Value: &types.QueryRecordsRequest_ValueInput{ - // Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "WebsiteRegistrationRecord"}, - // }, - // }, - // }, - // All: true, - // }, - // true, - // false, - // 1, - // }, + { + "Filter with type", + &types.QueryRecordsRequest{ + Attributes: []*types.QueryRecordsRequest_KeyValueInput{ + { + Key: "type", + Value: &types.QueryRecordsRequest_ValueInput{ + Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "WebsiteRegistrationRecord"}, + }, + }, + }, + All: true, + }, + true, + false, + 1, + }, // Skip the following test as querying with recursive values not supported (PR https://git.vdb.to/cerc-io/laconicd/pulls/112) // See function RecordsFromAttributes (QueryValueToJSON call) in the registry keeper implementation (x/registry/keeper/keeper.go) // { @@ -109,57 +108,57 @@ func (kts *KeeperTestSuite) TestGrpcGetRecordLists() { // false, // 1, // }, - // { - // "Filter with tag (non-existent) (https://git.vdb.to/cerc-io/laconicd/issues/129)", - // &types.QueryRecordsRequest{ - // Attributes: []*types.QueryRecordsRequest_KeyValueInput{ - // { - // Key: "tags", - // Value: &types.QueryRecordsRequest_ValueInput{ - // Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "NOEXIST"}, - // }, - // }, - // }, - // All: true, - // }, - // true, - // false, - // 0, - // }, - // { - // "Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)", - // &types.QueryRecordsRequest{ - // Attributes: []*types.QueryRecordsRequest_KeyValueInput{ - // { - // Key: "typ", - // Value: &types.QueryRecordsRequest_ValueInput{ - // Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "eWebsiteRegistrationRecord"}, - // }, - // }, - // }, - // All: true, - // }, - // true, - // false, - // 0, - // }, - // { - // "Filter with attributes ServiceProviderRegistration", - // &types.QueryRecordsRequest{ - // Attributes: []*types.QueryRecordsRequest_KeyValueInput{ - // { - // Key: "x500state_name", - // Value: &types.QueryRecordsRequest_ValueInput{ - // Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "california"}, - // }, - // }, - // }, - // All: true, - // }, - // true, - // false, - // 1, - // }, + { + "Filter with tag (non-existent) (https://git.vdb.to/cerc-io/laconicd/issues/129)", + &types.QueryRecordsRequest{ + Attributes: []*types.QueryRecordsRequest_KeyValueInput{ + { + Key: "tags", + Value: &types.QueryRecordsRequest_ValueInput{ + Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "NOEXIST"}, + }, + }, + }, + All: true, + }, + true, + false, + 0, + }, + { + "Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)", + &types.QueryRecordsRequest{ + Attributes: []*types.QueryRecordsRequest_KeyValueInput{ + { + Key: "typ", + Value: &types.QueryRecordsRequest_ValueInput{ + Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "eWebsiteRegistrationRecord"}, + }, + }, + }, + All: true, + }, + true, + false, + 0, + }, + { + "Filter with attributes ServiceProviderRegistration", + &types.QueryRecordsRequest{ + Attributes: []*types.QueryRecordsRequest_KeyValueInput{ + { + Key: "x500state_name", + Value: &types.QueryRecordsRequest_ValueInput{ + Value: &types.QueryRecordsRequest_ValueInput_String_{String_: "california"}, + }, + }, + }, + All: true, + }, + true, + false, + 1, + }, } for _, test := range testCases { kts.Run(fmt.Sprintf("Case %s ", test.msg), func() { @@ -385,13 +384,13 @@ func (kts *KeeperTestSuite) TestGrpcQueryWhoIs() { true, 1, }, - // { - // "Success", - // &types.QueryWhoisRequest{}, - // true, - // false, - // 1, - // }, + { + "Success", + &types.QueryWhoisRequest{}, + true, + false, + 1, + }, } for _, test := range testCases { kts.Run(fmt.Sprintf("Case %s ", test.msg), func() {