@@ -68,13 +68,6 @@ func TestOverlappingParticipationKeys(t *testing.T) {
68
68
defer fixture .Shutdown ()
69
69
70
70
accountsNum := len (fixture .NodeDataDirs ())
71
- for _ , dataDir := range fixture .NodeDataDirs () {
72
- cfg , err := config .LoadConfigFromDisk (dataDir )
73
- a .NoError (err )
74
- cfg .ParticipationKeysRefreshInterval = 500 * time .Millisecond
75
- err = cfg .SaveToDisk (dataDir )
76
- a .NoError (err )
77
- }
78
71
79
72
genesis , err := bookkeeping .LoadGenesisFromFile (filepath .Join (fixture .PrimaryDataDir (), "genesis.json" ))
80
73
a .NoError (err )
@@ -100,9 +93,25 @@ func TestOverlappingParticipationKeys(t *testing.T) {
100
93
fixture .Start ()
101
94
currentRound := uint64 (0 )
102
95
fixture .AlgodClient = fixture .GetAlgodClientForController (fixture .NC )
96
+
97
+ // ******** IMPORTANT ********
98
+ // It is CRITICAL that this for loop NOT BLOCK.
99
+ // This loop assumes that it stays current with the round of the network.
100
+ // Remember: this test is running while the network is advancing rounds in parallel
101
+ // If this test blocks for more than a couple seconds, then the network round count will have advanced
102
+ // farther than the current "currentRound" variable. This will mean that the "addParticipationKey" function
103
+ // will NOT install the participation key in time for the shortened SeedLookback variable resulting
104
+ // in a network stall and a test failure
103
105
for {
104
106
err := fixture .WaitForRoundWithTimeout (currentRound + 1 )
105
107
a .NoError (err )
108
+
109
+ // A sanity check that makes sure that the round of the network is the same as our
110
+ // current round variable
111
+ sts , err := fixture .GetAlgodClientForController (fixture .NC ).Status ()
112
+ a .NoError (err )
113
+ a .Equal (sts .LastRound , currentRound + 1 )
114
+
106
115
currentRound ++
107
116
if (currentRound - 1 )% 10 < uint64 (accountsNum ) {
108
117
acctIdx := (currentRound - 1 ) % 10
@@ -111,6 +120,7 @@ func TestOverlappingParticipationKeys(t *testing.T) {
111
120
regStartRound := currentRound
112
121
regEndRound := regStartRound + 11 + 4
113
122
123
+ // This cannot block! (See above)
114
124
pk , err := addParticipationKey (a , & fixture , acctIdx , startRound , endRound , regTransactions )
115
125
a .NoError (err )
116
126
t .Logf ("[.] Round %d, Added reg key for node %d range [%d..%d] %s\n " , currentRound , acctIdx , regStartRound , regEndRound , hex .EncodeToString (pk [:8 ]))
@@ -128,17 +138,20 @@ func TestOverlappingParticipationKeys(t *testing.T) {
128
138
func addParticipationKey (a * require.Assertions , fixture * fixtures.RestClientFixture , acctNum uint64 , startRound , endRound uint64 , regTransactions map [int ]transactions.SignedTxn ) (crypto.OneTimeSignatureVerifier , error ) {
129
139
dataDir := fixture .NodeDataDirs ()[acctNum ]
130
140
nc := fixture .GetNodeControllerForDataDir (dataDir )
131
- genesisDir , err := nc .GetGenesisDir ()
132
141
133
142
partKeyName := filepath .Join (dataDir , config .PartKeyFilename ("Wallet" , startRound , endRound ))
134
- partKeyNameTarget := filepath .Join (genesisDir , config .PartKeyFilename ("Wallet" , startRound , endRound ))
135
143
136
- // make the rename in the background to ensure it won't take too long. We have ~4 rounds to complete this.
137
- go os .Rename (partKeyName , partKeyNameTarget )
144
+ // This function can take more than a couple seconds, we can't have this function block so
145
+ // we wrap it in a go routine
146
+ go func () {
147
+ clientController := fixture .GetLibGoalClientFromNodeController (nc )
148
+ _ , err := clientController .AddParticipationKey (partKeyName )
149
+ a .NoError (err )
150
+ }()
138
151
139
152
signedTxn := regTransactions [int (startRound - 2 )]
140
153
a .NotEmpty (signedTxn .Sig )
141
- _ , err = fixture .GetAlgodClientForController (nc ).SendRawTransaction (signedTxn )
154
+ _ , err : = fixture .GetAlgodClientForController (nc ).SendRawTransaction (signedTxn )
142
155
a .NoError (err )
143
156
return signedTxn .Txn .KeyregTxnFields .VotePK , err
144
157
}
0 commit comments