Skip to content

Commit

Permalink
Fix failing tests and use typed errors when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
masih committed Jan 22, 2025
1 parent e355c9a commit 0a406e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion chain/lf3/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (fff *F3) GetLatestCert(ctx context.Context) (*certs.FinalityCertificate, e
func (fff *F3) GetManifest(ctx context.Context) (*manifest.Manifest, error) {
m := fff.inner.Manifest()
if m == nil {
return nil, xerrors.New("no known network manifest")
return nil, manifest.ErrNoManifest
}
if m.InitialPowerTable.Defined() {
return m, nil
Expand Down
15 changes: 10 additions & 5 deletions itests/f3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"golang.org/x/sync/errgroup"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-f3"
"github.com/filecoin-project/go-f3/certs"
"github.com/filecoin-project/go-f3/gpbft"
"github.com/filecoin-project/go-f3/manifest"
Expand Down Expand Up @@ -99,10 +100,10 @@ func TestF3_InactiveModes(t *testing.T) {
expectedErrors: map[string]any{
"F3GetOrRenewParticipationTicket": api.ErrF3NotReady,
"F3Participate": api.ErrF3NotReady,
"F3GetCertificate": "F3 is not running",
"F3GetLatestCertificate": "F3 is not running",
"F3GetManifest": "no known network manifest",
"F3GetF3PowerTable": "no known network manifest",
"F3GetCertificate": f3.ErrF3NotRunning.Error(),
"F3GetLatestCertificate": f3.ErrF3NotRunning.Error(),
"F3GetManifest": manifest.ErrNoManifest.Error(),
"F3GetF3PowerTable": manifest.ErrNoManifest.Error(),
},
expectedValues: map[string]any{
"F3GetOrRenewParticipationTicket": (api.F3ParticipationTicket)(nil),
Expand Down Expand Up @@ -343,7 +344,7 @@ func (e *testEnv) waitTillF3Instance(i uint64, timeout time.Duration) {
e.waitFor(func(n *kit.TestFullNode) bool {
c, err := n.F3GetLatestCertificate(e.testCtx)
if err != nil {
require.ErrorContains(e.t, err, "F3 is not running")
require.ErrorContains(e.t, err, f3.ErrF3NotRunning.Error())
return false
}
return c != nil && c.GPBFTInstance >= i
Expand Down Expand Up @@ -451,7 +452,9 @@ func newTestManifest(networkName gpbft.NetworkName, bootstrapEpoch int64, blockt
// Use smaller time intervals for more responsive test progress/assertion.
Delta: 250 * time.Millisecond,
DeltaBackOffExponent: 1.3,
QualityDeltaMultiplier: manifest.DefaultGpbftConfig.QualityDeltaMultiplier,
MaxLookaheadRounds: 5,
ChainProposedLength: manifest.DefaultGpbftConfig.ChainProposedLength,
RebroadcastBackoffBase: 500 * time.Millisecond,
RebroadcastBackoffSpread: 0.1,
RebroadcastBackoffExponent: 1.3,
Expand All @@ -471,6 +474,8 @@ func newTestManifest(networkName gpbft.NetworkName, bootstrapEpoch int64, blockt
MinimumPollInterval: blocktime,
MaximumPollInterval: 4 * blocktime,
},
PubSub: manifest.DefaultPubSubConfig,
ChainExchange: manifest.DefaultChainExchangeConfig,
}
}

Expand Down
5 changes: 3 additions & 2 deletions itests/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-f3"
"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi"
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
Expand Down Expand Up @@ -569,11 +570,11 @@ func TestGatewayF3(t *testing.T) {
nodes := startNodes(ctx, t)

cert, err := nodes.lite.F3GetLatestCertificate(ctx)
require.ErrorContains(t, err, "F3 is not running")
require.ErrorContains(t, err, f3.ErrF3NotRunning.Error())
require.Nil(t, cert)

cert, err = nodes.lite.F3GetCertificate(ctx, 2)
require.ErrorContains(t, err, "F3 is not running")
require.ErrorContains(t, err, f3.ErrF3NotRunning.Error())
require.Nil(t, cert)
})

Expand Down

0 comments on commit 0a406e1

Please sign in to comment.