Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit e933ffc

Browse files
committed
Fix Test_Validator_PerfectIssuanceWithHugeStake
1 parent 99dab44 commit e933ffc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pkg/tests/validator_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
// Supply for the test with faster slot duration and slots per epoch.
2222
const SUPPLY = iotago.BaseToken(1_813_620_509_061_365)
2323

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 {
2525
var slotDuration uint8 = 5
2626
var slotsPerEpochExponent uint8 = 5
2727
var validationBlocksPerSlot uint8 = 5
@@ -54,13 +54,13 @@ func setupValidatorTestsuite(t *testing.T, walletOpts ...options.Option[testsuit
5454
// Add validator nodes to the network. This will add validator accounts to the snapshot.
5555
vnode1 := ts.AddValidatorNode("node1", append(
5656
[]options.Option[testsuite.WalletOptions]{
57-
testsuite.WithWalletAmount(20_000_000),
57+
testsuite.WithWalletAmount(validator1Balance),
5858
},
5959
walletOpts...,
6060
)...)
6161
vnode2 := ts.AddValidatorNode("node2", append(
6262
[]options.Option[testsuite.WalletOptions]{
63-
testsuite.WithWalletAmount(25_000_000),
63+
testsuite.WithWalletAmount(validator2Balance),
6464
},
6565
walletOpts...,
6666
)...)
@@ -82,6 +82,10 @@ func setupValidatorTestsuite(t *testing.T, walletOpts ...options.Option[testsuit
8282
return ts
8383
}
8484

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+
8589
type EpochPerformanceMap = map[iotago.EpochIndex]uint64
8690
type ValidatorTest struct {
8791
ts *testsuite.TestSuite
@@ -137,9 +141,14 @@ func Test_Validator_PerfectIssuanceWithNonZeroFixedCost(t *testing.T) {
137141
}
138142

139143
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,
141145
// 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)
143152
defer ts.Shutdown()
144153

145154
validationBlocksPerSlot := ts.API.ProtocolParameters().ValidationBlocksPerSlot()

0 commit comments

Comments
 (0)