Add persistent AFK reserves for both engines (Refs #12)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// Compile the actual GSC registration adapter against portable VM interfaces.
|
||||
#include <fstream>
|
||||
int main()
|
||||
{
|
||||
afk::component component; component.on_startup(nullptr);
|
||||
const auto call = [](const std::string& name, std::vector<std::string> args = {})
|
||||
{ return gsc::function::functions.at(name)(args); };
|
||||
assert(call("afkversion").as<std::string>() == "1.0.0");
|
||||
auto ack=call("afkresponse",{"private-secret-invalid-json"}).as<scripting::array>();
|
||||
assert(!ack["valid"].as<bool>() && ack["reason"].as<std::string>() == "invalid_json");
|
||||
assert(call("afkload",{"server","endpoint"}).is<scripting::array>());
|
||||
for (int i=0;i<2;++i) assert(!call("afkstore",{"server","endpoint","private-secret Authorization"}).as<bool>());
|
||||
const std::string body=R"({"server":"server","guid":"1234","match":"match","request_id":"one","action":"reserve","session_id":"session","seconds":600})";
|
||||
assert(call("afkstore",{"server","endpoint",body}).as<bool>());
|
||||
assert(call("afkprepare",{"server","endpoint",body}).as<bool>());
|
||||
assert(call("afkauthorize",{"server","endpoint","session","600"}).as<bool>());
|
||||
assert(call("afkbegin",{"server","endpoint","session"}).as<bool>());
|
||||
assert(call("afkremaining",{"server","endpoint","session"}).as<int>() > 0);
|
||||
assert(call("afkcheckpoint",{"server","endpoint","session"}).as<int>() >= 0);
|
||||
assert(call("afkstop",{"server","endpoint","session","manual"}).as<bool>());
|
||||
assert(call("afkrecover",{"server","endpoint","new-match"}).as<bool>());
|
||||
std::filesystem::path file;
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator("tws-afk"))
|
||||
if (entry.path().extension() == ".json") file=entry.path();
|
||||
assert(!file.empty());
|
||||
{ std::ofstream stream(file); stream << "private-secret-corrupt-journal"; }
|
||||
for (int i=0;i<2;++i)
|
||||
{
|
||||
assert(call("afkload",{"server","endpoint"}).get_raw().type == game::SCRIPT_NONE);
|
||||
assert(!call("afkremove",{"server","endpoint","one"}).as<bool>());
|
||||
}
|
||||
std::filesystem::remove(file);
|
||||
assert(call("afkload",{"server","endpoint"}).is<scripting::array>());
|
||||
assert(call("afkremove",{"server","endpoint","one"}).as<bool>());
|
||||
}
|
||||
Reference in New Issue
Block a user