Skip to content

Commit

Permalink
errors(postgresql): Clarify missing ledger state delta message. (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
winder authored Mar 10, 2023
1 parent f5c2701 commit 4179564
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion conduit/plugins/exporters/postgresql/postgresql_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package postgresql
import (
"context"
_ "embed" // used to embed config
"errors"
"fmt"
"sync"
"sync/atomic"
Expand All @@ -26,6 +27,8 @@ import (
// PluginName to use when configuring.
const PluginName = "postgresql"

var errMissingDelta = errors.New("ledger state delta is missing from block, ensure algod importer is using 'follower' mode")

type postgresqlExporter struct {
round uint64
cfg ExporterConfig
Expand Down Expand Up @@ -120,7 +123,7 @@ func (exp *postgresqlExporter) Receive(exportData data.BlockData) error {
if exportData.Round() == 0 {
exportData.Delta = &sdk.LedgerStateDelta{}
} else {
return fmt.Errorf("receive got an invalid block: %#v", exportData)
return errMissingDelta
}
}
// Do we need to test for consensus protocol here?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package postgresql

import (
"context"
"fmt"
"testing"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -80,8 +79,8 @@ func TestReceiveInvalidBlock(t *testing.T) {
Certificate: &map[string]interface{}{},
Delta: nil,
}
expectedErr := fmt.Sprintf("receive got an invalid block: %#v", invalidBlock)
assert.EqualError(t, pgsqlExp.Receive(invalidBlock), expectedErr)
err := pgsqlExp.Receive(invalidBlock)
assert.ErrorIs(t, err, errMissingDelta)
}

func TestReceiveAddBlockSuccess(t *testing.T) {
Expand Down

0 comments on commit 4179564

Please sign in to comment.