@@ -21,7 +21,7 @@ import (
21
21
// Supply for the test with faster slot duration and slots per epoch.
22
22
const SUPPLY = iotago .BaseToken (1_813_620_509_061_365 )
23
23
24
- func setupValidatorTestsuite (t * testing.T , walletOpts ... options.Option [testsuite.WalletOptions ]) * testsuite.TestSuite {
24
+ func setupValidatorTestsuiteWithStake (t * testing.T , validator1Balance iotago. BaseToken , validator2Balance iotago. BaseToken , walletOpts ... options.Option [testsuite.WalletOptions ]) * testsuite.TestSuite {
25
25
var slotDuration uint8 = 5
26
26
var slotsPerEpochExponent uint8 = 5
27
27
var validationBlocksPerSlot uint8 = 5
@@ -54,13 +54,13 @@ func setupValidatorTestsuite(t *testing.T, walletOpts ...options.Option[testsuit
54
54
// Add validator nodes to the network. This will add validator accounts to the snapshot.
55
55
vnode1 := ts .AddValidatorNode ("node1" , append (
56
56
[]options.Option [testsuite.WalletOptions ]{
57
- testsuite .WithWalletAmount (20_000_000 ),
57
+ testsuite .WithWalletAmount (validator1Balance ),
58
58
},
59
59
walletOpts ... ,
60
60
)... )
61
61
vnode2 := ts .AddValidatorNode ("node2" , append (
62
62
[]options.Option [testsuite.WalletOptions ]{
63
- testsuite .WithWalletAmount (25_000_000 ),
63
+ testsuite .WithWalletAmount (validator2Balance ),
64
64
},
65
65
walletOpts ... ,
66
66
)... )
@@ -82,6 +82,10 @@ func setupValidatorTestsuite(t *testing.T, walletOpts ...options.Option[testsuit
82
82
return ts
83
83
}
84
84
85
+ func setupValidatorTestsuite (t * testing.T , walletOpts ... options.Option [testsuite.WalletOptions ]) * testsuite.TestSuite {
86
+ return setupValidatorTestsuiteWithStake (t , 20_000_000 , 25_000_000 , walletOpts ... )
87
+ }
88
+
85
89
type EpochPerformanceMap = map [iotago.EpochIndex ]uint64
86
90
type ValidatorTest struct {
87
91
ts * testsuite.TestSuite
@@ -137,9 +141,14 @@ func Test_Validator_PerfectIssuanceWithNonZeroFixedCost(t *testing.T) {
137
141
}
138
142
139
143
func Test_Validator_PerfectIssuanceWithHugeStake (t * testing.T ) {
140
- // This gives both validators the max supply as stake, which is unrealistic,
144
+ // This gives one validator almost the max supply as stake, which is unrealistic,
141
145
// but is supposed to test if one validator with a huge stake causes an overflow in the rewards calculation.
142
- ts := setupValidatorTestsuite (t , testsuite .WithWalletAmount (SUPPLY ))
146
+ var validator1Balance iotago.BaseToken = 25_000_000
147
+ var otherAccountBalance iotago.BaseToken = 31_700
148
+ var genesisOutputBalance iotago.BaseToken = 14_100
149
+ var validator2Balance iotago.BaseToken = SUPPLY - validator1Balance - otherAccountBalance - genesisOutputBalance
150
+
151
+ ts := setupValidatorTestsuiteWithStake (t , iotago .BaseToken (validator1Balance ), validator2Balance )
143
152
defer ts .Shutdown ()
144
153
145
154
validationBlocksPerSlot := ts .API .ProtocolParameters ().ValidationBlocksPerSlot ()
0 commit comments