Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC-1213: add "CodeCrafters internal error" to anticheat error scenarios #146

Merged
merged 2 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/anti_cheat.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ import (
)

func antiCheatTest(stageHarness *test_case_harness.TestCaseHarness) error {
logger := stageHarness.Logger

b := redis_executable.NewRedisExecutable(stageHarness)
if err := b.Run(); err != nil {
return err
logger.Criticalf("CodeCrafters internal error. Error instantiating executable: %v", err)
logger.Criticalf("Try again? Please contact us at hello@codecrafters.io if this persists.")
return fmt.Errorf("anti-cheat (ac1) failed")
}

logger := stageHarness.Logger

client, err := instrumented_resp_connection.NewFromAddr(stageHarness, "localhost:6379", "replica")
if err != nil {
logFriendlyError(logger, err)
return err
logger.Criticalf("CodeCrafters internal error. Error creating connection to redis server: %v", err)
logger.Criticalf("Try again? Please contact us at hello@codecrafters.io if this persists.")
return fmt.Errorf("anti-cheat (ac1) failed")
}
defer client.Close()

Expand All @@ -36,7 +40,7 @@ func antiCheatTest(stageHarness *test_case_harness.TestCaseHarness) error {

if err == nil {
logger.Criticalf("anti-cheat (ac1) failed.")
logger.Criticalf("Please contact us at hello@codecrafters.io if you think is a mistake.")
logger.Criticalf("Please contact us at hello@codecrafters.io if you think this is a mistake.")
return fmt.Errorf("anti-cheat (ac1) failed")
} else {
return nil
Expand Down
Loading