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

[YAML] Remove GetUniqueDiscriminator since cross-talks seems to be gone now #15784

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/tests/suites/TestDiscovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ config:
endpoint: 0
discriminator:
type: INT16U
defaultValue: GetUniqueDiscriminator()
defaultValue: 3840
vendorId:
type: INT16U
defaultValue: 65521
Expand Down
25 changes: 0 additions & 25 deletions src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <lib/support/SafeInt.h>
#include <platform/CHIPDeviceLayer.h>
#include <random>

CHIP_ERROR DiscoveryCommands::FindCommissionable()
{
Expand Down Expand Up @@ -114,36 +113,12 @@ CHIP_ERROR DiscoveryCommands::TearDownDiscoveryCommands()
return CHIP_NO_ERROR;
}

uint16_t DiscoveryCommands::GetUniqueDiscriminator()
{
if (mDiscriminatorUseForFiltering == 0)
{
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> distribution(1, 4096);
mDiscriminatorUseForFiltering = static_cast<uint16_t>(distribution(rng));
}
return mDiscriminatorUseForFiltering;
}

void DiscoveryCommands::OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData)
{
// TODO: If multiple results are found for the same filter, then the test result depends
// on which result comes first. At the moment, the code assume that there is only
// a single match on the network, but if that's not enough, there may be a need
// to implement some sort of list that is built for a given duration before returning
//
// But also, running on CI seems to show cross-talks between CI instances, so multiple
// results will comes up. Unexpected advertisements are filtered by validating the
// discriminator from the advertisement matches the one coming from the config section
// of the test.
if (nodeData.longDiscriminator != GetUniqueDiscriminator())
{
ChipLogError(chipTool, "Non fatal error: Unexpected node advertisment. It will be ignored");
nodeData.LogDetail();
return;
}

ReturnOnFailure(TearDownDiscoveryCommands());

nodeData.LogDetail();
Expand Down
5 changes: 0 additions & 5 deletions src/app/tests/suites/commands/discovery/DiscoveryCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ class DiscoveryCommands : public chip::Dnssd::CommissioningResolveDelegate
/////////// CommissioningDelegate Interface /////////
void OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) override;

protected:
// This function initialize a random discriminator once and returns it all the time afterwards
uint16_t GetUniqueDiscriminator();

private:
bool mReady = false;
chip::Dnssd::ResolverProxy mDNSResolver;
uint16_t mDiscriminatorUseForFiltering = 0;
};
11 changes: 5 additions & 6 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.