版本 1.0.0-rc8:卖货橱窗重构、收款币种、Gas 档位速度、区块自然增长、钱包持仓
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
018ee7d0d2
commit
93e26fc4f5
20 files changed
+582
-498
No files matched your search
@@ -902,20 +902,44 @@ internal static class Program
|
||||
Check(fake > 150 && fake < 250, $"假卡约一半被看穿退货:{fake}/400");
|
||||
// 平台跑路:上架的货与未放款货款都没了
|
||||
var b4 = new BlackMarket(); var w4 = new Wallet(); w4.Add(Assets.CRT, 100000);
|
||||
for (int i = 0; i < 30; i++) b4.List("c4", null, null, 0, 5000, 1.8, w4, Assets.CRT, 1, price);
|
||||
for (int i = 0; i < 30; i++) b4.List("c" + (i % 6), null, null, 0, 5000, 1.8, w4, Assets.CRT, 1, price);
|
||||
bool rugged = false;
|
||||
for (int d = 2; d < 400 && !rugged; d++) { var ev = b4.Night(d, false, w4, new Rng((ulong)d * 31), 0, price); rugged = ev.Any(e => e.Kind == "sale_rug"); }
|
||||
Check(rugged && b4.Sales.All(x => x.State != SaleState.Listed && x.State != SaleState.Sold), "跑路:上架与未放款全部归零");
|
||||
var b6 = new BlackMarket(); var w6 = new Wallet(); w6.Add(Assets.CRT, 100000);
|
||||
int ok6 = 0; for (int i = 0; i < 15; i++) if (b6.List("c4", null, null, 0, 500, 1.0, w6, Assets.CRT, 1, price) != null) ok6++;
|
||||
Check(ok6 == Tuning.BmMaxListings && b6.ActiveListings == 10, "同时最多上架 10 件");
|
||||
var b7 = new BlackMarket(); var w7 = new Wallet(); w7.Add(Assets.CRT, 5000);
|
||||
var s7 = b7.List("c4", null, null, 0, 500, 1.8, w7, Assets.CRT, 1, price);
|
||||
double c7 = w7.Get(Assets.CRT);
|
||||
Check(b7.Reprice(s7, 1.0, w7, Assets.CRT, 2, price) && s7.ListPrice == 500 && s7.Mult == 1.0 && Near(c7 - w7.Get(Assets.CRT), BlackMarket.RepriceFee(500), 1e-9), "改价:按参考价重算标价,收 2% 改价费");
|
||||
Check(!b7.Reprice(s7, 1.0, w7, Assets.CRT, 2, price) && !b7.Reprice(s7, 2.5, w7, Assets.CRT, 2, price) && Near(b7.SaleChance(s7.Mult), 0.5 * Math.Min(1.1, 90 / 90.0), 1e-9), "同倍率或超范围不改;改价后成交概率按新倍率");
|
||||
b7.Night(3, false, w7, new Rng(5), 0, price);
|
||||
Check(!b7.Reprice(s7, 0.6, w7, Assets.CRT, 4, price) || s7.State == SaleState.Listed, "已成交的货不能改价");
|
||||
int okStack = 0; for (int i = 0; i < 8; i++) if (b6.List("c4", null, null, 0, 500, 1.0, w6, Assets.CRT, 1, price) != null) okStack++;
|
||||
Check(okStack == Tuning.BmMaxStack && b6.ActiveKinds == 1 && b6.ActiveListings == 5, "同一种商品最多上架 5 件");
|
||||
int okKinds = 0; for (int k = 0; k < 9; k++) if (b6.List("k" + k, null, null, 0, 500, 1.0, w6, Assets.CRT, 1, price) != null) okKinds++;
|
||||
Check(b6.ActiveKinds == Tuning.BmMaxKinds && okKinds == Tuning.BmMaxKinds - 1, "同时最多上架 6 种");
|
||||
Check(b6.List("c4", null, null, 0, 500, 1.2, w6, Assets.CRT, 1, price) == null && b6.ListBlock(BmSale.KeyOf("c4", null, null, 0), 1.2, 1) != null && b6.ListBlock(BmSale.KeyOf("k0", null, null, 0), 1.2, 1) == "mult" && b6.ListBlock(BmSale.KeyOf("k0", null, null, 0), 1.0, 1) == null, "同一种商品倍率必须相同;种数满了新种不能上");
|
||||
b6.Delist(b6.Sales.First(x => x.Item == "k0"));
|
||||
Check(b6.ListBlock(BmSale.KeyOf("k0", null, null, 0), 1.2, 1) == null && b6.ListBlock(BmSale.KeyOf("zz", null, null, 0), 1.0, 1) == null, "下架后腾出名额,也可换倍率");
|
||||
// 收款币:每接受一种币多一轮成交判定,货款用命中的币付
|
||||
Func<int, string[], (int sold, int[] byCoin)> trial = (n, coins) =>
|
||||
{
|
||||
int sold = 0; var cnt = new int[4];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var bx = new BlackMarket(); var wx = new Wallet(); wx.Add(Assets.CRT, 1000);
|
||||
bx.SellAccepts = coins.ToList();
|
||||
var sx = bx.List("c4", null, null, 0, 500, 1.5, wx, Assets.CRT, 1, price);
|
||||
bx.Night(2, false, wx, new Rng((ulong)i + 11), 0, price);
|
||||
if (sx.State == SaleState.Sold) { sold++; cnt[Array.IndexOf(BlackMarket.SellCoins, sx.PayAsset)]++; }
|
||||
}
|
||||
return (sold, cnt);
|
||||
};
|
||||
var one = trial(4000, new[] { Assets.CRT });
|
||||
var all = trial(4000, BlackMarket.SellCoins);
|
||||
Check(all.sold > one.sold * 1.5 && one.byCoin.Skip(0).Where((c, i) => BlackMarket.SellCoins[i] != Assets.CRT).All(c => c == 0) && all.byCoin.All(c => c > 0), $"接受的币越多越容易成交,货款币种随机:{one.sold} → {all.sold}({string.Join("/", all.byCoin)})");
|
||||
var bt = new BlackMarket();
|
||||
Check(!bt.ToggleCoin(Assets.CRT) && bt.ToggleCoin(Assets.PSC) && bt.AcceptedCoins.Count() == 2 && bt.ToggleCoin(Assets.CRT) && !bt.ToggleCoin(Assets.PSC) && !bt.ToggleCoin(Assets.CRC), "收款币至少留一种,只有四种币可选");
|
||||
var b8 = new BlackMarket(); var w8 = new Wallet(); w8.Add(Assets.CRT, 1000);
|
||||
b8.SellAccepts = new List<string> { Assets.PSC };
|
||||
var s8 = b8.List("c4", null, null, 0, 500, 0.8, w8, Assets.CRT, 1, price);
|
||||
b8.Night(2, false, w8, new Rng(3), 0, price);
|
||||
double psc0 = w8.Get(Assets.PSC);
|
||||
b8.Night(5, false, w8, new Rng(4), 0, price);
|
||||
Check(s8.State == SaleState.Paid && s8.PayAsset == Assets.PSC && Near(w8.Get(Assets.PSC) - psc0, s8.Proceeds / 100.0, 1e-9), "货款以命中那一轮的币到账");
|
||||
// 镇压期间不推进
|
||||
var b5 = new BlackMarket(); var w5 = new Wallet(); w5.Add(Assets.CRT, 1000);
|
||||
var s5 = b5.List("c4", null, null, 0, 500, 0.8, w5, Assets.CRT, 1, price);
|
||||
@@ -923,6 +947,13 @@ internal static class Program
|
||||
Check(s5.State == SaleState.Listed, "镇压期间平台下线,不成交");
|
||||
});
|
||||
|
||||
Test("区块增长", () =>
|
||||
{
|
||||
var r = new Rng(5); int lo = int.MaxValue, hi = 0; long sum = 0;
|
||||
for (int i = 0; i < 2000; i++) { int n = TxRules.BlocksPerDay(r); lo = Math.Min(lo, n); hi = Math.Max(hi, n); sum += n; }
|
||||
Check(lo >= Tuning.BlocksPerDayMin && hi <= Tuning.BlocksPerDayMax && hi - lo > 30 && Near(sum / 2000.0, (Tuning.BlocksPerDayMin + Tuning.BlocksPerDayMax) / 2.0, 3), "每晚区块增量在范围内随机");
|
||||
});
|
||||
|
||||
Test("黑市全新卡", () =>
|
||||
{
|
||||
int fresh = 0, total = 0, bad = 0;
|
||||
@@ -1180,6 +1211,7 @@ internal static class Program
|
||||
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.Slowdown(FeeTier.Fast, false) < TxRules.Slowdown(FeeTier.Normal, false) && TxRules.Slowdown(FeeTier.Normal, false) < TxRules.Slowdown(FeeTier.Slow, false) && Near(TxRules.Slowdown(FeeTier.Normal, false), 1, 1e-9) && TxRules.Slowdown(FeeTier.Fast, true) < TxRules.Slowdown(FeeTier.Normal, true), "Gas 越高确认越快,拥堵时快档仍最快");
|
||||
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, "只有拥堵时的慢档会被丢");
|
||||
double lo = 9, hi = 0;
|
||||
|
||||
Reference in new issue
Block a user