Hardware wallet window: invoices paid from PLEDGER, checksummed addresses, DEX signing, block confirmation animation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5b7013f240
commit
add61a6b5e
16 files changed
+768
-63
No files matched your search
@@ -789,6 +789,25 @@ internal static class Program
|
||||
Check(personalListings > 100 && lo < 0.65 && hi > 1.05, $"个人卖家每件价格系数分散:{lo:0.00}–{hi:0.00}");
|
||||
});
|
||||
|
||||
Test("链上地址校验位", () =>
|
||||
{
|
||||
var rng = new Rng(5);
|
||||
int caught = 0, typos = 0;
|
||||
for (int i = 0; i < 2000; i++)
|
||||
{
|
||||
string a = ChainAddress.Make(rng.NextUInt());
|
||||
Check(ChainAddress.Valid(a) && ChainAddress.Valid(a.ToUpperInvariant().Replace("0X", "0x")) && ChainAddress.Valid(" " + a + " "), "生成的地址合法,大小写、空格不影响:" + a);
|
||||
int pos = 2 + rng.Range(0, ChainAddress.BodyLength + ChainAddress.CheckLength - 1);
|
||||
char c = a[pos];
|
||||
char t = "0123456789abcdef"[(Convert.ToInt32(c.ToString(), 16) + 1 + rng.Range(0, 14)) % 16];
|
||||
string typo = a.Substring(0, pos) + t + a.Substring(pos + 1);
|
||||
typos++;
|
||||
if (!ChainAddress.Valid(typo)) caught++;
|
||||
}
|
||||
Check(caught > typos * 0.98 && caught < typos, $"输错一位几乎都被校验位拦下,极少数碰巧合法:{caught}/{typos}");
|
||||
Check(!ChainAddress.Valid("0x12345") && !ChainAddress.Valid("0xzzzzzzzz") && !ChainAddress.WellFormed("12345678ab"), "格式不对的地址不合法");
|
||||
});
|
||||
|
||||
Console.WriteLine($"\n{_passed} 通过,{_failed} 失败");
|
||||
return _failed == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user