// Executed with the actual registration adapter and portable engine interfaces. #include int main() { bank::component component; component.on_startup(nullptr); const auto call = [](const std::string& name, std::vector args = {}) { return gsc::function::functions.at(name)(args); }; assert(call("bankversion").as() == "1.2.0"); auto ack = call("bankresponse", {"private-secret-invalid-json"}).as(); assert(!ack["valid"].as()); assert(ack["reason"].as() == "invalid_json"); assert(ack["code"].as().empty()); assert(call("bankload", {"server", "endpoint"}).is()); for (int i = 0; i < 2; ++i) assert(!call("bankstore", {"server", "endpoint", "private-secret Authorization"}).as()); const std::string body = R"({"server":"server","request_id":"one","decision":"cancel"})"; assert(call("bankstore", {"server", "endpoint", body}).as()); const auto root = bank::spool("server", "endpoint"); assert(root.load().size() == 1); // Locate only the test process's temporary outbox. std::filesystem::path file; for (const auto& entry : std::filesystem::recursive_directory_iterator("tws-bank")) 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("bankload", {"server", "endpoint"}).get_raw().type == game::SCRIPT_NONE); assert(!call("bankremove", {"server", "endpoint", "one"}).as()); } std::filesystem::remove(file); assert(call("bankload", {"server", "endpoint"}).is()); assert(call("bankremove", {"server", "endpoint", "one"}).as()); }