Skip to content

Commit f46e3bf

Browse files
AlexAlves87claude
andcommitted
fix(tests): isolate locale and device identity from host environment
FormatBytes used locale-sensitive interpolation ($"{val:F1}") which produced commas instead of dots on systems with a non-English decimal separator. Use ToString("F1", CultureInfo.InvariantCulture) so the output is always dot-separated regardless of host locale. OperatorConnect_FreshBootstrapDevice_StartsWithV2Signature and OperatorConnect_SharedTokenDevice_StartsWithV3Signature passed null as identityPath, causing the client to read the real device identity from %APPDATA%\OpenClawTray on machines where the app is installed and paired. On those machines _useV2Signature was computed from a live device token, making the bootstrap assertion fail. Pass a fresh temp directory so the tests start with no device state. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent e0a4b7c commit f46e3bf

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎src/OpenClaw.Shared/ChatAttachment.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.IO;
34
using System.Text.Json.Serialization;
45
using System.Threading.Tasks;
@@ -126,8 +127,8 @@ private static string FormatBytes(long bytes)
126127
return bytes switch
127128
{
128129
< 1024 => $"{bytes} B",
129-
< 1024 * 1024 => $"{bytes / 1024.0:F1} KB",
130-
_ => $"{bytes / (1024.0 * 1024.0):F1} MB"
130+
< 1024 * 1024 => $"{(bytes / 1024.0).ToString("F1", CultureInfo.InvariantCulture)} KB",
131+
_ => $"{(bytes / (1024.0 * 1024.0)).ToString("F1", CultureInfo.InvariantCulture)} MB"
131132
};
132133
}
133134
}

‎tests/OpenClaw.Shared.Tests/OpenClawGatewayClientTests.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,19 @@ public void OperatorConnect_FreshDevice_RequestsBootstrapHandoffScopes()
461461
[Fact]
462462
public void OperatorConnect_FreshBootstrapDevice_StartsWithV2Signature()
463463
{
464-
var helper = new GatewayClientTestHelper(tokenIsBootstrapToken: true);
465-
helper.SetDeviceTokenForTest(null);
464+
var tmpDir = Path.Combine(Path.GetTempPath(), $"oca-gw-test-{Guid.NewGuid():N}");
465+
Directory.CreateDirectory(tmpDir);
466+
var helper = new GatewayClientTestHelper(tokenIsBootstrapToken: true, identityPath: tmpDir);
466467

467468
Assert.True(helper.Client.UseV2Signature);
468469
}
469470

470471
[Fact]
471472
public void OperatorConnect_SharedTokenDevice_StartsWithV3Signature()
472473
{
473-
var helper = new GatewayClientTestHelper(tokenIsBootstrapToken: false);
474-
helper.SetDeviceTokenForTest(null);
474+
var tmpDir = Path.Combine(Path.GetTempPath(), $"oca-gw-test-{Guid.NewGuid():N}");
475+
Directory.CreateDirectory(tmpDir);
476+
var helper = new GatewayClientTestHelper(tokenIsBootstrapToken: false, identityPath: tmpDir);
475477

476478
Assert.False(helper.Client.UseV2Signature);
477479
}

0 commit comments

Comments
 (0)