Skip to content

Commit

Permalink
chore: fix systests
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Jun 12, 2024
1 parent a2253a2 commit db361d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion activation/activation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func newTestBuilder(tb testing.TB, numSigners int, opts ...BuilderOption) *testA
func(core zapcore.Core) zapcore.Core {
return zapcore.NewTee(core, observer)
},
)), zaptest.Level(zap.WarnLevel))
)))

ctrl := gomock.NewController(tb)
tab := &testAtxBuilder{
Expand Down
36 changes: 29 additions & 7 deletions systest/tests/distributed_post_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ func TestPostMalfeasanceProof(t *testing.T) {
localDb := localsql.InMemory()
certClient := activation.NewCertifierClient(db, localDb, logger.Named("certifier"))
certifier := activation.NewCertifier(localDb, logger, certClient)
poetDb := activation.NewPoetDb(db, zap.NewNop())
poetClient, err := activation.NewPoetClient(
activation.NewPoetDb(db, zap.NewNop()),
poetDb,
types.PoetServer{
Address: cluster.MakePoetGlobalEndpoint(ctx.Namespace, 0),
}, cfg.POET,
Expand All @@ -169,12 +170,26 @@ func TestPostMalfeasanceProof(t *testing.T) {
)
require.NoError(t, err)

verifyingOpts := activation.DefaultPostVerifyingOpts()
verifyingOpts.Workers = 1
verifier, err := activation.NewPostVerifier(cfg.POST, logger, activation.WithVerifyingOpts(verifyingOpts))
require.NoError(t, err)

validator := activation.NewValidator(
db,
poetDb,
cfg.POST,
cfg.SMESHING.Opts.Scrypt,
verifier,
)

nipostBuilder, err := activation.NewNIPostBuilder(
localDb,
grpcPostService,
logger.Named("nipostBuilder"),
cfg.POET,
clock,
validator,
activation.WithPoetClients(poetClient),
)
require.NoError(t, err)
Expand Down Expand Up @@ -216,19 +231,26 @@ func TestPostMalfeasanceProof(t *testing.T) {
}
break
}

nipost, err := nipostBuilder.BuildNIPost(ctx, signer, challenge.PublishEpoch, challenge.Hash())
nipostChallenge := &types.NIPostChallenge{
PublishEpoch: challenge.PublishEpoch,
PrevATXID: types.EmptyATXID,
PositioningATX: challenge.PositioningATXID,
CommitmentATX: challenge.CommitmentATXID,
InitialPost: &types.Post{
Nonce: challenge.InitialPost.Nonce,
Indices: challenge.InitialPost.Indices,
Pow: challenge.InitialPost.Pow,
}}

Check failure on line 243 in systest/tests/distributed_post_verification_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed with `-extra` (gofumpt)

nipost, err := nipostBuilder.BuildNIPost(ctx, signer, challenge.Hash(), nipostChallenge)
require.NoError(t, err)

// 2.2 Create ATX with invalid POST
for i := range nipost.Post.Indices {
nipost.Post.Indices[i] += 1
}

// Sanity check that the POST is invalid
verifyingOpts := activation.DefaultPostVerifyingOpts()
verifyingOpts.Workers = 1
verifier, err := activation.NewPostVerifier(cfg.POST, logger, activation.WithVerifyingOpts(verifyingOpts))
require.NoError(t, err)
err = verifier.Verify(ctx, (*shared.Proof)(nipost.Post), &shared.ProofMetadata{
NodeId: signer.NodeID().Bytes(),
CommitmentAtxId: challenge.CommitmentATXID.Bytes(),
Expand Down

0 comments on commit db361d1

Please sign in to comment.