Table of Contents

Class GlobalKeyFixture

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

Puts a world into a known progression state: sets and removes global keys (boss progress, events, world modifiers) on the server and waits until a joined client reports the same set, through ValheimCLI's read-only valheim.observe/globalkeys on both sides and the Adapter package's guarded GlobalKeyCommands.Change fixture command on the server. In Valheim 1.0.16 the server sends its whole list to every client after each change and the client replaces its own list with it, so the client's set must equal the server's exactly. Keys are lower case, name or name value. Each change is issued once; only the read-only lists are re-read. ValheimCLI's cli_check_global_key answers for one key at a time, so it cannot show a key the client has and the server does not; the listing can.

public static class GlobalKeyFixture
Inheritance
object
GlobalKeyFixture

Fields

ChangeSource

public const string ChangeSource = "global-key-change"

Field Value

string

Source

public const string Source = "global-keys"

Field Value

string

Methods

Apply(GameActor, GameActor, string, string, IEnumerable<string>, IEnumerable<string>, TimeSpan, TimeSpan, Func<TimeSpan, CancellationToken, Task>?, CancellationToken)

The fixture action: sets each of set (name or name value) and removes each of remove on the server, each once and in that order, then waits until the client reports the server's set (WaitForClient(GameActor, GameActor, string, TimeSpan, TimeSpan, Func<TimeSpan, CancellationToken, Task>?, CancellationToken)). Returns the keys both sides hold.

public static Task<IReadOnlyList<string>> Apply(GameActor server, GameActor client, string changePath, string listPath, IEnumerable<string> set, IEnumerable<string> remove, TimeSpan timeout, TimeSpan interval, Func<TimeSpan, CancellationToken, Task>? changed = null, CancellationToken cancellation = default)

Parameters

server GameActor
client GameActor
changePath string
listPath string
set IEnumerable<string>
remove IEnumerable<string>
timeout TimeSpan
interval TimeSpan
changed Func<TimeSpan, CancellationToken, Task>
cancellation CancellationToken

Returns

Task<IReadOnlyList<string>>

Compare(IEnumerable<string>, IEnumerable<string>)

Compares two key sets exactly (ordinal; the game stores keys lower case).

public static GlobalKeyDifference Compare(IEnumerable<string> server, IEnumerable<string> client)

Parameters

server IEnumerable<string>
client IEnumerable<string>

Returns

GlobalKeyDifference

Read(GameActor, string)

The keys actor's process holds, read through listPath (for example valheim.observe/globalkeys).

public static IReadOnlyList<string> Read(GameActor actor, string listPath)

Parameters

actor GameActor
listPath string

Returns

IReadOnlyList<string>

Remove(GameActor, string, string)

Removes name, whatever its value, on the server, once, and returns the server's keys after it.

public static IReadOnlyList<string> Remove(GameActor server, string changePath, string name)

Parameters

server GameActor
changePath string
name string

Returns

IReadOnlyList<string>

Set(GameActor, string, string, string?)

Sets name (with value, if given) on the server, once, and returns the server's keys after it. Throws if the server's reply does not hold the key with that value.

public static IReadOnlyList<string> Set(GameActor server, string changePath, string name, string? value = null)

Parameters

server GameActor
changePath string
name string
value string

Returns

IReadOnlyList<string>

WaitForClient(GameActor, GameActor, string, TimeSpan, TimeSpan, Func<TimeSpan, CancellationToken, Task>?, CancellationToken)

Waits until the client lists exactly the server's keys and returns them. Both lists are re-read each time, at most interval apart, or sooner when changed completes (for example the client's "client got keys" log line through a LogWait opened before the change). Expiry throws WaitTimeoutException naming the keys that still differ.

public static Task<IReadOnlyList<string>> WaitForClient(GameActor server, GameActor client, string listPath, TimeSpan timeout, TimeSpan interval, Func<TimeSpan, CancellationToken, Task>? changed = null, CancellationToken cancellation = default)

Parameters

server GameActor
client GameActor
listPath string
timeout TimeSpan
interval TimeSpan
changed Func<TimeSpan, CancellationToken, Task>
cancellation CancellationToken

Returns

Task<IReadOnlyList<string>>