Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow catchpoints from the exact target round #167

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions conduit/plugins/importers/algod/algod_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ func getMissingCatchpointLabel(URL string, nextRound uint64) (string, error) {
if err != nil {
return "", err
}
// TODO: Change >= to > after go-algorand#5352 is fixed.
if uint64(round) >= nextRound {
if uint64(round) > nextRound {
break
}
label = line
Expand All @@ -204,8 +203,7 @@ func getMissingCatchpointLabel(URL string, nextRound uint64) (string, error) {
// is detected.
func checkRounds(logger *logrus.Logger, catchpointRound, nodeRound, targetRound uint64) (bool, error) {
// Make sure catchpoint round is not in the future
// TODO: Change < to <= after go-algorand#5352 is fixed.
canCatchup := catchpointRound < targetRound
canCatchup := catchpointRound <= targetRound
mustCatchup := targetRound < nodeRound
shouldCatchup := nodeRound < catchpointRound

Expand Down
19 changes: 18 additions & 1 deletion conduit/plugins/importers/algod/algod_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ func Test_checkRounds(t *testing.T) {
wantLogLevel: logrus.InfoLevel,
wantLogMsg: "Catchup required, node round ahead of target round. Node round 5000, target round 1002, catchpoint round 1000.",
},
{
name: "Catchup required. Success. Edgecase where catchpoint round is equal to target round.",
args: args{
catchpointRound: 1000,
nodeRound: 5000,
targetRound: 1000,
},
want: true,
wantErr: assert.NoError,
wantLogLevel: logrus.InfoLevel,
wantLogMsg: "Catchup required, node round ahead of target round. Node round 5000, target round 1000, catchpoint round 1000.",
},
{
name: "Catchup required. Error.",
args: args{
Expand All @@ -130,8 +142,8 @@ func Test_checkRounds(t *testing.T) {

// Write 1 line to the log.
require.Len(t, hook.Entries, 1)
require.Equal(t, tt.wantLogLevel, hook.Entries[0].Level)
require.Equal(t, tt.wantLogMsg, hook.Entries[0].Message)
require.Equal(t, tt.wantLogLevel, hook.Entries[0].Level)

// Check the error
if !tt.wantErr(t, err, fmt.Sprintf("checkRounds(-, %v, %v, %v)", tt.args.catchpointRound, tt.args.nodeRound, tt.args.targetRound)) {
Expand Down Expand Up @@ -796,6 +808,11 @@ func TestGetMissingCatchpointLabel(t *testing.T) {
require.NoError(t, err)
// closest without going over
require.Equal(t, "1100#abcd", label)

label, err = getMissingCatchpointLabel(ts.URL, 1000)
require.NoError(t, err)
// returns the exact match
require.Equal(t, "1000#abcd", label)
}

func TestGetMissingCatchpointLabelError(t *testing.T) {
Expand Down
Loading