@@ -331,7 +331,7 @@ func TestEstimateTerminationPenalty2(t *testing.T) {
331
331
}
332
332
}
333
333
334
- var BLOCK_HEIGHT = abi . ChainEpoch (4198539 )
334
+ var BLOCK_HEIGHT = big . NewInt (4198539 )
335
335
336
336
type baseFiTest struct {
337
337
* BaseFi
@@ -420,7 +420,7 @@ func TestMinerFi(t *testing.T) {
420
420
}
421
421
defer closer ()
422
422
423
- ts , err := lapi .ChainGetTipSetByHeight (context .Background (), BLOCK_HEIGHT , types .EmptyTSK )
423
+ ts , err := lapi .ChainGetTipSetByHeight (context .Background (), abi . ChainEpoch ( BLOCK_HEIGHT . Int64 ()) , types .EmptyTSK )
424
424
if err != nil {
425
425
t .Fatal (err )
426
426
}
@@ -485,10 +485,11 @@ type agentFiTest struct {
485
485
var agentTests = []struct {
486
486
name string
487
487
agent string
488
+ block * big.Int
488
489
want agentFiTest
489
490
}{
490
491
// agent 59
491
- {"agent many miners" , "0x64Ea1aD49A78B6A6878c4975566b8953b1Ef1e79" , agentFiTest {
492
+ {"agent many miners" , "0x64Ea1aD49A78B6A6878c4975566b8953b1Ef1e79" , BLOCK_HEIGHT , agentFiTest {
492
493
AgentFi : & AgentFi {
493
494
BaseFi : BaseFi {
494
495
Balance : bigFromStr ("2090733730144435384596917" ),
@@ -514,7 +515,7 @@ var agentTests = []struct {
514
515
leverageRatio : 0.5743316423053819 ,
515
516
}},
516
517
// agent 27
517
- {"agent no miners" , "0xDBa96B0FDbc87C7eEb641Ee37EAFC55B355079E4" , agentFiTest {
518
+ {"agent no miners" , "0xDBa96B0FDbc87C7eEb641Ee37EAFC55B355079E4" , BLOCK_HEIGHT , agentFiTest {
518
519
AgentFi : EmptyAgentFi (),
519
520
balance : big .NewInt (0 ),
520
521
maxBorrowAndSeal : big .NewInt (0 ),
@@ -526,7 +527,7 @@ var agentTests = []struct {
526
527
leverageRatio : 0 ,
527
528
}},
528
529
// agent 2
529
- {"agent single miner" , "0xf0F1ceCCF78D411EeD9Ca190ca7F157140cCB2d3" , agentFiTest {
530
+ {"agent single miner" , "0xf0F1ceCCF78D411EeD9Ca190ca7F157140cCB2d3" , BLOCK_HEIGHT , agentFiTest {
530
531
AgentFi : & AgentFi {
531
532
BaseFi : BaseFi {
532
533
Balance : bigFromStr ("133252309755096579751" ),
@@ -552,7 +553,7 @@ var agentTests = []struct {
552
553
leverageRatio : 0.016656085317377764 ,
553
554
}},
554
555
// agent 91
555
- {"agent miner with fee debt" , "0xFF65F5f3D309fEA7aA2d4cB2727E918FAb0aE7F7" , agentFiTest {
556
+ {"agent miner with fee debt" , "0xFF65F5f3D309fEA7aA2d4cB2727E918FAb0aE7F7" , BLOCK_HEIGHT , agentFiTest {
556
557
AgentFi : & AgentFi {
557
558
BaseFi : BaseFi {
558
559
Balance : bigFromStr ("0" ),
@@ -577,6 +578,56 @@ var agentTests = []struct {
577
578
marginCall : bigFromStr ("0" ),
578
579
leverageRatio : 0 ,
579
580
}},
581
+ {"agent with balance no miners" , "0xf0F1ceCCF78D411EeD9Ca190ca7F157140cCB2d3" , big .NewInt (4238800 ), agentFiTest {
582
+ AgentFi : & AgentFi {
583
+ BaseFi : BaseFi {
584
+ Balance : bigFromStr ("3454284493328524959" ),
585
+ AvailableBalance : bigFromStr ("3454284493328524959" ),
586
+ LockedRewards : bigFromStr ("0" ),
587
+ InitialPledge : bigFromStr ("0" ),
588
+ FeeDebt : bigFromStr ("0" ),
589
+ TerminationFee : bigFromStr ("0" ),
590
+ LiveSectors : big .NewInt (0 ),
591
+ FaultySectors : big .NewInt (0 ),
592
+ },
593
+ Liability : Liability {
594
+ Principal : bigFromStr ("0" ),
595
+ Interest : bigFromStr ("0" ),
596
+ },
597
+ },
598
+ maxBorrowAndSeal : bigFromStr ("10362853479985574877" ),
599
+ maxBorrowAndWithdraw : bigFromStr ("2590713369996393720" ),
600
+ liquidationValue : bigFromStr ("3454284493328524959" ),
601
+ borrowLimit : bigFromStr ("10362853479985574877" ),
602
+ withdrawLimit : bigFromStr ("3454284493328524959" ),
603
+ marginCall : bigFromStr ("0" ),
604
+ leverageRatio : 0 ,
605
+ }},
606
+ {"agent with balance no miners with principal" , "0xf0F1ceCCF78D411EeD9Ca190ca7F157140cCB2d3" , big .NewInt (4238810 ), agentFiTest {
607
+ AgentFi : & AgentFi {
608
+ BaseFi : BaseFi {
609
+ Balance : bigFromStr ("4454284493328524959" ),
610
+ AvailableBalance : bigFromStr ("4454284493328524959" ),
611
+ LockedRewards : bigFromStr ("0" ),
612
+ InitialPledge : bigFromStr ("0" ),
613
+ FeeDebt : bigFromStr ("0" ),
614
+ TerminationFee : bigFromStr ("0" ),
615
+ LiveSectors : big .NewInt (0 ),
616
+ FaultySectors : big .NewInt (0 ),
617
+ },
618
+ Liability : Liability {
619
+ Principal : bigFromStr ("1000000000000000000" ),
620
+ Interest : bigFromStr ("0" ),
621
+ },
622
+ },
623
+ maxBorrowAndSeal : bigFromStr ("10362852195738999537" ),
624
+ maxBorrowAndWithdraw : bigFromStr ("2340712941914201940" ),
625
+ liquidationValue : bigFromStr ("4454284493328524959" ),
626
+ borrowLimit : bigFromStr ("9362851767656807757" ),
627
+ withdrawLimit : bigFromStr ("3120950589218935919" ),
628
+ marginCall : bigFromStr ("1176471091861402094" ),
629
+ leverageRatio : 0.22450304410954403 ,
630
+ }},
580
631
}
581
632
582
633
func TestEstimateTermationFeeAgent (t * testing.T ) {
@@ -591,14 +642,13 @@ func TestEstimateTermationFeeAgent(t *testing.T) {
591
642
}
592
643
defer closer ()
593
644
594
- ts , err := lapi .ChainGetTipSetByHeight (context .Background (), BLOCK_HEIGHT , types .EmptyTSK )
595
- if err != nil {
596
- t .Fatal (err )
597
- }
598
-
599
645
for _ , tt := range agentTests {
600
646
testname := fmt .Sprintf ("%s:%s" , tt .name , tt .agent )
601
647
t .Run (testname , func (t * testing.T ) {
648
+ ts , err := lapi .ChainGetTipSetByHeight (context .Background (), abi .ChainEpoch (tt .block .Uint64 ()), types .EmptyTSK )
649
+ if err != nil {
650
+ t .Fatal (err )
651
+ }
602
652
603
653
agent := common .HexToAddress (tt .agent )
604
654
@@ -632,7 +682,7 @@ func assertAgentFiEqual(t *testing.T, expected *agentFiTest, actual *AgentFi) {
632
682
t .Fatalf ("Expected principal: %v, actual: %v" , expected .Principal , actual .Principal )
633
683
}
634
684
if expected .Balance .Cmp (actual .Balance ) != 0 {
635
- t .Fatalf ("Expected balance: %v, actual: %v" , expected .balance , actual .Balance )
685
+ t .Fatalf ("Expected balance: %v, actual: %v" , expected .Balance , actual .Balance )
636
686
}
637
687
if expected .FaultySectors .Cmp (actual .FaultySectors ) != 0 {
638
688
t .Fatalf ("Expected faulty sectors: %v, actual: %v" , expected .FaultySectors , actual .FaultySectors )
0 commit comments