Skip to content

Commit

Permalink
Merge pull request #106 from eosnetworkfoundation/deep-mind-nondet
Browse files Browse the repository at this point in the history
Fixes for non-determinism in dfuse tests
  • Loading branch information
swatanabe authored Apr 14, 2022
2 parents 61ce643 + cbf6326 commit fdc7e00
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 64 deletions.
7 changes: 6 additions & 1 deletion libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,13 @@ namespace eosio { namespace testing {
preactivations.emplace_back( feature_digest );
};

std::vector<builtin_protocol_feature_t> ordered_builtins;
for( const auto& f : builtin_protocol_feature_codenames ) {
auto digest = pfs.get_builtin_digest( f.first );
ordered_builtins.push_back( f.first );
}
std::sort( ordered_builtins.begin(), ordered_builtins.end() );
for( const auto& f : ordered_builtins ) {
auto digest = pfs.get_builtin_digest( f);
if( !digest ) continue;
add_digests( *digest );
}
Expand Down
122 changes: 61 additions & 61 deletions unittests/deep-mind/deep-mind.log

Large diffs are not rendered by default.

44 changes: 42 additions & 2 deletions unittests/deep_mind_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ std::string merge_line(const std::string& line, const std::string& pattern)
std::string result;
auto line_iter = line.begin(), line_end = line.end();
auto pattern_iter = pattern.begin(), pattern_end = pattern.end();
// The nondeterministic data is an fc::microseconds object in
// the traces, which is 8-bytes long.
static constexpr int xdigit_group = 16;
int current_xdigits = 0;
int skip_xdigit = 0;
while(line_iter != line_end && pattern_iter != pattern_end)
{
if(*pattern_iter == '\\')
Expand All @@ -99,6 +104,7 @@ std::string merge_line(const std::string& line, const std::string& pattern)
// Either manually edited or does not match
return pattern;
}
current_xdigits = 0;
result.push_back('\\');
result.push_back(*pattern_iter);
}
Expand All @@ -109,9 +115,23 @@ std::string merge_line(const std::string& line, const std::string& pattern)
// Does not match
return pattern;
}
result += "[[:xdigit:]]";
if(skip_xdigit && *line_iter == '0') {
result += '0';
} else {
++current_xdigits;
result += "[[:xdigit:]]";
}
++line_iter;
pattern_iter += 12;
if(skip_xdigit)
{
--skip_xdigit;
}
if(current_xdigits == xdigit_group)
{
current_xdigits = 0;
skip_xdigit = xdigit_group;
}
continue;
}
else if(is_escaped(*pattern_iter))
Expand All @@ -121,12 +141,23 @@ std::string merge_line(const std::string& line, const std::string& pattern)
}
else if(*line_iter == *pattern_iter)
{
result.push_back(*line_iter);
if(current_xdigits > 0 && current_xdigits < xdigit_group && *line_iter == '0')
{
++current_xdigits;
result += "[[:xdigit:]]";
}
else
{
current_xdigits = 0;
result.push_back(*line_iter);
}
}
else
{
if(std::isxdigit(*line_iter) && std::isxdigit(*pattern_iter))
{
skip_xdigit = 0;
++current_xdigits;
result += "[[:xdigit:]]";
}
else
Expand All @@ -137,6 +168,15 @@ std::string merge_line(const std::string& line, const std::string& pattern)
}
++line_iter;
++pattern_iter;
if(skip_xdigit)
{
--skip_xdigit;
}
if(current_xdigits == xdigit_group)
{
current_xdigits = 0;
skip_xdigit = xdigit_group;
}
}
if(line_iter != line_end || pattern_iter != pattern_end)
{
Expand Down

0 comments on commit fdc7e00

Please sign in to comment.