Skip to content

Commit

Permalink
test(e2e): test finalize snapshot in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 17, 2025
1 parent 0125867 commit 1afb8be
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
17 changes: 17 additions & 0 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,23 @@ func (app *Application) ApplySnapshotChunk(_ context.Context, req *abci.RequestA
app.logger.Debug("ApplySnapshotChunk", "resp", resp)
return resp, nil
}

func (app *Application) FinalizeSnapshot(ctx context.Context, req *abci.RequestFinalizeSnapshot) (*abci.ResponseFinalizeSnapshot, error) {

Check failure on line 583 in abci/example/kvstore/kvstore.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it to match ^_ (revive)
app.mu.Lock()
defer app.mu.Unlock()

// we only verify the snapshot
if app.LastCommittedState.GetHeight() != req.LightBlock.SignedHeader.Header.Height {
return &abci.ResponseFinalizeSnapshot{}, fmt.Errorf("snapshot height mismatch")
}

if !app.LastCommittedState.GetAppHash().Equal(req.LightBlock.SignedHeader.Header.AppHash) {
return &abci.ResponseFinalizeSnapshot{}, fmt.Errorf("snapshot apphash mismatch")
}

app.logger.Info("FinalizeSnapshot finished successfully", "req", req)
return &abci.ResponseFinalizeSnapshot{}, nil
}
func (app *Application) appVersionForHeight(height int64) uint64 {
if app.appVersion == 0 {
return uint64(height)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/networks/rotate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ start_at = 1005 # Becomes part of the validator set at 1030 to ensure ther
seeds = ["seed01"]
snapshot_interval = 5
block_sync = "v0"
#state_sync = "p2p"
state_sync = "p2p"
#persistent_peers = ["validator01", "validator02", "validator03", "validator04", "validator05", "validator07", "validator08"]
perturb = ["pause", "disconnect", "restart"]
privval_protocol = "dashcore"
Expand Down Expand Up @@ -192,7 +192,7 @@ privval_protocol = "dashcore"
start_at = 1030
mode = "full"
block_sync = "v0"
#state_sync = "rpc"
state_sync = "p2p"
persistent_peers = [
"validator01",
"validator02",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pkg/mockcoreserver/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func WithQuorumVerifyMethod(cs CoreServer, times int) MethodFunc {
&cmd.LLMQType,
&cmd.RequestID,
&cmd.MessageHash,
&cmd.QuorumHash,
&cmd.Signature,
&cmd.QuorumHash,
)
if err != nil {
return nil, err
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/runner/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ func MakeAppConfig(node *e2e.Node) ([]byte, error) {
}

// UpdateConfigStateSync updates the state sync config for a node.
// Arguments:
// - node: the node to update
// - height: the height to trust
// - hash: the hash of the block at `height` to trust
func UpdateConfigStateSync(node *e2e.Node, height int64, hash []byte) error {
cfgPath := filepath.Join(node.Testnet.Dir, node.Name, "config", "config.toml")

Expand All @@ -464,7 +468,7 @@ func UpdateConfigStateSync(node *e2e.Node, height int64, hash []byte) error {
if err != nil {
return err
}
bz = regexp.MustCompile(`(?m)^trust-height =.*`).ReplaceAll(bz, []byte(fmt.Sprintf(`trust-height = %v`, height-1)))
bz = regexp.MustCompile(`(?m)^trust-height =.*`).ReplaceAll(bz, []byte(fmt.Sprintf(`trust-height = %v`, height)))
bz = regexp.MustCompile(`(?m)^trust-hash =.*`).ReplaceAll(bz, []byte(fmt.Sprintf(`trust-hash = "%X"`, hash)))
//nolint: gosec
// G306: Expect WriteFile permissions to be 0600 or less
Expand Down
2 changes: 1 addition & 1 deletion types/quorum_sign_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (i *SignItem) Validate() error {
if len(i.MsgHash) != crypto.DefaultHashSize {
return fmt.Errorf("invalid hash size %d: %X", len(i.MsgHash), i.MsgHash)
}
if len(i.QuorumHash) != crypto.DefaultHashSize {
if len(i.QuorumHash) != crypto.QuorumHashSize {
return fmt.Errorf("invalid quorum hash size %d: %X", len(i.QuorumHash), i.QuorumHash)
}
// Msg is optional
Expand Down

0 comments on commit 1afb8be

Please sign in to comment.