diff --git a/cmd/goal/messages.go b/cmd/goal/messages.go index 6bf976f6a9..bcb7b3fd52 100644 --- a/cmd/goal/messages.go +++ b/cmd/goal/messages.go @@ -62,7 +62,7 @@ const ( infoNodeShuttingDown = "Algorand node is shutting down..." infoNodeSuccessfullyStopped = "The node was successfully stopped." infoNodeStatus = "Last committed block: %d\nTime since last block: %s\nSync Time: %s\nLast consensus protocol: %s\nNext consensus protocol: %s\nRound for next consensus protocol: %d\nNext consensus protocol supported: %v" - infoNodeStatusConsensusUpgradeVoting = "Consensus upgrate state: Voting\nYes votes: %d\nNo votes: %d\nVotes remaining: %d\nYes votes required: %d\nVote window close round: %d" + infoNodeStatusConsensusUpgradeVoting = "Consensus upgrade state: Voting\nYes votes: %d\nNo votes: %d\nVotes remaining: %d\nYes votes required: %d\nVote window close round: %d" infoNodeStatusConsensusUpgradeScheduled = "Consensus upgrade state: Scheduled" catchupStoppedOnUnsupported = "Last supported block (%d) is committed. The next block consensus protocol is not supported. Catchup service is stopped." infoNodeCatchpointCatchupStatus = "Last committed block: %d\nSync Time: %s\nCatchpoint: %s" diff --git a/cmd/goal/node.go b/cmd/goal/node.go index b8b5f2efa4..2b70c25327 100644 --- a/cmd/goal/node.go +++ b/cmd/goal/node.go @@ -482,6 +482,7 @@ func makeStatusString(stat model.NodeStatusResponse) string { upgradeVotesRequired := uint64(0) upgradeNoVotes := uint64(0) upgradeYesVotes := uint64(0) + upgradeVoteRounds := uint64(0) if stat.UpgradeVotesRequired != nil { upgradeVotesRequired = *stat.UpgradeVotesRequired } @@ -491,11 +492,14 @@ func makeStatusString(stat model.NodeStatusResponse) string { if stat.UpgradeYesVotes != nil { upgradeYesVotes = *stat.UpgradeYesVotes } + if stat.UpgradeVoteRounds != nil { + upgradeVoteRounds = *stat.UpgradeVoteRounds + } statusString = statusString + "\n" + fmt.Sprintf( infoNodeStatusConsensusUpgradeVoting, upgradeYesVotes, upgradeNoVotes, - upgradeNextProtocolVoteBefore-stat.LastRound, + upgradeVoteRounds-upgradeYesVotes-upgradeNoVotes, upgradeVotesRequired, upgradeNextProtocolVoteBefore, ) diff --git a/daemon/algod/api/server/v2/generated/model/types.go b/daemon/algod/api/server/v2/generated/model/types.go index 5837057832..faf37aed80 100644 --- a/daemon/algod/api/server/v2/generated/model/types.go +++ b/daemon/algod/api/server/v2/generated/model/types.go @@ -942,7 +942,7 @@ type NodeStatusResponse struct { // UpgradeNodeVote This node's upgrade vote UpgradeNodeVote *bool `json:"upgrade-node-vote,omitempty"` - // UpgradeVoteRounds Total voting ounds for current upgrade + // UpgradeVoteRounds Total voting rounds for current upgrade UpgradeVoteRounds *uint64 `json:"upgrade-vote-rounds,omitempty"` // UpgradeVotes Total votes cast for consensus upgrade diff --git a/daemon/algod/api/server/v2/handlers.go b/daemon/algod/api/server/v2/handlers.go index d9e53216d9..78e8a89a7b 100644 --- a/daemon/algod/api/server/v2/handlers.go +++ b/daemon/algod/api/server/v2/handlers.go @@ -793,26 +793,29 @@ func (v2 *Handlers) GetStatus(ctx echo.Context) error { CatchpointAcquiredBlocks: &stat.CatchpointCatchupAcquiredBlocks, } - nextProtocolVoteBefore := uint64(stat.NextProtocolVoteBefore) - var votesToGo int64 = int64(nextProtocolVoteBefore) - int64(stat.LastRound) - if votesToGo < 0 { - votesToGo = 0 - } - if nextProtocolVoteBefore > 0 { + // Make sure a vote is happening + if stat.NextProtocolVoteBefore > 0 { + votesToGo := uint64(0) + // Check if the vote window is still open. + if stat.NextProtocolVoteBefore > stat.LastRound { + // subtract 1 because the variables are referring to "Last" round and "VoteBefore" + votesToGo = uint64(stat.NextProtocolVoteBefore - stat.LastRound - 1) + } + consensus := config.Consensus[protocol.ConsensusCurrentVersion] upgradeVoteRounds := consensus.UpgradeVoteRounds upgradeThreshold := consensus.UpgradeThreshold - votes := uint64(consensus.UpgradeVoteRounds) - uint64(votesToGo) + votes := consensus.UpgradeVoteRounds - votesToGo votesYes := stat.NextProtocolApprovals votesNo := votes - votesYes - upgradeDelay := uint64(stat.UpgradeDelay) + upgradeDelay := stat.UpgradeDelay response.UpgradeVotesRequired = &upgradeThreshold response.UpgradeNodeVote = &stat.UpgradeApprove response.UpgradeDelay = &upgradeDelay response.UpgradeVotes = &votes response.UpgradeYesVotes = &votesYes response.UpgradeNoVotes = &votesNo - response.UpgradeNextProtocolVoteBefore = &nextProtocolVoteBefore + response.UpgradeNextProtocolVoteBefore = numOrNil(uint64(stat.NextProtocolVoteBefore)) response.UpgradeVoteRounds = &upgradeVoteRounds } diff --git a/daemon/algod/api/server/v2/test/handlers_resources_test.go b/daemon/algod/api/server/v2/test/handlers_resources_test.go index bef0291006..f57121473d 100644 --- a/daemon/algod/api/server/v2/test/handlers_resources_test.go +++ b/daemon/algod/api/server/v2/test/handlers_resources_test.go @@ -229,7 +229,7 @@ func setupTestForLargeResources(t *testing.T, acctSize, maxResults int, accountM acctData = accountMaker(acctSize) ml.accounts[fakeAddr] = acctData - mockNode := makeMockNode(&ml, t.Name(), nil, false) + mockNode := makeMockNode(&ml, t.Name(), nil, cannedStatusReportGolden) mockNode.config.MaxAPIResourcesPerAccount = uint64(maxResults) dummyShutdownChan := make(chan struct{}) handlers = v2.Handlers{ diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index 0c7c5135c4..8595640dba 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -63,12 +63,12 @@ import ( const stateProofIntervalForHandlerTests = uint64(256) -func setupTestForMethodGet(t *testing.T, consensusUpgrade bool) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, []account.Root, []transactions.SignedTxn, func()) { +func setupTestForMethodGet(t *testing.T, status node.StatusReport) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, []account.Root, []transactions.SignedTxn, func()) { numAccounts := 1 numTransactions := 1 offlineAccounts := true mockLedger, rootkeys, _, stxns, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) - mockNode := makeMockNode(mockLedger, t.Name(), nil, consensusUpgrade) + mockNode := makeMockNode(mockLedger, t.Name(), nil, status) dummyShutdownChan := make(chan struct{}) handler := v2.Handlers{ Node: mockNode, @@ -86,13 +86,13 @@ func TestSimpleMockBuilding(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, _, _, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, _, _, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() require.Equal(t, t.Name(), handler.Node.GenesisID()) } func accountInformationTest(t *testing.T, address string, expectedCode int) { - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.AccountInformation(c, address, model.AccountInformationParams{}) require.NoError(t, err) @@ -115,7 +115,7 @@ func TestAccountInformation(t *testing.T) { } func getBlockTest(t *testing.T, blockNum uint64, format string, expectedCode int) { - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.GetBlock(c, blockNum, model.GetBlockParams{Format: (*model.GetBlockParamsFormat)(&format)}) require.NoError(t, err) @@ -134,7 +134,7 @@ func TestGetBlock(t *testing.T) { } func testGetLedgerStateDelta(t *testing.T, round uint64, format string, expectedCode int) { - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(require.New(t), handler, 3) err := handler.GetLedgerStateDelta(c, round, model.GetLedgerStateDeltaParams{Format: (*model.GetLedgerStateDeltaParamsFormat)(&format)}) @@ -179,7 +179,7 @@ func TestSyncRound(t *testing.T) { numTransactions := 1 offlineAccounts := true mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) dummyShutdownChan := make(chan struct{}) handler := v2.Handlers{ Node: mockNode, @@ -240,7 +240,7 @@ func TestSyncRound(t *testing.T) { } func addBlockHelper(t *testing.T) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, transactions.SignedTxn, func()) { - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) l := handler.Node.LedgerForAPI() @@ -324,7 +324,7 @@ func TestGetBlockHash(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.GetBlockHash(c, 0) @@ -342,7 +342,7 @@ func TestGetBlockGetBlockHash(t *testing.T) { t.Parallel() a := require.New(t) - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(a, handler, 2) @@ -414,7 +414,7 @@ func TestGetSupply(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, _, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, _, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.GetSupply(c) require.NoError(t, err) @@ -424,7 +424,7 @@ func TestGetStatus(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.GetStatus(c) require.NoError(t, err) @@ -455,17 +455,72 @@ func TestGetStatus(t *testing.T) { require.Equal(t, expectedResult, actualResult) } +func TestGetStatusConsensusUpgradeUnderflow(t *testing.T) { + partitiontest.PartitionTest(t) + t.Parallel() + + // Setup status report with unanimous YES votes. + proto := config.Consensus[protocol.ConsensusCurrentVersion] + currentRound := basics.Round(1000000) + stat := node.StatusReport{ + LastRound: currentRound - 1, + LastVersion: protocol.ConsensusCurrentVersion, + NextVersion: protocol.ConsensusCurrentVersion, + UpgradePropose: "upgradePropose", + NextProtocolVoteBefore: currentRound, + NextProtocolApprovals: proto.UpgradeVoteRounds, + } + + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, stat) + defer releasefunc() + err := handler.GetStatus(c) + require.NoError(t, err) + actualResult := model.NodeStatusResponse{} + err = protocol.DecodeJSON(rec.Body.Bytes(), &actualResult) + require.NoError(t, err) + + // Make sure the votes are all yes, and 0 no. + require.Equal(t, uint64(0), *actualResult.UpgradeNoVotes) + require.Equal(t, proto.UpgradeVoteRounds, *actualResult.UpgradeYesVotes) + require.Equal(t, proto.UpgradeVoteRounds, *actualResult.UpgradeVotes) + require.Equal(t, proto.UpgradeThreshold, *actualResult.UpgradeVotesRequired) +} + func TestGetStatusConsensusUpgrade(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, true) + cannedStatusReportConsensusUpgradeGolden := node.StatusReport{ + LastRound: basics.Round(97000), + LastVersion: protocol.ConsensusCurrentVersion, + NextVersion: protocol.ConsensusCurrentVersion, + NextVersionRound: 200000, + NextVersionSupported: true, + StoppedAtUnsupportedRound: true, + Catchpoint: "", + CatchpointCatchupAcquiredBlocks: 0, + CatchpointCatchupProcessedAccounts: 0, + CatchpointCatchupVerifiedAccounts: 0, + CatchpointCatchupTotalAccounts: 0, + CatchpointCatchupTotalKVs: 0, + CatchpointCatchupProcessedKVs: 0, + CatchpointCatchupVerifiedKVs: 0, + CatchpointCatchupTotalBlocks: 0, + LastCatchpoint: "", + UpgradePropose: "upgradePropose", + UpgradeApprove: false, + UpgradeDelay: 0, + NextProtocolVoteBefore: 100000, + NextProtocolApprovals: 5000, + } + + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportConsensusUpgradeGolden) defer releasefunc() err := handler.GetStatus(c) require.NoError(t, err) stat := cannedStatusReportConsensusUpgradeGolden consensus := config.Consensus[protocol.ConsensusCurrentVersion] - votesToGo := uint64(stat.NextProtocolVoteBefore) - uint64(stat.LastRound) + votesToGo := uint64(stat.NextProtocolVoteBefore) - uint64(stat.LastRound) - 1 nextProtocolVoteBefore := uint64(stat.NextProtocolVoteBefore) votes := uint64(consensus.UpgradeVoteRounds) - votesToGo votesNo := votes - stat.NextProtocolApprovals @@ -508,7 +563,7 @@ func TestGetStatusAfterBlock(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.WaitForBlock(c, 0) require.NoError(t, err) @@ -521,7 +576,7 @@ func TestGetTransactionParams(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() err := handler.TransactionParams(c) require.NoError(t, err) @@ -529,7 +584,7 @@ func TestGetTransactionParams(t *testing.T) { } func pendingTransactionInformationTest(t *testing.T, txidToUse int, format string, expectedCode int) { - handler, c, rec, _, stxns, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, stxns, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() txid := "bad txid" if txidToUse >= 0 { @@ -552,7 +607,7 @@ func TestPendingTransactionInformation(t *testing.T) { } func getPendingTransactionsTest(t *testing.T, format string, max uint64, expectedCode int) { - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() params := model.GetPendingTransactionsParams{Format: (*model.GetPendingTransactionsParamsFormat)(&format), Max: &max} err := handler.GetPendingTransactions(c, params) @@ -631,7 +686,7 @@ func TestPendingTransactions(t *testing.T) { } func pendingTransactionsByAddressTest(t *testing.T, rootkeyToUse int, format string, expectedCode int) { - handler, c, rec, rootkeys, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, rootkeys, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() address := "bad address" if rootkeyToUse >= 0 { @@ -659,7 +714,7 @@ func prepareTransactionTest(t *testing.T, txnToUse, expectedCode int) (handler v offlineAccounts := true mockLedger, _, _, stxns, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) handler = v2.Handlers{ Node: mockNode, @@ -852,7 +907,7 @@ func TestSimulateTransaction(t *testing.T) { mockLedger, roots, _, _, releasefunc := testingenvWithBalances(t, 999_998, 999_999, numAccounts, 1, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) handler := v2.Handlers{ Node: mockNode, Log: logging.Base(), @@ -1000,7 +1055,7 @@ func TestSimulateTransactionVerificationFailure(t *testing.T) { mockLedger, roots, _, _, releasefunc := testingenv(t, numAccounts, 1, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) handler := v2.Handlers{ Node: mockNode, Log: logging.Base(), @@ -1047,7 +1102,7 @@ func startCatchupTest(t *testing.T, catchpoint string, nodeError error, expected mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nodeError, false) + mockNode := makeMockNode(mockLedger, t.Name(), nodeError, cannedStatusReportGolden) handler := v2.Handlers{Node: mockNode, Log: logging.Base(), Shutdown: dummyShutdownChan} e := echo.New() req := httptest.NewRequest(http.MethodPost, "/", nil) @@ -1088,7 +1143,7 @@ func abortCatchupTest(t *testing.T, catchpoint string, expectedCode int) { mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) handler := v2.Handlers{ Node: mockNode, Log: logging.Base(), @@ -1123,7 +1178,7 @@ func tealCompileTest(t *testing.T, bytesToUse []byte, expectedCode int, mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) mockNode.config.EnableDeveloperAPI = enableDeveloperAPI handler := v2.Handlers{ Node: mockNode, @@ -1194,7 +1249,7 @@ func tealDisassembleTest(t *testing.T, program []byte, expectedCode int, mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) mockNode.config.EnableDeveloperAPI = enableDeveloperAPI handler := v2.Handlers{ Node: mockNode, @@ -1257,7 +1312,7 @@ func tealDryrunTest( mockLedger, _, _, _, releasefunc := testingenv(t, numAccounts, numTransactions, offlineAccounts) defer releasefunc() dummyShutdownChan := make(chan struct{}) - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) mockNode.config.EnableDeveloperAPI = enableDeveloperAPI handler := v2.Handlers{ Node: mockNode, @@ -1376,7 +1431,7 @@ func TestAppendParticipationKeys(t *testing.T) { mockLedger, _, _, _, releasefunc := testingenv(t, 1, 1, true) defer releasefunc() - mockNode := makeMockNode(mockLedger, t.Name(), nil, false) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden) handler := v2.Handlers{ Node: mockNode, Log: logging.Base(), @@ -1460,7 +1515,7 @@ func TestAppendParticipationKeys(t *testing.T) { t.Run("Internal error", func(t *testing.T) { // Create mock node with an error. expectedErr := errors.New("expected error") - mockNode := makeMockNode(mockLedger, t.Name(), expectedErr, false) + mockNode := makeMockNode(mockLedger, t.Name(), expectedErr, cannedStatusReportGolden) handler := v2.Handlers{ Node: mockNode, Log: logging.Base(), @@ -1626,7 +1681,7 @@ func TestStateProofNotFound(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(a, handler, 700) @@ -1639,7 +1694,7 @@ func TestStateProofHigherRoundThanLatest(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() a.NoError(handler.GetStateProof(ctx, 2)) @@ -1650,7 +1705,7 @@ func TestStateProof200(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(a, handler, 1000) @@ -1668,7 +1723,7 @@ func TestHeaderProofRoundTooHigh(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() a.NoError(handler.GetLightBlockHeaderProof(ctx, 2)) @@ -1679,7 +1734,7 @@ func TestHeaderProofStateProofNotFound(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(a, handler, 700) @@ -1692,7 +1747,7 @@ func TestGetBlockProof200(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, ctx, responseRecorder, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() insertRounds(a, handler, 1000) @@ -1823,7 +1878,7 @@ func TestExperimentalCheck(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, false) + handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t, cannedStatusReportGolden) defer releasefunc() // Since we are invoking the method directly, it doesn't matter if EnableExperimentalAPI is true. diff --git a/daemon/algod/api/server/v2/test/helpers.go b/daemon/algod/api/server/v2/test/helpers.go index 8b3ac5f8fc..e8837e3f97 100644 --- a/daemon/algod/api/server/v2/test/helpers.go +++ b/daemon/algod/api/server/v2/test/helpers.go @@ -64,30 +64,6 @@ var cannedStatusReportGolden = node.StatusReport{ LastCatchpoint: "", } -var cannedStatusReportConsensusUpgradeGolden = node.StatusReport{ - LastRound: basics.Round(97000), - LastVersion: protocol.ConsensusCurrentVersion, - NextVersion: protocol.ConsensusCurrentVersion, - NextVersionRound: 200000, - NextVersionSupported: true, - StoppedAtUnsupportedRound: true, - Catchpoint: "", - CatchpointCatchupAcquiredBlocks: 0, - CatchpointCatchupProcessedAccounts: 0, - CatchpointCatchupVerifiedAccounts: 0, - CatchpointCatchupTotalAccounts: 0, - CatchpointCatchupTotalKVs: 0, - CatchpointCatchupProcessedKVs: 0, - CatchpointCatchupVerifiedKVs: 0, - CatchpointCatchupTotalBlocks: 0, - LastCatchpoint: "", - UpgradePropose: "upgradePropose", - UpgradeApprove: false, - UpgradeDelay: 0, - NextProtocolVoteBefore: 100000, - NextProtocolApprovals: 5000, -} - var poolAddrRewardBaseGolden = uint64(0) var poolAddrAssetsGolden = make([]model.AssetHolding, 0) var poolAddrCreatedAssetsGolden = make([]model.Asset, 0) @@ -114,14 +90,14 @@ var txnPoolGolden = make([]transactions.SignedTxn, 2) // package `data` and package `node`, which themselves import `mocks` type mockNode struct { mock.Mock - ledger v2.LedgerForAPI - genesisID string - config config.Local - err error - id account.ParticipationID - keys account.StateProofKeys - usertxns map[basics.Address][]node.TxnWithStatus - consensusUpgrade bool + ledger v2.LedgerForAPI + genesisID string + config config.Local + err error + id account.ParticipationID + keys account.StateProofKeys + usertxns map[basics.Address][]node.TxnWithStatus + status node.StatusReport } func (m *mockNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error) { @@ -159,14 +135,14 @@ func (m *mockNode) AppendParticipationKeys(id account.ParticipationID, keys acco return m.err } -func makeMockNode(ledger v2.LedgerForAPI, genesisID string, nodeError error, consensusUpgrade bool) *mockNode { +func makeMockNode(ledger v2.LedgerForAPI, genesisID string, nodeError error, status node.StatusReport) *mockNode { return &mockNode{ - ledger: ledger, - genesisID: genesisID, - config: config.GetDefaultLocal(), - err: nodeError, - usertxns: map[basics.Address][]node.TxnWithStatus{}, - consensusUpgrade: consensusUpgrade, + ledger: ledger, + genesisID: genesisID, + config: config.GetDefaultLocal(), + err: nodeError, + usertxns: map[basics.Address][]node.TxnWithStatus{}, + status: status, } } @@ -174,13 +150,8 @@ func (m *mockNode) LedgerForAPI() v2.LedgerForAPI { return m.ledger } -func (m mockNode) Status() (s node.StatusReport, err error) { - if m.consensusUpgrade { - s = cannedStatusReportConsensusUpgradeGolden - } else { - s = cannedStatusReportGolden - } - return +func (m *mockNode) Status() (node.StatusReport, error) { + return m.status, nil } func (m *mockNode) GenesisID() string { return m.genesisID