Skip to main content

Testing

Testing✍️

Background

Once you have the SDK or API directly integrated into your game, you will need to test the integration. Luckily, Haste provides an easy mechanism for testing your games without requiring payments to be sent or leaderboards to be populated with testing data. Haste Arcade provides two modes of play for your game: production and nonproduction. Both modes will perform all the same work in the Haste Arcade with two primary differences: Nonproduction mode will not send or receive any payments, and any scores submitted will not be placed on a leaderboard.

The Haste team recommends always using nonproduction mode through all lower level environments. This would likely include local development and any remote development, staging, and qa environments. Once your game is moved to a production environment, it is recommended to use nonproduction for your initial testing of production. Once you feel confident in your game, you may then change the value to production and launch the game officially. It is strongly recommended to use an environment variable to define the Haste Arcade environment. This allows for payments to easily be turned on and off without modifying code and redeploying.

Selecting a Haste Environment

The following sections will demonstrate how to select nonproduction or production for the Haste environment. The first is specific to Haste'safely Typescript SDK, and the second is for manual API integration.

Server Typescript SDK

initialize.tsx
// the following variable can be production or nonproduction
// for testing, this value should always be nonproduction
// ideally, this will be a server environment variable.
const environment = "nonproduction"; //make env var
const haste = await Haste.build(
process.env.HASTE_SERVER_CLIENT_ID,
process.env.HASTE_SERVER_CLIENT_SECRET,
environment
);

Using a server environment variable for the Haste environment will allow you to quickly switch between nonproduction and production mode without redeploying.

API Manual Integration

ServerIntegration.cs
// the hasteServerEnvironment variable can be production or nonproduction
// for testing, this value should always be nonproduction
// ideally, this will be a server environment variable.
public IEnumerator GetServerToken(string hasteServerClientId, string hasteServerSecret, string hasteServerEnvironment = "nonproduction")
{
// first you need to get a token
var path = "/oauth/writetoken";
var data = new Dictionary<string, string>();
data.Add("clientId", hasteServerClientId);
data.Add("clientSecret", hasteServerSecret);
data.Add("environment", hasteServerEnvironment);

PostRequest<HasteServerAuthResult>($"{_apiUrl}{path}", data);
}