fix: UpsertUserAll 因 playSpecial 越界被服务器 500 拒绝
calcRandom() 移植的是 C# 里声明为 int 的 32 位比特反转,`<<=` 溢出按二进制 补码环绕,结果恒为合法 signed int32(高位被置起时为负)。Dart 的 int 是 64 位 且被反转值恒正,于是约一半概率产出 [2^31, 2^32) 的正数(如 3212134032),超出 UserGamePlaylog.playSpecial 的 int 声明,服务器整个 body 反序列化失败返回 HTTP 500,表现为解锁歌曲/获取收藏品不可用。按 C# 位模式重解释为 signed 32 位。 同时补上 userPlaylogList 缺少的 extBool3(UserPlaylog.cs:337 声明的 bool)。
This commit is contained in:
1 parent
79fa0d7a20
commit
ebd1fdddaa
3 files changed
+21
-1
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ichino/services/title_api_service.dart';
|
||||
|
||||
void main() {
|
||||
// UserGamePlaylog.playSpecial 在客户端里声明为 int(int32)。越界会让服务器
|
||||
// 反序列化失败并返回 HTTP 500,而旧实现有约一半概率越界。
|
||||
test('calcRandom 恒在 int32 范围内', () {
|
||||
const min = -2147483648;
|
||||
const max = 2147483647;
|
||||
for (var i = 0; i < 20000; i++) {
|
||||
final v = TitleApiService.calcRandom();
|
||||
expect(v, inInclusiveRange(min, max), reason: '第 $i 次采样得到 $v');
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user