Skip to content

Commit 691c485

Browse files
Testing
1 parent b92aa8c commit 691c485

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

node/node.go

-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ func (node *AlgorandFullNode) Start() {
404404
// startMonitoringRoutines starts the internal monitoring routines used by the node.
405405
func (node *AlgorandFullNode) startMonitoringRoutines() {
406406
node.monitoringRoutinesWaitGroup.Add(2)
407-
408407
go node.txPoolGaugeThread()
409408
// Delete old participation keys
410409
go node.oldKeyDeletionThread()

test/e2e-go/features/participation/overlappingParticipationKeys_test.go

+25-12
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ func TestOverlappingParticipationKeys(t *testing.T) {
6868
defer fixture.Shutdown()
6969

7070
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-
}
7871

7972
genesis, err := bookkeeping.LoadGenesisFromFile(filepath.Join(fixture.PrimaryDataDir(), "genesis.json"))
8073
a.NoError(err)
@@ -100,9 +93,25 @@ func TestOverlappingParticipationKeys(t *testing.T) {
10093
fixture.Start()
10194
currentRound := uint64(0)
10295
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
103105
for {
104106
err := fixture.WaitForRoundWithTimeout(currentRound + 1)
105107
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+
106115
currentRound++
107116
if (currentRound-1)%10 < uint64(accountsNum) {
108117
acctIdx := (currentRound - 1) % 10
@@ -111,6 +120,7 @@ func TestOverlappingParticipationKeys(t *testing.T) {
111120
regStartRound := currentRound
112121
regEndRound := regStartRound + 11 + 4
113122

123+
// This cannot block! (See above)
114124
pk, err := addParticipationKey(a, &fixture, acctIdx, startRound, endRound, regTransactions)
115125
a.NoError(err)
116126
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) {
128138
func addParticipationKey(a *require.Assertions, fixture *fixtures.RestClientFixture, acctNum uint64, startRound, endRound uint64, regTransactions map[int]transactions.SignedTxn) (crypto.OneTimeSignatureVerifier, error) {
129139
dataDir := fixture.NodeDataDirs()[acctNum]
130140
nc := fixture.GetNodeControllerForDataDir(dataDir)
131-
genesisDir, err := nc.GetGenesisDir()
132141

133142
partKeyName := filepath.Join(dataDir, config.PartKeyFilename("Wallet", startRound, endRound))
134-
partKeyNameTarget := filepath.Join(genesisDir, config.PartKeyFilename("Wallet", startRound, endRound))
135143

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+
}()
138151

139152
signedTxn := regTransactions[int(startRound-2)]
140153
a.NotEmpty(signedTxn.Sig)
141-
_, err = fixture.GetAlgodClientForController(nc).SendRawTransaction(signedTxn)
154+
_, err := fixture.GetAlgodClientForController(nc).SendRawTransaction(signedTxn)
142155
a.NoError(err)
143156
return signedTxn.Txn.KeyregTxnFields.VotePK, err
144157
}

0 commit comments

Comments
 (0)