Chain drama: fee tiers, congestion, mempool drops, address poisoning, clipboard hijack, phishing; selected-button style
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2b781acd82
commit
dbba8b4376
15 files changed
+357
-20
No files matched your search
@@ -808,6 +808,27 @@ internal static class Program
|
||||
Check(!ChainAddress.Valid("0x12345") && !ChainAddress.Valid("0xzzzzzzzz") && !ChainAddress.WellFormed("12345678ab"), "格式不对的地址不合法");
|
||||
});
|
||||
|
||||
Test("相似地址、手续费、确认数", () =>
|
||||
{
|
||||
var rng = new Rng(21);
|
||||
int sameShort = 0;
|
||||
for (int i = 0; i < 300; i++)
|
||||
{
|
||||
string a = ChainAddress.Make(rng.NextUInt());
|
||||
string f = ChainAddress.Lookalike(a, rng);
|
||||
Check(ChainAddress.Valid(f) && !ChainAddress.Same(a, f) && f.Substring(0, 5) == a.Substring(0, 5), $"相似地址合法、不同、前缀相同:{a} / {f}");
|
||||
if (ChainAddress.Short(a) == ChainAddress.Short(f)) sameShort++;
|
||||
}
|
||||
Check(sameShort > 290, $"缩写看起来一样:{sameShort}/300");
|
||||
Check(TxRules.FeeCredits(FeeTier.Slow, false) < TxRules.FeeCredits(FeeTier.Normal, false) && TxRules.FeeCredits(FeeTier.Normal, false) < TxRules.FeeCredits(FeeTier.Fast, false), "慢 < 普通 < 快");
|
||||
Check(Math.Abs(TxRules.FeeCredits(FeeTier.Fast, true) - Tuning.TxFeeFast * Tuning.TxCongestedFeeMult) < 1e-9, "拥堵时手续费翻倍");
|
||||
Check(TxRules.Confirmations(100) == 3 && TxRules.Confirmations(5000) == 6 && TxRules.Confirmations(50000) == 12, "大额要更多确认");
|
||||
Check(TxRules.DropChance(FeeTier.Slow, true) > 0 && TxRules.DropChance(FeeTier.Slow, false) == 0 && TxRules.DropChance(FeeTier.Fast, true) == 0, "只有拥堵时的慢档会被丢");
|
||||
var h = new List<TxRecord>();
|
||||
for (int i = 0; i < 30; i++) TxRules.Record(h, new TxRecord { Day = i });
|
||||
Check(h.Count == TxRules.HistoryMax && h[0].Day == 29, "记录最新在前、有上限");
|
||||
});
|
||||
|
||||
Test("被投毒的钱包:门槛以下不转,越多越快,转空", () =>
|
||||
{
|
||||
Check(Wallet.DrainChance(Tuning.WalletDrainMin - 1) == 0, "门槛以下不会被转走");
|
||||
|
||||
Reference in new issue
Block a user