第十阶段 stage 2(四):浏览器页(全局账本)、Web3 页签折行
This commit is contained in:
1 parent
e3e5ec2d6e
commit
a3e955ca59
17 files changed
+199
-6
No files matched your search
@@ -410,6 +410,21 @@ internal static class Program
|
||||
Check(Stablecoins.PriceOfRatio(Tuning.CraSafeRatio) == 1 && Near(Stablecoins.PriceOfRatio(Tuning.CraCrashRatio), 1 - Tuning.CraDiscountMax, 1e-9), "价格曲线:安全线 1,崩盘线折价 15%");
|
||||
});
|
||||
|
||||
Test("浏览器账本:最新在前、按地址过滤、超过上限丢最旧", () =>
|
||||
{
|
||||
var l = new Ledger();
|
||||
string a = ChainAddress.Make(1), b = ChainAddress.Make(2), c = ChainAddress.Make(3);
|
||||
l.Add(new LedgerEntry { Block = 1, From = a, To = b, Asset = "PSC", Amount = 1 });
|
||||
l.Add(new LedgerEntry { Block = 2, From = b, To = c, Asset = "CRC", Amount = 5, Fee = 1 });
|
||||
l.Add(new LedgerEntry { Block = 3, From = c, To = a, Asset = "PSC", Amount = 0 });
|
||||
Check(l.Entries.Count == 2 && l.Entries[0].Block == 2, "数额为 0 不记;最新的在前");
|
||||
Check(l.Of(b, 10).Count == 2 && l.Of(a, 10).Count == 1 && l.Of(a.ToUpperInvariant(), 10).Count == 1 && l.Of("", 10).Count == 2, "按地址过滤,大小写不敏感,空地址是最近的全部");
|
||||
for (int i = 0; i < Tuning.LedgerMax + 30; i++) l.Add(new LedgerEntry { Block = 100 + i, From = a, To = b, Asset = "PSC", Amount = 1 });
|
||||
Check(l.Entries.Count == Tuning.LedgerMax && l.Entries[0].Block == 100 + Tuning.LedgerMax + 29 && l.Of("", 5).Count == 5, "上限 200 条");
|
||||
var back = Newtonsoft.Json.JsonConvert.DeserializeObject<Ledger>(Newtonsoft.Json.JsonConvert.SerializeObject(l));
|
||||
Check(back.Entries.Count == l.Entries.Count && back.Entries[0].Block == l.Entries[0].Block, "存档往返");
|
||||
});
|
||||
|
||||
Test("CRA 长期行为:200 天里有的局崩盘有的不崩,质押越多崩得越多,崩盘前有预兆", () =>
|
||||
{
|
||||
Func<double, (double crash, double lead)> run = staked =>
|
||||
|
||||
Reference in new issue
Block a user