Skip to content

Commit

Permalink
[YAML] Remove GetUniqueDiscriminator since cross-talks seems to be go…
Browse files Browse the repository at this point in the history
…ne now
  • Loading branch information
vivien-apple committed Mar 3, 2022
1 parent 2c4fb91 commit 764e944
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
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;
};

0 comments on commit 764e944

Please sign in to comment.