Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyiqian1 committed Oct 17, 2024
1 parent d75eed3 commit 66857f0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/test/rpc/AccountObjects_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,14 +1273,14 @@ class AccountObjects_test : public beast::unit_test::suite
}

// this lambda function is used to check invalid marker response.
auto testInvalidMarker = [&env, &bob](std::string& marker) {
auto testInvalidMarker = [&](std::string& marker) {
Json::Value params;
params[jss::account] = bob.human();
params[jss::limit] = 11;
params[jss::limit] = limit;
params[jss::ledger_index] = jss::validated;
params[jss::marker] = marker;
Json::Value const resp =
env.rpc("json", "account_nfts", to_string(params));
env.rpc("json", "account_objects", to_string(params));
return resp[jss::result][jss::error_message] ==
"Invalid field \'marker\'.";
};
Expand All @@ -1304,47 +1304,47 @@ class AccountObjects_test : public beast::unit_test::suite
}

// test account_objects with an invalid marker containing invalid
// dirIndex with marker: ",entryIndex"
// dirIndex by replacing some characters from the dirIndex.
{
std::string s = ',' + entryIndex;
std::string s = markerStr;
s.replace(0, 7, "FFFFFFF");
BEAST_EXPECT(testInvalidMarker(s));
}

// test account_objects with an invalid marker containing invalid
// dirIndex with marker: "0,entryIndex"
// entryIndex by replacing some characters from the entryIndex.
{
std::string s = "0," + entryIndex;
std::string s = entryIndex;
s.replace(0, 7, "FFFFFFF");
s = dirIndex + ',' + s;
BEAST_EXPECT(testInvalidMarker(s));
}

// test account_objects with an invalid marker containing invalid
// dirIndex by replacing some characters from the dirIndex.
// dirIndex with marker: ",entryIndex"
{
std::string s = markerStr;
s.replace(0, 7, "FFFFFFF");
std::string s = ',' + entryIndex;
BEAST_EXPECT(testInvalidMarker(s));
}

// test account_objects with an invalid marker containing invalid
// entryIndex with marker: "dirIndex,"
// dirIndex with marker: "0,entryIndex"
{
std::string s = dirIndex + ',';
std::string s = "0," + entryIndex;
BEAST_EXPECT(testInvalidMarker(s));
}

// test account_objects with an invalid marker containing invalid
// entryIndex with marker: "dirIndex,0"
// entryIndex with marker: "dirIndex,"
{
std::string s = dirIndex + ',';
BEAST_EXPECT(testInvalidMarker(s));
}

// test account_objects with an invalid marker containing invalid
// entryIndex by replacing some characters from the entryIndex.
// entryIndex with marker: "dirIndex,0"
{
std::string s = entryIndex;
s.replace(0, 7, "FFFFFFF");
s = dirIndex + ',' + s;
std::string s = dirIndex + ",0";
BEAST_EXPECT(testInvalidMarker(s));
}

Expand Down

0 comments on commit 66857f0

Please sign in to comment.